Sie sind auf Seite 1von 10

LATEX Quick Reference

Written by J. Kokorian and T.J. Peters,


adapted by E. Verlinden and R. Bijster
September 2016

Contents
1 Introduction

2 Minimal framework for every LATEX document

3 Commonly used LATEX commands


3.1 Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2
4

4 List structures
4.1 Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Itemization (bullet list) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5
5

5 Floating environments
5.1 Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5
6

6 Math
6.1 Inline math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Equation environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Subscripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6
6
6
6

7 Essential packages
7.1 SIunitx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7
7

8 Optional packages

A Typesetting of Physical Mathematics

1 Introduction
This document offers some guidance to novice LATEX users. A list of frequently used LATEX commands
and packages are shown below. With just the information in this document it is possible to create
a manuscript that contains the most commonly used typographic entities like bullets, enumerations,
graphics, tables and math. Anything related to LATEX that is not found in this document can be easily
found by performing an online search, since the user community is very active.

2 Minimal framework for every LATEX document


Every LATEX file should have at least the following commands:
For the preamble
For the document

\documentclass []{<type>}
\begin {document}
The contents of the document.

\end {document}

3 Commonly used LATEX commands


A LATEX command consists of a backslash followed by its name, brackets for optional arguments and
braces for required arguments:

\command[<optional>]{<required>}
Table 1: Preamble commands

LATEX command

Description

\documentclass[<fontsize>,<papersize>]{<type>}

Sets the document class file to use (e.g.


minimal, article or report).
Loads a package.
Sets the document title.
Sets the author name or names.
Sets the date (if this command is not
used the default is the compiling date).

\usepackage{}
\title{<title>}
\author{<name>}
\date{<name>}

Table 2: Document skeleton

LATEX command

Description

\maketitle
\tableofcontents
\input{<file>}
\include{<file>}

Creates the title (article) or title page (report,book).


Inserts a table of contents.
Inserts the contents of file.
Inserts the contents of file preceded and followed by a
\clearpage.
Defines which .bst style file to use for the bibliography
(use unsrt if you dont care).
Defines which .bib file to use and renders the bibliography
section (dont type the .bib extension in the command).

\bibliographystyle{<stylefile>}
\bibliography{<bibfile>}

Table 3: Typeface changing commands

LATEX command

Description

\textbf {..}
\textit {..}
\underline {..}
{\small ..},{\normalsize ..},{\large ..} etc
$x^{..}$
$x_{..}$

bold font
italic font
underlined font
font size: small,normal, or large
x Superscript
x Subscript

Table 4: Layout commands.

LATEX command

Description

\newpage
\vspace{..}
\hspace{..}
\\
<blank line in your code>
\centering

Pagebreak
Vertical space
Horizontal space
New line
Paragraph break
Centers your text

Table 5: Document structure

LATEX command

Hierarchy level

\part{..}
\chapter{..}
\section{..}
\subsection{..}
\subsubsection{..}
\paragraph{..}
\subparagraph{..}

-1
0 (only for book and report)
1
2
3
4
5

Table 6: References and citations

LATEX command

Description

\label{..}

Inserts

\ref{..}
\eqref{..}

Inserts a reference to a label.


Inserts a reference to an equation (package amsmath).
Example:
\eqref{eq:gauss}.
Inserts a citation to a bibliographic item.
Inserts a reference to the page number of a label.
Creates a superscript footnote symbol and puts the footnote text at the bottom
of the page.

\cite{..}
\pageref{}
\footnote{..}

label.

Examples:

\label{sec:theory}, \label {eq:gauss}.

\label{fig:device lay-out},

3.1 Dimensions
Any time a command requires you to provide a length parameter (such as width, height, size, etc.)
you can enter a number with any of the following units: pt, cm, mm, in, px, ex, em and some more
exotic ones. It is also possible to enter a fraction of a certain layout dimension such as: 0.5\textwidth
or 0.7\columnwidth, which sets the dimension to half the text width or 0.7 times the column width (in
case of multiple columns).

4 List structures
4.1 Enumeration
LATEX command:

Result:

\begin{enumerate}
\item The first item
\item The second item
\item The last item
\end{enumerate}

1. The first item


2. The second item
3. The last item

To create your own enumeration mark: \item[<your own mark>]

4.2 Itemization (bullet list)


LATEX command:

Result:

\begin{itemize}
\item First
\item Second
\item Third with subitems
\begin{itemize}
\item subitem
\item subitem
\end{itemize}
\end{itemize}

First
Second
Third with subitems
subitem
subitem

5 Floating environments
A floating environment is a document element of which the exact location cannot be directly controlled
by the user, but is automatically determined by LATEX. Most floating environments have a caption: a
block of text which is printed above or below the content.
All floating environments can be given an optional argument that specifies where LATEX should attempt to place it. The options are h (here), t (top of the page), b (bottom of the page) and p (separate
page). Multiple arguments can be given to specify in which order LATEXshould attempt to place the floating environment. For example: [htbp] means: try to place it here, if that fails place it on top of the page,
on the bottom of the page, or, if that also fails, place it on its own page. An exclamation mark behind
one of the characters forces LATEX to try harder. The default float location argument is [tbp].

5.1 Figure
When rendered to PDF, LATEX supports the following image file formats: png, pdf, jpg.

\begin{figure}[htbp]
\includegraphics[width=0.5\textwidth]{pics/something_interesting.pdf}
\caption{This figure shows something interesting.}
\label{fig:something interesting}
\end{figure}

5.2 Table
LATEX command:

Result:
Table 7: This is a table

\begin{table}[htbp]
\centering
\caption{This is a table}
\begin{tabular}{rcl}
\toprule
A
& B
& C\\
\midrule
lorem
& ipsum & dolor \\
sit
& amet & consectetur \\
adipisicing & elit & balls \\
\bottomrule
\end{tabular}
\end{table}

A
lorem
sit
adipisicing

B
ipsum
amet
elit

C
dolor
consectetur
balls

6 Math
LATEX is particularly good at typesetting mathematics. This section gives a brief overview of the possibilities. For a complete list of commands see: http://en.wikibooks.org/wiki/LaTeX/Mathematics.

6.1 Inline math


To type math expressions inside a normal paragraph, surround the math with one or two dollar signs
on each side. When using one dollar sign ($x$) you will get x in the same line . When using two dollar
signs ($$y=\int_{0}^{x}..$$) the math will be displayed on a new line, centered:
Z x
y=
2x 0 dx 0 + 3
0

6.2 Equation environment


To place an equation on a separate line and let LATEX assign a reference number to it, use the equation
environment:

\begin{equation}
\label{eq:NewtonsFirstLaw}
F = m \cdot a
\end{equation}
F =ma

6.3 Subscripts
To place upright text inside a math environment, use one of the following commands:
\mathrm{upright text} (preferred): F normal
\textnormal{upright text}: F normal
\textrm{upright text}: F normal
\text{upright text}: F normal
\textup (part of package amsmath): F normal

(1)

7 Essential packages
\usepackage[english]{babel}: Ensures proper hyphenation in the English language.
\usepackage[utf8]{inputenc}: llws typng f nde chrtrs.
\usepackage[T1]{fontenc}: extends the default OT1 7-bit font encoding of TeX to the T1 8-bit
font encoding
\usepackage[small,bf,hang]{caption}: Nicer captions for figures and tables.
\usepackage{xcolor}: allows you to color text, like: {\color{red}{..} which will look like this.
\usepackage{fourier}: sets the font to Utopia which is nice and modern looking. Also provides
lots of additional mathematics symbols.
\usepackage{booktabs}: allows you to use the commands \toprule, \midrule and \bottomrule
in tables which is nice.
\usepackage{graphicx}: without this package it is impossible to include figures!
\usepackage{amsmath}: extended mathematics functionality
\usepackage{siunitx}: typesetting numbers and units, see section 7.1.
\usepackage{hyperref}: makes all citations, references and URLs clickable in the output pdf.
\usepackage{cleveref}: a cleverer way to do cross-referencing than the standard way. Import
this package after all the others.

7.1 SIunitx
The siunitx package introduces a set of absolutely essential commands for typesetting numbers with
units. Never again look for the mu symbol, but simply type \SI{10}{\micro\metre}, to get 10 m.
Note that the space between the number and the unit is slightly smaller than the space between two
words, which is exactly the way it is supposed to be and which is really tedious to accomplish with a
program like MS Word.
Also the readability of large numbers like 1000000 can be improved by writing \num{1000000},
which results in 1 000 000. Delimiters (thin spaces in this case) divide the number in groups consisting
of no more than three digits.
Finally, siunitx supports automatic alignment of the
numbers within table columns. This enables for examTable 8: A table with aligned numbers
ple centering on the decimal marks. All you need to do
is change the column argument of the tabular command.
Decimal-centered Regular centering
Example: \begin{tabular}{S S[table-parse-only]}.
1234.5
1234.5
This example will result in a table with two columns. The
88.8

0.9
88.8
0.9
left column will be decimal-centered while the right col5
4.5

10
4.5

105
umn will be centered in the regular way.

8 Optional packages
The packages listed here are not required to create a document, but provide functionality you might
desire occasionally.
\usepackage{fullpage}: Uses the entire page for the document.
\usepackage{geometry}: Allows you to manually specify the dimensions of margins, headers,
footers, etc.
\usepackage{todonotes}: Allows you to add little todo notes in the document and its margins,
insert missing figure placeholders and print a list of all todos.
\usepackage{natbib}: Extended literature citation functionality.
\usepackage{glossaries}: To create glossaries, nomenclatures and alike.

A Typesetting of Physical Mathematics


The guidelines below are a summary made by R. Bijster of C. Beccari, "Typesetting mathematics for
science and technology according to ISO 31/XI", TUGboat, 18(1), 39-48 (1997).
1. Use serif fonts, instead of sans-serif fonts. In a serif font, the different between I and l is clear.
While for a sans-serif font, it is not: 'I' or 'l' ?
2. Use italic fonts for variables and constants whose value may change with improved measurement.
Although the charge of the electron e, Plancks constant h or the speed of light c can be considered
constants of nature, their numerical value can change when measurement techniques improve.
3. A variable or constant is designated with one letter and as many modifiers as necessary. For exj
ample, a force F axial , for the axial force of the member j .
4. Subscripts and superscripts are in italic only when referring to physical quantities or variables.
For example, the heat capacity C T has an italic subscript, because T refers to temperature, while
R E has an upright subscript, because E refers to emitter.
5. Numerical constants are presented upright. This includes the imaginary number i or j and Eulers
number e. This guideline is often neglected. However, it helps distinguish the imaginary number
i (j) from the iterable i ( j ), and Eulers number e from the standard symbol for electric charge e.
6. Units are separated from the value by means of an unbreakable thin space, and are formatted in
upright text. For example, we write 20 kg, instead of 20kg .
Nota bene: a value can be represented in the format A = {A} [A] . Here the curly braces indicate
value of and the square braces indicate unit of. When presenting data in a table or in a graph,
it is therefore acceptable to rewrite this format to read {A} = A/ [A]. You will sometimes see this
in axis labels in graphs or in table headers. For example, when we are listing or plotting the wavelength, the caption can include: /nm. However, more commonly you will find the unit enclosed
in parentheses in these scenarios: (nm).
LaTeX tip: using the siunitx package for correctly typesetting numerical values and units in
LATEX.
7. Mathematical operators and special functions are formatted in upright text. Brackets are only
needed when there are more than two entities. For example, sin t is okay, and so is sin (2t ).
However, do not write sin 2t .
8. The ISO 80 000 standard and the International Union of Pure and Applied Physics (IPU) prescribe
that the differential operator should be printed in upright text. This means that dx is the preferred
format. In physics and engineering the formal version is preferred, because it allows one to distinguish between the product of variables d and x (d x) and the differential of x: dx. Because of
this, d can be used as a variable, and dd as its differential, rather than d d . Pure mathematics differs in this regard and does not use such typesetting. Unfortunately,
R this is also the most ignored
guideline ofRthe ISO 80 000 standard and you will often encounter f (x) d x, rather then the less
ambiguous f (x) dx. It is a small difference, but nevertheless very useful.
9. Chemical names should be printed in upright format. For example Si3 N4 , Al2 O3 and Ag2+ .
10. Use a thin space or a decimal operator for separating large numbers into triplets. For example,
use 1 200 000, rather than 1200000.
Nota bene: Office does not handle thin spaces very well. Use decimal operators instead.
11. Always add a leading zero for numbers smaller than zero. Use 0.123 instead of .123.

12. Use the right prefix when presenting values to avoid ambiguity. For example, when you write
1200 g, you may have added the trailing zeros to indicate the magnitude of the number. However,
their presence implies in physics that the value was measured with a precision of 0.5 g. If this
is not the case, it is better to use 1.2 kg or resort to scientific notation, 1.2 103 g. It is generally
preferred to drop leading zeros, when possible. For example, 32 pF is preferred over 0.032 nF.

10

Das könnte Ihnen auch gefallen