Thursday, March 31, 2011

Latex Math Tips

Summations
  • If summations become cramped, use \displaystyle before \sum.
  • If summations should be cramped, use \textstyle before \sum.

Numbering lines of equations using align
  • Use align to number all lines; use align* to switch off numbering
  • In align, use \notag before \\ to switch off numbering for a line
  • In align*, use \tag{...} to number (or rather tag) a line
  • Given a numbered/tagged line, use \label{...} before \\ to refer to the line using \ref{...}.
  • Use \allowdisplaybreaks to allow a single equation block to be split over two pages.
Canceling terms in expressions
  • \usepackage{cancel}
  • Four options: \cancel{...}, \bcancel{...}, \xcancel{...}, \cancelto{<val>}{...} (in math mode)
  • Use \usepackage{ulem}, \sout{...} to strike out text.
Others
  • Use \boxed{} to put a box around equations(to highlight them). Note: If you use it within the align environment, it should not contain the `&'; otherwise it will give an error.
  • Use \newcommand{\myfrac}[2]{\ensuremath{\frac{#1}{#2}}} to define new commands (\myfrac) with many (2) arguments, and specify replacement latex code (\ensuremath...), including references to the arguments (#1, #2, ...). The new command can now be used in normal latex code (\myfrac{a}{b}). Aside: \ensuremath{} forces its contents to be interpreted in a math environment.

No comments:

Post a Comment