

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This cheat sheet contains the main notions about Latex, a software system for document preparation: Layout, Structure the Document, Math Equations, Text,Floating Environments.
Typology: Cheat Sheet
1 / 2
This page cannot be seen from the preview
Don't miss anything!
“Write clear & beautiful english with LATEX!”
You have to include the package mentioned in the headings e.g. to use \definecolor you have to include the xcolor package with \usepackage{xcolor} in the preamble
Available units for lengths and dimensions: points pt millimeter mm inch in m width em pixel px centimeter cm pica pc x height ex
\ introduces a command (in text \textbackslash) { } embraces arguments, creates logical parts (${ }$) [ ] embraces optional command parameters ($[ ]$) % comments: code after % will be ignored. (%) & separates columns in tables (&)
_ ^ indizes and exponents in mathmode. e.g. a^21 (_ ^)
Usage: \documentclass[opt,opt]{class}
Common classes: scrartcl (article), scrreprt (report), scrbook (book)
Common Options: 10pt/11pt/12pt Font size.
letterpaper/a4paper Paper size. twocolumn Use two columns.
twoside Set margins for two-sided.
landscape Landscape orientation.
Usage: \usepackage[opt, opt]{package}
\PassOptionsToPackage{opt, opt}{package}
Penalties are the main values that TEXtries to minimise when line or page breakes are calculated. \linepenalty=10 breaking a page within a paragraph
\hyphenpenalty=50 line breaking at an automatic hyphen \binoppenalty=700 breaking a line at a binary operator
\relpenalty=500 breaking a line at a relation \clubpenalty=150 *breaking after first line of a paragraph
\widowpenalty=150 *breaking before last line of a paragraph
\brokenpenalty=100 page breaking after a hyphenated line
\usepackage[ngerman, english]{babel} (last language default) \selectlanguage{language} \foreignlanguage{language}{text}
Load \usepackage[acronym]{glossaries} Define: \newacronym{label}{ABB}{written-out} \newglossaryentry{label}{name=..., description=...} Use: \gls{label}, \glspl{label}
Usage: \geometry{ opt, opt, ... }
Margin Notes
1
2
3
(^4 )
6
7
8
9
10
11
bottom
top
left right
© 1 1in + \hoffset © 2 1in + \voffset © 3 \oddsidemargin © 4 \topmargin © 5 \headheight © 6 \headsep ©^7 \textheight ©^8 \textwidth © 9 \marginparwidth 10 © \marginparwidth 11 © \footskip Additional paramter: left,right,top,bottom, paper=a4paper, landscape|portrait, includehead,includefoot, twocolumn
\ usepackage { fancyhdr } \ pagestyle { fancy } % use fancyhdr pagestyle \ fancyhf {} % clear header and footer \ fancyhead [ RE ]{} % even page right header
\ usepackage { xcolor } \ definecolor { tum _ blue }{ RGB }{0 , 115 , 207} \ colorlet { col _ section }{ tum _ blue }
Predefined colors: white, gray, black, red, green, blue, cyan, magenta, yellow Fade a color with !value between 0 and 100, e.g. \color{gray!70} Usage in Text: \textcolor{red}{text} or {\color{red}text}
default: \author{text}, \title{text}, \date{\today}, \maketitle titlepage: \begin{titlepage} text \end{titlepage}
\tableofcontents \listoftables \listoffigures \printglossaries (needs glossaries package)
\part{title} \subsubsection{title} \chapter{title} \paragraph{title} \section{title} \subparagraph{title} \subsection{title} *: no numbering, no entry in ToC \part and \chapter only in dcumentcalss book or report
\begin{itemize} with bullet \item or \item[symbol] \begin{enumerate} with numbered \item \begin{description} with bold \item[word]
\ begin { enumerate }\ itemsep 0 pt \ item First Argument \ item Second Argument \ end { enumerate }
Command Declaration Effect
\textrm{text} {\rmfamily text} Roman family \textsf{text} {\sffamily text} Sans serif family \texttt{text} {\ttfamily text} Typewriter family \textmd{text} {\mdseries text} Medium series \textbf{text} {\bfseries text} Bold series \textup{text} {\upshape text} Upright shape \textit{text} {\itshape text} Italic shape \textsl{text} {\slshape text} Slanted shape \textsc{text} {\scshape text} Small Caps shape \emph{text} {\em text} Emphasized \textnormal{text} {\normalfont text} Document font \underline{text} Underline
\tiny tiny \scriptsize scriptsize \footnotesize footnotesize \small small \normalsize normalsize
\LARGE LARGE
\Huge Huge
Environment Declaration Other \begin{center} \centering text \vfill text \begin{flushleft} \raggedright text \hfill text \begin{flushright} \raggedleft
Textstyle: $x^2 + 4$, x^2 + 4 as part of the text. Disyplaystyle: \begin{equation} x^2 + 4 \end{equation}
λ := lim x 1 →∞
xˆ 1
x 0
f
t 2
n^ √t (^2) + sin (^2) (t) dt^
! ≤ 1 (1)
for numbered equations. use the * variant for unnumbered equations.
\scriptscriptstyle, \scriptstyle, \textstyle, \displaystyle \mathrm, \mathit, \mathbb, \mathcal, \mathfrak
xn+1^ x^{n+1} Ekin E_{\mathrm{kin}} a + b 2
\frac{a+b}{2} n
a^2 + b^2 \sqrt[n]{a^2+b^2}
x 1 ,... , xn x_1 , \ldots, x_n
x 1 + · · · + xn x_1 + \cdots + x_n ( a +
\left( a + \frac12 \right)^
∑^ N
i=
i=
\sum\limits_{i=1}^{N}, \prod\limits_{i=1}^{N}
F (^) ⊥, F (^) ‖ \vec F_{\perp}, \vec F_{\parallel}
lim a→∞ \lim\limits_{a \rightarrow \infty} ˆ^ b
a
x^2 dx \int\limits_a^b x^2; \mathrm{d}x
df dx
x 0
\left.\frac{\mathrm df}{\mathrm dx} \right|_{x_0}
a>, A†, A∗^ \vec a^\top, A^\dagger, A^* ! <,
def = \stackrel{!}{<}, \stackrel{\rm def}{=}
\sin \sinh \arcsin \csc \ln \min \cos \cosh \arccos \sec \lg \max \tan \tanh \arctan \cot \log \lim \exp \det \tr \dim \ker \Pr
\sum
\prod
´ \int \int
\iint
\iiint
\oint
≥ \ge \gg × \times = = 6 = \ne ≡ \equiv ≈ \approx | | ⊥ \perp | \mid ‖ \parallel f ′^ f’ ∇ \nabla ∆ \Delta ∂ \partial ∈ \in ∀ \forall ∃ \exists @ \nexists ∩ \cap ∪ \cup ∈/ \notin \ \setminus ` \ell ∠ \angle ◦ \circ ∅ \emptyset ∨ \lor ∧ \land ¬ \lnot ∅ \varnothing \top ⊥ \bot ∞ \infty ∝ \propto
Homepage: www.latex4ei.de – please report misstakes immediately. by Emanuel Regnath, contact emanuel.regnath@tum.de Created 17. November 2013 at 16:54 1
(.) (.) [.] [.] b.c \lfloor.\rfloor |.| |.| {.} {.} d.e \lceil.\rceil ‖.‖ |.| |.| \vert.\vert 〈.〉 \langle.\rangle Use \left( expr \right) to stretch any delimeter to the height of expr Or \big, \Big, \bigg for manual sizing e.g. \Big| \Big|
Every combination of left,right,up,down with arrow(s) 7 → \mapsto \leadsto
→ \rightarrow ⇒ \Rightarrow −→ \longrightarrow =⇒ \Longrightarrow
← \leftarrow ⇐ \Leftarrow ←− \longleftarrow ⇐= \Longleftarrow
↑ \uparrow ⇑ \Uparrow
↓ \downarrow ⇓ \Downarrow ↔ \leftrightarrow ⇔ \Leftrightarrow
⇔ \leftleftarrows ⇒ \rightrightarrows
\leftrightarrows \rightleftarrows \leftrightharpoons \rightleftharpoons
Use the package siunitx for correct display of numbers and units. It provide the commands \num{
7 .123 456 × 1012 \num{7.123456e12}
[g] = m s−^2 [g] = \si{\meter \per \second \squared}
E = 1. (^3) mmkV E = \SI{1.3}{\kilo\volt\per\milli\meter}
You can use all SI units (pascal, henry, ...) and not only the base units. It is also possible to change the style of display with \sisetup{per-mode=reciprocal} or \sisetup{per-mode=fraction}: Prefixes like \kilo,\deca,\mega,\micro
latex4ei_thesis: layout with TUM colors scientific: useful scientific macros dx \diff x N, R, C \N, \R, \C
x \vec x
x 1 x 2
\vect{ x_1 \ x_2 }
\ma A
\mat{ 1 & 2 \ 3 & 4}
b^ F r \FT
DT Fb r \DTFT b^ L r \LT bZ r \ZT Additional function names (upright, correct spacing): \const, \sinc, \grad, \rot, \div, \tri, \rect, \erf
\ begin { figure } \ centering \ includegraphics [ width =9 cm ]{./ img / diagram. pdf } \ caption [ title for LOF ]{ this is the long title } \ label { fig : example 1} \ end { figure }
Load image: \includegraphics[width=x]{file} Alter numbering: \renewcommand\thefigure{\arabic{figure}} 8.1.1 Subfigures with subfigure Usage \subfigure[caption]{graphic, label}
\ begin { table } \ centering \ begin { tabular }{ ll } \ textsc { Name } & \ textsc { Desc .}\ \ hline test 1 & is no good idea &\ bla 2 & even worse &\ \ end { tabular } \ caption { My first Table } \ label { tab : example 1} \ end { table }
Usage: \begin{tabular}[htbp]{@{}lrc|p{3cm}} Column distance: \setlength{\tabcolsep}{5pt} Adjust row distance: \renewcommand{\arraystretch}{1.5} Partial lines: \cline{2-3} instead of \hline Additional packages: longtable, booktabs, colortbl
Options: \lstset{basicstyle=\tt, language=C} Languages: C,C++,Java,Matlab,Python,HTML,XML,bash,...
Environment: \begin{lstlisting} code \end{lstlisting} Inline: \lstinline?code?
\ begin { lstlisting } int i =0; for ( i = 0; i < 10; i ++){ printf ( " Line % i " , i ); } \ end { ltlisting } % missing s!
Rule: The hyphen is never placed between two spaces!
Name Source Example Usage
hyphen - X-ray, in- and output connect words en-dash -- 1 – 5, Paris – Rom seperate numbers. em-dash --- Yes—or no? Punctuation. minus $-$ 5 − 3 = 2 Equations.
Language Symbols LaTeX
German ” ’
... ‘ “ \glqq \glq ... \grq \grqq English “ ‘... ’ ” ‘‘ \lq ... \rq ’’ France <... > \flqq \flq ... \frq \frqq
“I think”, said Anna, “he shouted ‘This is Lars’s car!’, when I saw him.”
Numbers Look Usage
old-style as part of text, dates lining 1234567890 as math value
British American German
27/06/93 06/27/93 27.06. 27 June, 1993 June 27, 1993 27. Juni 1993 International notation (ISO 8601): yyyy-mm-dd: 1993-06-
a!b ab a,b a b a;b a b a\quad b a b ab ab a>b a b a\ b a b a\qquad b a b \hspace{length}, \vspace{length} *: even at line start \phantom{text}, \vphantom{text} Protected space ~
Normal: \parbox[pos][height][contentpos]{width}{text} or \begin{minipage}[pos][height][contentpos]{width} text
Prevent line breaking: \mbox{text} Lift Text: \raisebox{lift}[height][depth]{text} Framed Box: \framebox[width][pos]{text} or \fbox{text} Resize: \scalebox{10}{Giant} Lengths: \setlength{\fboxsep}{10pt}, \setlength{\fboxrule}{2pt}
@article Journal or magazine article. fields: author, title, journal, year, volume
@book Book with publisher. fields: author/editor, title, publisher, year
@techreport Tech report, usually numbered in series. fields: author, title, institution, year
@phdthesis PhD. or other thesis. fields: author, title, school, year
\ bibliographystyle { alphadin } \ bibliography { < bibliographyfile. bib >}
\cite{key } Cite a reference \label{marker } Set a marker for cross-reference, of- ten of the form \label{sec:item} like \label{fig:diag1}. \ref{marker } Give section/body number of marker. \pageref{marker } Give page number of marker. \footnote{text} Print footnote at bottom of page. \url{url} Creates click-able web-adress. \href[options]{url}{text} click-able link \hyperref[marker ]{text} click-able ref
Mendeley: free, Win/Linux/Mac, import from several websites Citavi: free, Win
Same font, line width, vector graphic
\usepackage[options]{package} load package \newcommand[paranum]{\newcmd}{tex #1} define command \renewcommand{\cmd}{ latex #1,#2 } alter command \let\cmdcopy\cmd copy a command Read this document CTAN
Some important variables: Counters: \thepage, \thesection, \thefigure Lengths: \textwidth, \parindent, \parskip
These plain TEX commands should be used carfully Fonts \rm, \sf, \sc, \sl, \it, \tt Definitions \def\newcmd{texcode}, \let\newcmd\cmd If \ifnum\counter<10 true text \else false text \fi
LaTeX4EI www.latex4ei.de Font & Symbols https://de.wikipedia.org/wiki/Hilfe:TeX Color Schemes http://colorschemedesigner.com Tipps for Package Writers:
Homepage: www.latex4ei.de – please report misstakes immediately. by Emanuel Regnath, contact emanuel.regnath@tum.de Created 17. November 2013 at 16:54 2