LaTeX tips and tricks

These are just a few things I’ve learnt since I started using \LaTeX.

What is LaTeX ?

1. Skeleton/Blank LaTeX document

\documentclass{article}
\usepackage{amsmath,amsthm,amsfonts}
\usepackage{graphicx}

\begin{document}

Stuff goes here

\end{document}

2. Creating a matrix/array in LaTeX

Example: A 2×2 matrix (Identity)

 \left ( \begin{array}{cc}
 1 & 0 \\
 0 & -1 \end{array} \right)
 

\left ( \begin{array}{cc}
1 & 0 \\
0 & -1 \end{array}  \right )

3. Getting Field Symbols

If you want to get integer,complex or real symbols you can do this. You need to include the amsfonts package.

\usepackage{amsfonts}
\newcommand{\field}[1]{\mathbb{#1}}

\field{C}  %Complex numbers
\field{Z}  %Integers
\field{R}  %Real numbers 

4. Tables in Latex

Tables can be produced in LaTeX using the tabular environment. In a tabular environment, the format specification after \begin{tabular} should consist of one or more of the following, enclosed within braces { and }:

l specifies a column of left-justified text
c specifies a column of centred text
r specifies a column of right-justified text
p{width} specifies a left-justified column of the given width
| inserts a vertical line between columns
@{text} inserts the given text between columns

Example:

\begin{tabular}{|r|r|}
\hline
$n$&$n!$\\
\hline
1&1\\
2&2\\
3&6\\
4&24\\
\hline
\end{tabular}

\begin{tabular}{|r|r|}
\hline
$n$&$n!$\\
\hline
1&1\\
2&2\\
3&6\\
4&24\\
\hline
\end{tabular}

5. Numbering in Latex

Each of these objects are numbered in LaTeX with a counter:

part paragraph figure enumi
chapter subparagraph table enumii
section page footnote enumiii
subsection equation mpfootnote enumiv
subsubsection

The code word that prints the current value of the counter in your document is \thecounter. That is, \thepart, \thechapter, \thesection and so on.

Changing the Numbering Style You can change the way the number is printed. You have these choices:

   \arabic{4} 4
   \roman{4} iv
   \Roman{4} IV
   \alph{4} d
   \Alph{4} D 

To change the numbering style, even half way through your document, you simply \renew it:

\renewcommand{\labelenumi}{\textbf{(\arabic{enumi})}}

5. A Simple Bibliography

This can go at the end of your LaTeX file. To refer to something from your bibliography you can put something like this in your file:

This is a citation \cite{Burl}.

\begin{thebibliography}{2}

  \bibitem{Burl} M. Burl, M. Weber, and P. Perona. A probabilistic
approach to object recognition using local photometry and global 
geometry. In Proceedings of the European Conference on Computer Vision,
pages 628-641, 1998.


\end{thebibliography}

6. Multiline subscripts

The \substack command is quite useful when you want to have multiline subscripts for summations, limits etc.

Syntax:

\substack{ line1 \\ line 2 \\ ...}

Example:

\sum _{ {l=1 \\l\neq l_1}}^{L}\delta _{l_1}^{(3)}(p)

\sum _{\substack{l=1 \\ l\neq l_1}}^{L}\delta _{l}^{(3)}(p)

7. Spacing in Math Mode

LaTeX provides the following four commands for use in math mode:

  • \; - a thick space

a \; b

  • \: - a medium space
  • \, - a thin space
  • \! - a negative thin space
Creative Commons License Valid CSS Valid XHTML 1.0 Driven by DokuWiki Powered by PHP Powered by Apache get firefox!! kgareth.com Recent changes RSS feed