Monday, January 21, 2013

Short LaTeX Tutorial

A Short LaTeX Primer

A Short \(\LaTeX\) Primer

I will expand this list as the need arises. A more complete primer can be found here.

Use the following \(\LaTeX\) commands to enter the following basic mathematical elements:

  • All latex commands start with a \ symbol and must be between single or double dollar signs
  • Mathematics inline within text must be between $ signs. For example, this equation $2x\sqrt{x^2+3} = 5 - x$ is inline and was typeset as:

    ...this equation $2x\sqrt{x^2+3} = 5 - x$ is inline and...

  • Mathematics displayed, centered on its own line must be between $$ signs. For example, this equation $$2x\sqrt{x^2+3} = 5 - x$$ is displayed, and was typeset as:

    ...this equation $$2x\sqrt{x^2+3} = 5 - x$$ is displayed...

  • \frac{a}{b} for \(\frac{a}{b}\)
  • \sqrt{a} for \(\sqrt{a}\)
  • \sqrt[n]{a} for $\sqrt[n]{a}$
  • _ for subscripts. For example a_1 for \(a_1\) but if the subscript is more than a single character, then you must put it in braces as in a_{34} for \(a_{34}\).
  • ^ for superscripts (exponents and such). For example x^2 for \(x^2\). As with subscripts if the superscript is more than a single character, enclose it in braces as in x^{23} for \(x^{23}\).
  • \int x^2\;dx for $\int x^2\;dx$; \int_2^3 x^2\;dx for $\int_2^3 x^2\;dx$. The \; gives a bit of extra space.
  • \sum a_i for $\sum a_i$; \sum_{i=1}^{\infty} a_i for $\sum_{i=1}^{\infty} a_i$.
  • \vec{v} for $\vec{v}$ (vectors).
  • \bvec{v} for $\bvec{v}$ (bold vector notation).
  • \lang{3,4,5} for $\lang{3,4,5}$ (vectors in component form)
  • You can use \cdot (center dot) for dot products as in $\vec{v}\cdot\vec{w}$.
  • You can use \times for cross products as in $\vec{v}\times\vec{w}$.
  • For absolute value (or norm of a vector), use |\vec{v}| as in $|\vec{v}|$.
Here is an example of a more complicated expression entered using $\LaTeX$. The code $\sqrt{\vec{v}\cdot\vec{v}} = |\vec{v}|$ creates $\sqrt{\vec{v}\cdot\vec{v}} = |\vec{v}|$.

1 comment: