LaTeX

Online LaTeX editing tools

Want the equivalent of Google docs, but for LaTeX documents? Try Overleaf. It allows several users to share a document and edit it at the same time.

Readings

Beginners are strongly recommended to read the book "LaTeX: A Document Preparation System" by Leslie Lamport. Intermediate to advanced LaTeX users can take advantage of the book "The LaTeX Companion" by Mittelbach, Goossens and Samarin.

Basic rules to follow

New sentence = new line: always start new a new sentence on a new line. It would even make sence to break sentences on several lines, for example commas, semi-colon, etc. would be good places where to split your text.

Put a tilde sign in front of most references, such as ~\cite, ~\ref, etc.

Quotes should be formated like this: ``jump number'' (not "jump number").

Problems with formatting

Sometimes, LaTeX is not able to find a way to layout the text that respects the various constraints it is trying to optimize. Then, LaTeX is too strict and results in overfull parts that extend past the end of the column. One way to reduce this problem is to add \sloppy. This tells LaTeX to be less picky when trying to format the text in the best way possible.

Symbols

Draw symbols and get the corresponding LaTeX code: Detexify: http://detexify.kirelabs.org/classify.html

Adding space

\vspace{}, \hspace{}, for example \hspace{3em} adds the width of 3 M characters. The size ex is similar, but the height of the X character. The spaces can be specified in various formats: cm, pt, etc.

Math

Space in mathematical formulas

To add spaces in math mode, use \,, \:, \;, \quad, \qquad to add positive space. Use \! for negative space.

Fractions

It is possible to use \frac{1}{2} to create a fraction. When inside a paragraph, the fraction will be small. To make it larger, use \dfrac{1}{2}.

Words, variables, functions, etc. inside math modes

To have a function such as "project" to display properly, use $\textit{project}$. Otherwise, LaTeX will format it as if it was the product of p times r times o, ... which results in an awkward spacing between the individual letters. It is also possible to have the text in upright characters with $\mathrm{project}$. Using either textit or mathrm results in a correct spacing of the text inside mathematical formulas.

Figures and tables placement

To try to force LaTeX to put figures and other floats where you want them, use the parameters h, t, b (here, top, bottom). Example: \begin{figure}[tbh]. If this is not enough, try forcing it further with !. Example: \begin{figure}[!t].

Arrows over or under text

Depending on the wanted result, there are two possibilities. You need to use amsmath (\usepackage{amsmath}). First \overrightarrow{your text}, \overleftarrow{your text}, \underrightarrow{your text}, \underleftarrow{your text}, \overleftrightarrow{your text}, \underleftrightarrow{your text}. The arrow is in supersript or subscript position. If the arrow is expected to be centered, use this instead: \xrightarrow[subscript text]{superscript text}. \xleftarrow[subscript text]{superscript text}. The subscript is optional and the super script can be left empty.

tabular

To build a table with proper alignment, use \begin{tabular}{your alignment} where "your alignment" is a mixture of l for left aligned column, c for centered column, r for right aligned column. Between the l, r and c, you can add @{wathever} where "wathever" will replace the inter column space. This can be used to bring the columns much closer together. Example:

\begin{tabular}{@{}c|r@{}}

no wasted space to the left & no wasted space to the right \\

\end{tabular}

You can also use | to put a line between columns. Example:

\begin{tabular}{c|r}

centered text & right justified text \\

next line & wathever \\

\end{tabular}

Use \[ \begin{array}{cr} ... \end{array} \]

for mathematical expressions.

Merging tabular columns together

In order to merge multiple columns together, for a header line for example, use the multicolumn command. For example:

\begin{tabular}{lll}

\multicolumn{c}{2}{Date} & Task \\

March & 3 & Repair the car.

\end{tabular}

As can be seen, the multicolumn column command can also be used to change the alignment.

Alignment on decimal

Alignment on decimal characters is possible with the use of the dcolumn package. A quici example:

\usepackage{dcolumn}

...

\newcolumntype{.}{D{.}{.}{1}}

\begin{tabular}{l.}

A & 1.3 \\

B & 11 \\

\end{tabular}

If you don't want to use the dcolumn package (or it is not possible due to other packages constraints), it is also possible to simply use @{} to stick together decimal numbers:

\begin{tabular}{r@{.}l}

3 & 1416 \\

2 & 7183 \\

\end{tabular}

Degree, times (*)

Looking for the degree symbol? Try using $180^{\circ}$.

Looking for the multiplication symbol? Try using $2\times 3$

Multi-line equations

Can use \begin{align} \end{align}. For example

\begin{align}

a = & 1 + 2 \nonumber \\

& 3 + 4

\end{align}

Can also use \begin{eqnarray} \end{eqnarray}.

LaTeX to Word and Word to LaTeX

The LaTeX-to-Word tool by GrindEQ works quite well for the text and the equations. It greatly eases the process of putting your text through a spelling and grammar checker. Figures are not converted properly. GrinqEQ also provides the inverse tool (Word to LaTeX).

It is also possible to insert LaTeX equations in a Word Document with the sourceforge project LaTeX in Word

Another approach would be to use pdflatex and then to convert the pdf to Word. There are several pdf to Word converters, some even free online converters. NitroPDF is one option to consider for pdf to Word conversion. It is not perfect but it does a decent job.

LaTeX to Powerpoint

TexPoint allows LaTeX equations to be inserted in a Powerpoint presentation.

LaTeXit does the same thing and can insert equations in several software such as Word, Powerpoint, Keynote, etc.

Using LaTex with CVS or Subversion (SVN)

Avoid adding these files to your repository: *.aux, *.bbl, *.blg, *.log, *.dvi. It also makes sense to ignore your output pdf file. All of this can be done easily using the .cvsignore file for CVS or using the property svn:ignore with Subversion. In both cases, put one file per line.

Fonts in figures created in other software

When preparing figures and graphs for a LaTeX document, if you want or need to have the same font as the one in typical LaTeX document, this font is Computer Modern. True Type Font equivalents can be found here: http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/ttf/

There are tons of variants on this page. The cmr10.ttf font (Computer Modern Roman?) provides adequate results and can be installed on Windows systems.

MacOSX

Useful resources found on the Mac TUG wiki. The best distribution is MacTex. TexWorks seems to be a good LaTeX editor. Aquamacs is also a good option if you are familiar with emacs.

If you are using Windows latin files under MacOS, you are likely to run into problems. This might solve the issue for dos encoded files containing accents:

\usepackage[T1]{fontenc}

\usepackage[utf8]{inputenc}

Windows

TeXLive is a good distribution for Windows. It comes with TexWorks.

Numbering lines

Sometimes when submitting a paper to a conference, it is expected to number the lines of your paper. Use the lineno package:

\usepackage{lineno}

If your document is in two column, use the switch option:

\usepackage[switch]{lineno}

You need to use the \linenumbers command:

\begin{document}

\linenumbers

Conditions

Should you need to add conditional expressions (boolean expressions, if) to your LaTeX file, for example to switch between an anonymous version of your paper and the final version with author names and acknowledgements, try this:

\newif\ifanonymous

\anonymoustrue

...

\ifanonymous

Anonymous Author

\else

Your Real Name

\fi

Available fonts for LaTeX documents

See this list (LaTeX font calalogue: https://tug.org/FontCatalogue/ ) of fonts should you need to use something else than the default Computer Modern font.