2.1 Using LaTeX

LaTeX is a powerful typesetting language with primary use in academia for the publication of scientific papers and presentation slides as well as book publication. It is also used in RMarkdown, when compiling a notebook to a .pdf format.

2.1.1 LaTeX setup

You can download LaTeX by going to the following website:

and selecting a version for your operating system:

For windows, you can get the proTeXt distribution:

Extract the installation folder:

and open the installation:

Install the distribution:

and make sure that it is the complete package set:

Finally, test if your LaTeX installation is working as intended. You can either open TeXWorks, or download any other TeX editor like TEXMaker and create (and save) the following code:

To compile the .tex document into a .pdf, click the arrow button:

If everything works, a separate window should open with the generated formula file.

2.1.2 Formula examples

More info on LaTeX formulas, matrices, and other mathematical notation General formulas

Formulas in Markdown (and in LaTeX) are written between the $ symbols for inline formulas, and between $$ symbols for centered formulas.

For example, writing $X_t = \sum_{j = 1}^t \epsilon_j$ produces the following output: \(X_t = \sum_{j = 1}^t \epsilon_j\).

Writing $$X_t = \sum_{j = 1}^t \epsilon_j$$ produces: \[X_t = \sum_{j = 1}^t \epsilon_j\] Matrices

If we want to write a matrix, we use (either with $ or $$, and using \quad to separate the different matrices)::

which produces the following output: \[ \begin{bmatrix} \alpha& \beta^{*}\\ \gamma^{*}& \delta \end{bmatrix}, \quad \begin{pmatrix} \alpha& \beta^{*}\\ \gamma^{*}& \delta \end{pmatrix} \] Equation aligning

Using the align environment and writing & next to the symbols we want to align in each row lets us specify multiple equations aligned by the same symbol, for example:


\[ \begin{aligned} Y_{1,t} &= \alpha_1 + \beta_1 X_{1,t} + \epsilon_{1,t} \\ Y_{2,t} &= \alpha_1 + \beta_1 X_{1,t} + \epsilon_{1,t} \end{aligned} \]

Or if we need to write our equation in a different form:

\[ \begin{aligned} f(x) &= (a+b)^2 \\ &= a^2+2ab+b^2 \end{aligned} \]

Or if we simply have longer names for our variables:

\[ \begin{aligned} Population_t &= \alpha_1 + \gamma_1 X_{1,t} + \gamma_2 X_{1,t-1} \\ Price_t &= \alpha_2 + \beta_1 Z_{1,t} \end{aligned} \] Writing equation systems

We can write the equation systems using the cases environment (note - we are also using the & symbol to align our equations):

\[ f(n) = \begin{cases} n/2 &\mbox{if } n \equiv 0 \\ (3n +1)/2 & \mbox{if } n \equiv 1. \end{cases} \pmod{2} \]