Friday, October 7, 2011

LaTeX: getting back in the saddle

After spending more than a year away from LaTeX, I have forgotten so much. Here are the things I've had to look up so far:

Setting up LaTeX

I'm using a Mac now and TeXShop. Fortunately it comes with a template, which I've modified slightly (to use the "article" document class). I also installed cocoAspell, which is a dictionary that will filter out the LaTeX keywords. After installation, you have to go to its section in System Preferences to enable the dictionaries and turn on the LaTeX filter. You could go to either System Preferences -> Language & Text or TexShop's Edit->Show Spelling and Grammar (or both) to set it to use the Aspell dictionary.

LaTeX commands

To change the section and subsection numbering style:
\def\thesection {\arabic{section}.}
\def\thesubsection {(\thesection\alph{subsection})}


Set of all reals:
\usepackage{amssymb}
\mathbb{R}

Indicator function:
\usepackage{bbm}
\mathbbm{1}

Lots of symbols:
http://www.artofproblemsolving.com/Wiki/index.php/LaTeX:Symbols

Aligned equations:
\usepackage{amsmath}
\begin{align*}
g^{-1}(\xi) &= \{x \in \mathbb{R}: g(x) = \xi\} \\
h^{-1}(\psi) &= \{y \in \mathbb{R}: h(y) = \psi\}
\end{align*}
If you're trying to align a single equation in multiple places. The parameter is # of columns, which is (# of & signs + 1)/2. Every other & is for alignment, the other ones specify where to add the whitespace.
\begin{alignat*}{2}
f &= ax + b && \ge 0 \\
h &= cx && = 0 
\end{alignat*}

Defining a piecewise function, with the big curly bracket:
f_{Z|X}(z,x) = f_{Y}(z-x) = \begin{cases}
\frac{\mu^{z-x}}{(z-x)!} e^{-\mu} & z-x \ge 0 \\
0 & z-x < 0
\end{cases}

Keeping fractions big:
\frac{\displaystyle ...}{\displaystyle ...}

Particular spacing:
\int x\,dt
i.e.\ in other words

Command shortcuts:
\newcommand{\norm}[1]{\lVert#1\rVert}
\newcommand{\reals}{\ensuremath{\mathbb{R}}}
\def \ba#1\ea {\begin{align*}#1\end{align*}}

Tables:
http://en.wikibooks.org/wiki/LaTeX/Tables

Keeping functions together:
\relpenalty and \binoppenalty
http://www.guyrutenberg.com/2006/12/10/prevent-line-breaking-inline-formula-in-texlatex/

No comments:

Post a Comment