LaTeX overview
Reminder: you can left-scroll and right-scroll the long math or code blocks
Introduction
LaTeX is a language and document composition system created by Leslie Lamport in 1983. It is a collection of macro commands designed to make TeX (Donald Knuth’s text processor), easier to use.
LaTeX commands have become the de facto standard for writing mathematics. It is also widely used in academia for writing scientific papers.
Find more on Wikipedia.
The following is an overview of the language for most usages. Please let me know in the comments if I missed important features 😉
LaTeX editors
- emacs + aucTex
- TexMaker, TexShop, etc.
Compilation
On the command line:
- compilation:
$ latex file.tex
.dvix file - display the .dvi file:
% xdvi file.dvi
- Format conversion:
- postcript:
$ dvips file.dvi -o file.ps
- pdf:
$ ps2pdf file.ps file.pdf
- html:
$ latex2html file.tex
- postcript:
General form
LaTeX Commands: \command{parameter}[option]
1 | \documentclass[a4paper 12pt]{article} |
common classes
- book
- article
- report
- letter
- slides
Letter and slides differ significantly from book, article and report.
Formatting
Formatting list of authors
Example:
1 | \documentclass[11pt, English]{article} |
Bold, italic, underline, color, alignment…
Effect | Command | Meaning | Other / Macro |
---|---|---|---|
Bold | \textbf{…} | text big font | {\bf …} |
Italic | \textit{…} | text italic | {\it …} |
Underline | \underline{…} | underline | |
Color | Preamble: \usepackage{xcolor} Body of doc: \textcolor{color}{…} background color: \colorbox{color}{…} |
{\color{color} …} | |
Framed box | \fbox{…} | framed box | |
Alignment | |||
WithdrawalQuote | \begin{quotation} … \end{quotation} \begin{quote} … \end{quote} |
quote | |
Text Rotation | \rotatebox{_angle _}{…} |
Formatting commands
\\
: new line (in text mode)\-
: hyphenation (unknown words fromin the LaTeX dictionary., e.g.rou\-tin\-quo\-facte\-pique.
Colors: xcolor module
- Defining a color object: one of the commands
1 | \definecolor{macolor}{rgb}{0.20,0.43,0.09} % average gremen |
- Playing on the tones:
1 | \textcolor{color1!<percentage_of_color>!color2} |
color2 = white by default.
Example:
1 | \textcolor{green!60!yellow}{example} |
Special character
Character | Escaping | LaTeX usage |
---|---|---|
\ |
\verb<delimiter>\<delimiter> |
Introduces a LaTeX command |
~ |
\verb<delimiter>\<delimiter> |
Non-breaking space |
{ and } |
\{ and \} |
Block delimiters |
% |
\% |
Commentary |
$ |
\$ |
Math mode |
& |
\& |
Table column delimiter |
# |
\# |
Macro definition |
^ |
\verb<delimiter>^<delimiter> |
Exhibitor |
_ |
\_ |
Index |
< and > |
\textless and \textgreater |
? |
<delimiteur> is any character exception space.
verbatim mode
Text displayed without formatting by LaTeX, with font typewriter (\tt
).
Code display LaTeX for example.
- online mode:
\verb<delimiter><literal text><delimiter>
or\verb*<delimiter><literal text><delimiter>
.
<delimiter>
is any character except space.
\verb*
displays spaces in visual mode. - block mode (display): verbatim environment:
\begin{verbatim} ...\end{verbatim}
Note:
\verb
can not be passed as an argument to a command parameter. Unusable with\textit{}
or\textbf{}
for example.- Macros such as
\it
or\bf
can be used to format\verb
to certain extend. Example:{\it \verb-\section{<example>}-}
Tabular structures
Lists
- Flat lists: environment itemize
1 | \begin{itemize} |
- Ordered lists: environment enumerate
- It is necessary to declare:
\usepackage{enumerate}
- Number styles:
i, I, i) a, A, 1,1)
- It is necessary to declare:
1 | \usepackage{enumerate} |
- Description lists: environment description (neither bullets nor numbers)
1 | \begin{description} |
Tables
To merge cells, package multirow
:
1 | \usepackage{multirow} |
header1 | header2 | header3 | normal line |
---|---|---|---|
A | B | horizontal merge (columns) | |
x | y | z | vertical merge (rows) |
1 | 7 | integrated line | |
5 | 6 | negative vertical merge (upward) |
Explanations:
\begin{tabular}[c]
: arguments l, c, r (alignment in a line: left, center, right). Parameter: lcr as many alignment letters as columns - vertical separator line of columns.\multicolumn{2}{|c|}{B}
: multicolumn parameters: number of columns, alignment, texthline
: horizontal linecline
: column line (<begin> - <end>)\multirow{-2}*{7}
: we can integrate a line above or below.*
takes all the options of the table.
Floating objects, inserting objects
Figures
1 | \begin{figure}[!h] |
- Anchors can be:
h
,t
,b
,p
(here, top, bottom, page). !
allows you to force the position (when possible).
Floating tables
1 | \begin{table}[anchor] |
- Anchors can be:
h
,t
,b
,p
(here, top, bottom, page). !
allows you to force the position (when possible).
Inserting images
1 | \usepackage{graphicx} |
References
Internal references
Table Of Contents - TOC
Command
1 | \tableofcontent |
Double compilation:
- first compilation: knowledge of the structure (sections, subsections, etc.)
- second compilation: TOC generation
Others commands
1 | 1. \renewcommand{\tableofcontents}{Sommaire} |
Explanations:
- change the display (argument 2) of the command (argument 1)
- changes the depth of the CT. toc: table of contents
- adding additional content to the TDM. arg1: toc = table of contents, arg2: will appear as a section, arg3: text to display
Table Of Tables - TOT
Command
1 | \listoftables |
Do not forget the \caption[]{}
in the environments table
.
Table Of Figures - TOF
Command
1 | \listoffigures |
Do not forget the \caption[]{}
in the environments figure
.
Footnotes
Command
1 | \footnote{<text, in general a precision for some readers>} |
Internal jumps
Two commands: anchor and call. Two compilations.
\label{<unique key>}
just above where you want to reference (typically\section{}
)\ref{<unique key>}
at the location where the reference is made to another part of the article.
Bibliographical references
Creating a bibliography file, .bib extension
Model:
1 | @Inproceedings{<unique indexing key>, |
Tip: To know the fields creation of a .bib file in auctex or bibTex, Menu “entry-types”
Commands:
Inserting a quote:
1 | \cite{<indexing key>} |
Generation of the list:
1 | \bibliographystyle{<biblio. style ex: alpha>} |
Requires 4 compilations:
- link creation with a bibliography file (external): Latex compiler
- preparation of the .bib file: bibTex compiler
- knowledge of the structure: Latex compiler
- file generation: Latex compiler
Some bibliography classes
Article:
1 | @Manual{art:CECS, |
Book:
1 | @Book{book:latex, |
Web site:
1 | @Misc{web:mcclinews, |
Hyperlinks
href link
hyperlink and hypertarget anchors
module hyperref
1 | \hyperlink{<target>}{<clickable text>} |
Appendices: appendix
Command:
1 | \appendix |
Tells LaTeX that we are starting the appendices.
The symbolic mode (math)
The math
environments
Inline mode | Display mode |
---|---|
$...$ |
$$...$$ |
\begin{math}...\end{math} |
\[...\] |
\begin{displaymath}...\end{displaymath} |
|
\begin{equation}...\end{equation} |
The math environments
NB:
\equation
numbers the different entries.- In inline mode,
\displaystyle
allows to display the formula as in display mode (no contraction of the formula).
Symbols
Operators
Analytical operators:
\times |
\% |
\div |
\cdot |
||||
\neq |
\leq |
\geq |
\gg |
||||
\ll |
\approx |
\pm |
\sim |
||||
\simeq |
\wedge |
\vee |
\neg |
||||
(amsmath) | \implies |
\iff |
\in |
\notin |
|||
\exists |
\nexists |
\forall |
\bullet |
||||
\sum |
\prod |
\int |
\lim |
Analytical operators
Sets
Notaions and operators on sets:
\varnothing |
\emptyset |
\infty |
\complement |
||||
\in |
\notin |
\setminus |
\oplus |
||||
\ominus |
\otimes |
\bullet |
\cup |
||||
\bigcup |
\cap |
\bigcap |
\subset |
||||
\supset |
\subseteq |
\supseteq |
\mathcal{P}(E) |
||||
, | \mathbb{N} |
\bowtie |
Sets
Notes:
- The
\mathbb{N}
command requires the ams font module:\usepackage{amsfont}
- The
\mathcal{P}(E)
command requires the euler calligraphics module:\usepackage{eucal}
Diacritic signs (accents, parentheses)
\acute{x} |
\grave{x} |
\bar{x} |
\vec{x} |
||||
\overrightarrow{xyz} |
\widehat{xyz} |
\overbrace{x+...+x} |
\underbrace{1,...,n} |
||||
f^\prime |
\left\{x \atop y\right\} |
\left\{x \atop y\right. |
\underset{k \in \{1,\ \dots ,\ K\}}{\operatorname{argmax}} |
||||
\Vert\overrightarrow{X}\Vert |
\vert x \vert |
Accents, parentheses
Functions
Notation, symbols and operators on the functions:
\frac{x}{y} |
\sqrt{x(x+1)} |
\to |
\mapsto |
||||
\nearrow |
\searrow |
\nwarrow |
\swarrow |
||||
\cos(x+y) |
\sin(2\alpha) |
\log(n) |
\ln(2x) |
Functions
Notes:
\nearrow
: north east arrow\searrow
: south east arrow\nwarrow
: north west arrow\swarrow
: south west arrow
Arrows
Arrows:
\rightarrow |
\Rightarrow |
\Leftarrow |
\leftrightarrow |
||||
\Leftrightarrow |
\uparrow |
\downarrow |
\updownarrow |
||||
\Uparrow |
\Downarrow |
\Updownarrow |
Arrows
Formatting
Spacing, raw text, framing
Elementary formatting:
Spacing | \! , \: , \; , \(space) , \quad , \qqaud |
raw text | \text{...} \mbox{...} |
framing | \boxed{..} (inline) \fbox{...} |
Spacing, raw text, framing
NB:
- with
\mbox
, you sometimes have to encapsulate the equation in$$
. \text
vs.\mbox
:\text{...}
used in a product index of the text in subscript size (unlike mbox)
The array
environment
example 1
1 | \[ |
Result:
example 2
1 | \[ |
Result:
The align
environment
Note: It is not recommended to use the environment eqnarray
example:
1 | \begin{align*} |
Note: The star is used to not display equation numbers.
The theorem
environment
In preamble, declare an order:
1 | \newtheorem{theorem}{Théorème} |
- First parameter: word that will be used for the command.
- Second parameter: title to display when creating each environment (before the number)
In the body of the document:
1 | \begin{theorem} |
Slides with the beamer
class
Beamer is based on a page environment (frame) that represents a “transparent”, which can be displayed in several stages by a succession of layers (slides).
Note: Beamer names frame what other modules name slide and slide what others call overlay.
Special features of slide documents
- 2 hierarchical structures
- of the whole document (summary
- by slide (title + subtitles)
- Each slide is understood as a paragraph (
\section
) - The default font is sans serif (unlike the article class)
xcolor
package is built into Beamer by default
Overview
General form
1 | \documentclass[t,12pt]{beamer} |
Remarks:
\begin{frame}[label=pagesimple]
, the optionlabel=\<key>
has the same role as\label{<unique key>}
Beamer class options:
[10pt]
: font size: 10pt (or smaller), 11pt (default), 12pt (or bigger)
8pt, 9pt, 14pt, 17pt or 20pt with the extsize package.[t]
: vertical alignment, default centered.[t]
=top,[b]
=(bottom),[c]
(center, by default).
Can intervene on a single page in the\begin{frame}[t]
[color=list of options]
: switch options to color (because automatically loaded by Beamer).[xcolor\itempst]
: pass options to xcolor (loaded automatically by Beamer),
If we use\textcolor{orange}{PStricks}
, we need to use[xcolor=pst]
or[xcolor\itempst]
depending on the version of xcolor or nothing at all with the latest version of PStricks. In case of problems, test the different solutions![hyperref=list of options]
: pass options to hyperref (automatically loaded by Beamer).
Same command\hypersetup
[usepdftitle=false]
: deletes the title and author information from the pdf file: by default, the commands\title
et\author
inserts their content into the information area of the resulting pdf file. If these commands include frills (boxes or arguments), this will create problems, it is better to delete the insertion of their content in the file information.[compress]
: headers that take up less space.[draft]
: faster compilation in draft mode (headers, footers and side panel are represented by a simple gray rectangle).[trans]
: Removing all overlay effects or text overlay (to create transparencies quickly)
Attention, does not seem to like the overprint environment.
-[handout]
: create a copyable version quickly. Same note for the overprint environment.
-[ucs]
: to use Unicode.
Loads the ucs package and passes the correct Unicode options to hyperref.
-[utf8]
: same as[ucs]
and also allows to encode his text in utf8 in an equivalent way to\usepackage[utf8]{inputenc}
-[envcountsect]
: numbering the theorems with respect to each section.
-[notheorems]
: no longer uses the predefined environment blocks.
-[noamsthm]
: no longer load amsthm and amsmath packages.
TOC: tableofcontents
When you have too many sections, think about doing the summary in two columns.
Options:
\tableofcontents[currentsection]
Current section in values, the others grise light.\tableofcontents[currentsubsection]
Current sub-section highlighted, the others grayed.\tableofcontents[firstsection=xx]
Starting section of the numbering (previous negative section).\tableofcontents[hideallsubsections]
no longer displays subsections.\tableofcontents[hideothersubsections]
displays subsections only for the current section.\tableofcontents[part=xx]
summary of part number xx (instead of the current part).\tableofcontents[pausesections]
causes a\pause
command before displaying each section. Allows you to present each section one by one.\tableofcontents[pausesubsections]
causes a\pause
command before displaying each subsection, but not before sections.\tableofcontents[sections=xx]
summary of section number xx (title section and subsections).\tableofcontents[sections={xx-yy}]
only displays the summary of section xx to yy.\tableofcontents[sections={xx,yy}]
only displays the summary of section xx and yy.- Some of the commands above are shortcuts of:
\tableofcontents[sectionstyle=<visibility of current sec.>/<vis. others sec.>]
\tableofcontents[subsectionstyle=<vis. current subsection>/vis. others ss/vis. non-current ss]
- example:
1 | \begin{frame}{Plan : \thesection{} - \secname} |
Text enhancement
\structure{<text in relief>}
\alert{<highlighted elt>}
Customizing the predefined theme (overload)
- Setting a beamerFont object.
example:
1 | \setbeamercolor{myAlert}{fg=blue} |
- Ordered lists:
enumerate
1 | \setbeamertemplate{enumerate item}[<style>] |
Delayed display
Local modification of an element of the list: to dynamize the presentation (appearance / disappearance of elements of the list, colorization, etc.)
example:
1 | \begin{itemize} |
to put the navigation icons in vertival position.
Hypertext links can be buttons.
example:
1 | \hyperlink{<target>}{\beamerbutton{<Button text>}} |
Appendix
Concept of document
A document is ny source of information and knowledge directly available to humans.
Characteristics of a document
- Logical structure / physical structure physical
- Logical structure:
- Hierarchical: titles of levels, paragraph (in the logical sense = grouping of ideas).
- Extraction of all or part of the logical structure (content + position): summary, notices, etc.
- A too hierarchical summary is not legible: simplify the hierarchical structure (2 levels of titles).
- Tabular: series of information of the same type and whose number is fixed.
- Lites: flat (dashes, bullets) or sequential (numbered)
- Figures
- By references: structure allowing non-sequential reading. Pointer.
- Internal references
- Bibliographical references
- Hypermedia
- Hierarchical: titles of levels, paragraph (in the logical sense = grouping of ideas).
- Physical structure: projection of the logical structure on a support (obtaining a visual)
- Logical structure:
- Document support (paper / electronic [all symbols are numerically encoded])
- Content type:
- Form (text, static / dynamic image, sound, video, etc.)
- State (static / dynamic)
- Life cycle (end of cycle [trash], new version [correction, renewal], design, development, update ?, publication, distribution, archiving, etc.)
Some issues in creating documents
- Creation: editor alone, several, synchronously / asynchronously, remotely, etc. (annotations, modification follow-up, writing with several hands …)
- Publication: editorial team, moderator, validation, constraints (style sheets, editorial line)
- Usage for scientific publications:
- Form: text, formula, images, graphs, schemas
- State: static .
Written on Sun Nov 4th 2018, 10:39 GMT+00:00.
Last updated on Sun Nov 4th 2018, 6:19 GMT+00:00.