Brief intro to L
ATEX
Veronika Heimsbakk
Brief intro to L
ATEX
∠ A document markup language.
∠ Released in 1984.
∠ L
ATEXan abbreviation for Lamport TEX.
‡ https://github.com/latex3/latex2e
Brief intro to L
ATEX
TEX
TEX (τχ) is an abbreviation τχνη—TEXNH—technē. Greek for art and craft, root
for technical.
∠ Released in 1978 by Donald Knuth.
∠ Typesetting system.
∠ Developed to let anyone on any machine could create books and documents of
high quality.
∠ https://www.tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web
Brief intro to L
ATEX
Installation
∠ TeXworks, Kile, Vim, Emacs etc.
∠ Package handling: MikTeX, MacTeX
∠ apt-get install texlive
∠ Browser based Overleaf1
1 https://www.overleaf.com/
Brief intro to L
ATEX
Mitt første dokument
documentclass[a4paper, 10pt]{article}
begin{document}
My first document!
end{document}
A lot of options for documentclass.
documentclass[options]{class}
∠ Options: font size, paper size, twoside/oneside, landscape etc.
∠ Class: book, article, report, minimal, beamer etc.
Brief intro to L
ATEX
Packages
For language and type faces.
usepackage[norsk]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
A lot of packages for anything! More on this later...
usepackage{hyperref}
usepackage{mathtools}
usepackage{listings}
usepackage{graphicx}
Brief intro to L
ATEX
Author and title
title{Introduction to LaTeX{}}
author{Veronika Heimsbakkveronika.heimsbakk@capgemini.com}
begin{document}
maketitle
end{document}
Brief intro to L
ATEX
Sections
section{Section}
This is section 1!
subsection{Sub section}
This is section 1's first sub section.
subsubsection{Sub sub section}
This is section 1's first sub section's sub section!
Brief intro to L
ATEX
Paragrafer
paragraph{Paragraph}
This is a paragraph.
subparagraph{Sub paragraph}
This is the paragraph's sub paragraph.
Brief intro to L
ATEX
Misc.
% This is a comment.
newline

Brief intro to L
ATEX
Fonts
textbf textit texttt underline
Bold Italic Typeface Underscore
textbf{Bold}
bfseries{Bold}
textit{Italic}
itshape{Italic}
Brief intro to L
ATEX
Fonts, packages
∠ Several packages for font styling.
∠ soul, color, . . .
st textcolor{red}{Rød tekst}
Strike through Red text
caps so
Small Capitals s p a c e y s t u f f
Brief intro to L
ATEX
Fonts, sizing
tiny Example text
scriptsize Example text
footnotesize Example text
small Example text
normalsize Example text
large Example text
Large Example text
LARGE Example text
huge Example text
Huge Example text
Brief intro to L
ATEX
Fonts, type faces
normalfont Example text
rmfamily Example text
sffamily Example text
ttfamily Example text
A lot of type faces to explore in L
ATEX. Check out http://www.tug.dk/FontCatalogue/
Brief intro to L
ATEX
Tables
begin{tabular}[h!]{|l|r|c|}
textbf{Table}  textbf{Table}  textbf{Table}
hline
one  two  three
four  five  six
seven  eight  nine
end{tabular}
Brief intro to L
ATEX
Table
Table Table Table
one two three
four five six
seven eight nine
Brief intro to L
ATEX
table
Table Table Table
one two three
four five six
seven eight nine
Table: Example of a table.
begin{table}[h!]
centering
begin{tabular}[h!]{|l|r|c|}
textbf{Table}  textbf{Table}  textbf{Table}
hline
one  two  three
four  five  six
seven  eight  nine
end{tabular}
caption{Eksempel på en tabell.}
label{tab:example}
end{table}
Brief intro to L
ATEX
References
∠ May use label for references.
∠ Example på reference to tabel 1.
∠ pageref, ref, cite
Example på reference to tabel ref{tab:example}.
Brief intro to L
ATEX
References
Need tagging of reference.
sec: section
subsec: subsection
fig: figure
tab: table
eq: equation
itm: enumerated list item
Brief intro to L
ATEX
Figure
begin{figure}[h!]
centering
includegraphics[width=textwidth]{img/latexlogo.png}
caption{LaTeX{} logo.}
end{figure}
Brief intro to L
ATEX
Figure placement
h here
t top of page
b bottom of page
! Override internal L
ATEXparameters that fixes good float for the position
H Equal to ht!
Brief intro to L
ATEX
Lists, itemize
∠ This is a list element.
∠ This is another list element.
begin{itemize}
item
This is a list element.
item
This is another list element.
end{itemize}
Brief intro to L
ATEX
Lists, enumeration
1. This is a list element.
1.1 This is another list element.
begin{enumerate}
item
This is a list element.
begin{enumerate}
item
This is another list element.
end{enumerate}
end{enumerate}
Brief intro to L
ATEX
Lists, description
* This is a list element.
Element This is another list element.
begin{description}
item[*] This is a list element.
item[Element] This is another list element.
end{description}
Brief intro to L
ATEX
Emph, footnotes and verbatim
Everything is allowed in verbatim (except from verbatim).
This is a verbatim.
This is a emph.
Example text with footnote.2
emph{ ... }
footnote{ ... }
2This is a footnote.
Brief intro to L
ATEX
Hyperlinks
Include the package hyperref.
http://tug.org/
TEX Users Group web site
veronahe@ifi.uio.no
url{http://tug.org/}
href{http://tug.org/}{TeX{} Users Group web site}
href{mailto:veronahe@ifi.uio.no}{veronahe@ifi.uio.no}
Brief intro to L
ATEX
Mathematics
Environment from TEX
$ ... $ % In-line equation
$$ ... $$ % Highlighted equation
In-line equation ∀x ∈ X, ∃y ≤ 
Highlighted equation
∀x ∈ X, ∃y ≤ 
forall x in X, quad exists y leq epsilon
Brief intro to L
ATEX
Mathematics
Environment, new in L
ATEX
( ... ) % In-line equation
[ ... ] % Highlighted equation
In-line equation ∀x ∈ X, ∃y ≤ 
Highlighted equation
∀x ∈ X, ∃y ≤ 
Alternative ways of writing equations
∠ begin{equation}
∠ begin{align}
∀x ∈ X, ∃y ≤  (1)
align will enumerate equations.
Brief intro to L
ATEX
Symbols
Symbol Command
∩ cap
∪ cup
⊆ subseteq
≡ equiv
∈ in
/
∈ notin
∧ land
∨ lor
|= models
∅ emptyset
Λ Lambda
λ lambda
∠ The Comprehensive L
ATEXSymbol List
∠ L
ATEXWiki Mathematics
Brief intro to L
ATEX
lstlistings
1 public class Code {
2 public static void main ( String [ ] args ) {
3 System . out . println (  Hello , world !  ) ;
4 }
5 }
Brief intro to L
ATEX
Innstillinger for lstlistings
lstset{
language=Java,
keywordstyle=color{blue},
stringstyle=color{red},
numbers=left,
numberstyle=tinycolor{lightgray},
tabsize=2
}
Brief intro to L
ATEX
lstlistings
begin{lstlisting}
public class Code {
public static void main(String[] args) {
System.out.println(Hello, world!);
}
}
end{lstlisting}
Load code by using lstinputlisting{source_filename.py}
Brief intro to L
ATEX
Languages supported by lstlistings
ABAP, ACSL, Ada, Algol, Ant, Assembler, Awk, bash, Basic, C#, C++, C, Caml, Clean,
Cobol, Comal, csh, Delphi, Eiffel, Elan, erlang, Euphoria, Fortran, GCL, Go (golang),
Gnuplot, Haskell, HTML, IDL, inform, Java, JVMIS, ksh, Lisp, Logo, Lua, make,
Mathematica, Matlab, Mercury, MetaPost, Miranda, Mizar, ML, Modelica, Modula-2,
MuPAD, NASTRAN, Oberon-2, Objective C , OCL, Octave, Oz, Pascal, Perl, PHP, PL/I,
Plasm, POV, Prolog, Promela, Python, R, Reduce, Rexx, RSL, Ruby, S, SAS, Scilab, sh,
SHELXL, Simula, SQL, tcl, TEX, VBScript, Verilog, VHDL, VRML, XML, XSLT
Add custom keywords with morekeywords in lstset.
Brief intro to L
ATEX
Bibliography
A simple reference system included in L
ATEX.
begin{thebibliography}
bibitem{tolkien77}
J.R.R. Tolkien,
textit{The Silmarillion},
George Allen  Unwin, United Kingdom,
1st edition,
1977.
end{thebibliography}
Use cite to reference to bibitem{tolkien77}
Brief intro to L
ATEX
TikZ
1
2
4 5
3
A
B
Brief intro to L
ATEX
TikZ
usepackage{tikz}
Brief intro to L
ATEX
Draw
begin{tikzpicture}
draw (0,0) -- (5,0);
end{tikzpicture}
Standard unit (cm)
em
pt
mm
Brief intro to L
ATEX
Shapes
usetikzlibrary{shapes}
draw (0,0) rectangle (2,2); draw (0,0) circle (1);
draw (0,0) ellipse (1 and 0,5);
Brief intro to L
ATEX
Options
draw[draw=yellow, thick, fill=orange] (0,0) rectangle (2,2);
draw[draw=none, fill=teal] (0,0) circle (1);
draw[draw=red, ultra thick, dashed] (0,0) ellipse (1 and 0.5);
Brief intro to L
ATEX
Tree
1
2 3
4 5
node {1}
child {node {2}}
child {node {3}
child {node {4}}
child {node {5}}
}
;
Brief intro to L
ATEX
Style for all nodes
1
2 3
4 5
Brief intro to L
ATEX
Style for all nodes
begin{tikzpicture}[every node/.style={circle, draw=black}]
node {1}
child {node {2}}
child {node {3}
child {node {4}}
child {node {5}}
}
;
end{tikzpicture}
Brief intro to L
ATEX
Intelligence: Finding an error in a Knuth text.
Stupidity: Cashing that $2.56 check you got.
Brief intro to L
ATEX
Useful resources
∠ TEX Users Group
∠ TEXample
∠ TikZ  PGF Manual
∠ L
ATEXWiki
Brief intro to L
ATEX

Basic Introduction to LaTeX

  • 1.
    Brief intro toL ATEX Veronika Heimsbakk Brief intro to L ATEX
  • 2.
    ∠ A documentmarkup language. ∠ Released in 1984. ∠ L ATEXan abbreviation for Lamport TEX. ‡ https://github.com/latex3/latex2e Brief intro to L ATEX
  • 3.
    TEX TEX (τχ) isan abbreviation τχνη—TEXNH—technē. Greek for art and craft, root for technical. ∠ Released in 1978 by Donald Knuth. ∠ Typesetting system. ∠ Developed to let anyone on any machine could create books and documents of high quality. ∠ https://www.tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web Brief intro to L ATEX
  • 4.
    Installation ∠ TeXworks, Kile,Vim, Emacs etc. ∠ Package handling: MikTeX, MacTeX ∠ apt-get install texlive ∠ Browser based Overleaf1 1 https://www.overleaf.com/ Brief intro to L ATEX
  • 5.
    Mitt første dokument documentclass[a4paper,10pt]{article} begin{document} My first document! end{document} A lot of options for documentclass. documentclass[options]{class} ∠ Options: font size, paper size, twoside/oneside, landscape etc. ∠ Class: book, article, report, minimal, beamer etc. Brief intro to L ATEX
  • 6.
    Packages For language andtype faces. usepackage[norsk]{babel} usepackage[utf8]{inputenc} usepackage[T1]{fontenc} A lot of packages for anything! More on this later... usepackage{hyperref} usepackage{mathtools} usepackage{listings} usepackage{graphicx} Brief intro to L ATEX
  • 7.
    Author and title title{Introductionto LaTeX{}} author{Veronika Heimsbakkveronika.heimsbakk@capgemini.com} begin{document} maketitle end{document} Brief intro to L ATEX
  • 8.
    Sections section{Section} This is section1! subsection{Sub section} This is section 1's first sub section. subsubsection{Sub sub section} This is section 1's first sub section's sub section! Brief intro to L ATEX
  • 9.
    Paragrafer paragraph{Paragraph} This is aparagraph. subparagraph{Sub paragraph} This is the paragraph's sub paragraph. Brief intro to L ATEX
  • 10.
    Misc. % This isa comment. newline Brief intro to L ATEX
  • 11.
    Fonts textbf textit textttunderline Bold Italic Typeface Underscore textbf{Bold} bfseries{Bold} textit{Italic} itshape{Italic} Brief intro to L ATEX
  • 12.
    Fonts, packages ∠ Severalpackages for font styling. ∠ soul, color, . . . st textcolor{red}{Rød tekst} Strike through Red text caps so Small Capitals s p a c e y s t u f f Brief intro to L ATEX
  • 13.
    Fonts, sizing tiny Exampletext scriptsize Example text footnotesize Example text small Example text normalsize Example text large Example text Large Example text LARGE Example text huge Example text Huge Example text Brief intro to L ATEX
  • 14.
    Fonts, type faces normalfontExample text rmfamily Example text sffamily Example text ttfamily Example text A lot of type faces to explore in L ATEX. Check out http://www.tug.dk/FontCatalogue/ Brief intro to L ATEX
  • 15.
    Tables begin{tabular}[h!]{|l|r|c|} textbf{Table} textbf{Table} textbf{Table} hline one two three four five six seven eight nine end{tabular} Brief intro to L ATEX
  • 16.
    Table Table Table Table onetwo three four five six seven eight nine Brief intro to L ATEX
  • 17.
    table Table Table Table onetwo three four five six seven eight nine Table: Example of a table. begin{table}[h!] centering begin{tabular}[h!]{|l|r|c|} textbf{Table} textbf{Table} textbf{Table} hline one two three four five six seven eight nine end{tabular} caption{Eksempel på en tabell.} label{tab:example} end{table} Brief intro to L ATEX
  • 18.
    References ∠ May uselabel for references. ∠ Example på reference to tabel 1. ∠ pageref, ref, cite Example på reference to tabel ref{tab:example}. Brief intro to L ATEX
  • 19.
    References Need tagging ofreference. sec: section subsec: subsection fig: figure tab: table eq: equation itm: enumerated list item Brief intro to L ATEX
  • 20.
  • 21.
    Figure placement h here ttop of page b bottom of page ! Override internal L ATEXparameters that fixes good float for the position H Equal to ht! Brief intro to L ATEX
  • 22.
    Lists, itemize ∠ Thisis a list element. ∠ This is another list element. begin{itemize} item This is a list element. item This is another list element. end{itemize} Brief intro to L ATEX
  • 23.
    Lists, enumeration 1. Thisis a list element. 1.1 This is another list element. begin{enumerate} item This is a list element. begin{enumerate} item This is another list element. end{enumerate} end{enumerate} Brief intro to L ATEX
  • 24.
    Lists, description * Thisis a list element. Element This is another list element. begin{description} item[*] This is a list element. item[Element] This is another list element. end{description} Brief intro to L ATEX
  • 25.
    Emph, footnotes andverbatim Everything is allowed in verbatim (except from verbatim). This is a verbatim. This is a emph. Example text with footnote.2 emph{ ... } footnote{ ... } 2This is a footnote. Brief intro to L ATEX
  • 26.
    Hyperlinks Include the packagehyperref. http://tug.org/ TEX Users Group web site veronahe@ifi.uio.no url{http://tug.org/} href{http://tug.org/}{TeX{} Users Group web site} href{mailto:veronahe@ifi.uio.no}{veronahe@ifi.uio.no} Brief intro to L ATEX
  • 27.
    Mathematics Environment from TEX $... $ % In-line equation $$ ... $$ % Highlighted equation In-line equation ∀x ∈ X, ∃y ≤ Highlighted equation ∀x ∈ X, ∃y ≤ forall x in X, quad exists y leq epsilon Brief intro to L ATEX
  • 28.
    Mathematics Environment, new inL ATEX ( ... ) % In-line equation [ ... ] % Highlighted equation In-line equation ∀x ∈ X, ∃y ≤ Highlighted equation ∀x ∈ X, ∃y ≤ Alternative ways of writing equations ∠ begin{equation} ∠ begin{align} ∀x ∈ X, ∃y ≤ (1) align will enumerate equations. Brief intro to L ATEX
  • 29.
    Symbols Symbol Command ∩ cap ∪cup ⊆ subseteq ≡ equiv ∈ in / ∈ notin ∧ land ∨ lor |= models ∅ emptyset Λ Lambda λ lambda ∠ The Comprehensive L ATEXSymbol List ∠ L ATEXWiki Mathematics Brief intro to L ATEX
  • 30.
    lstlistings 1 public classCode { 2 public static void main ( String [ ] args ) { 3 System . out . println ( Hello , world ! ) ; 4 } 5 } Brief intro to L ATEX
  • 31.
  • 32.
    lstlistings begin{lstlisting} public class Code{ public static void main(String[] args) { System.out.println(Hello, world!); } } end{lstlisting} Load code by using lstinputlisting{source_filename.py} Brief intro to L ATEX
  • 33.
    Languages supported bylstlistings ABAP, ACSL, Ada, Algol, Ant, Assembler, Awk, bash, Basic, C#, C++, C, Caml, Clean, Cobol, Comal, csh, Delphi, Eiffel, Elan, erlang, Euphoria, Fortran, GCL, Go (golang), Gnuplot, Haskell, HTML, IDL, inform, Java, JVMIS, ksh, Lisp, Logo, Lua, make, Mathematica, Matlab, Mercury, MetaPost, Miranda, Mizar, ML, Modelica, Modula-2, MuPAD, NASTRAN, Oberon-2, Objective C , OCL, Octave, Oz, Pascal, Perl, PHP, PL/I, Plasm, POV, Prolog, Promela, Python, R, Reduce, Rexx, RSL, Ruby, S, SAS, Scilab, sh, SHELXL, Simula, SQL, tcl, TEX, VBScript, Verilog, VHDL, VRML, XML, XSLT Add custom keywords with morekeywords in lstset. Brief intro to L ATEX
  • 34.
    Bibliography A simple referencesystem included in L ATEX. begin{thebibliography} bibitem{tolkien77} J.R.R. Tolkien, textit{The Silmarillion}, George Allen Unwin, United Kingdom, 1st edition, 1977. end{thebibliography} Use cite to reference to bibitem{tolkien77} Brief intro to L ATEX
  • 35.
  • 36.
  • 37.
    Draw begin{tikzpicture} draw (0,0) --(5,0); end{tikzpicture} Standard unit (cm) em pt mm Brief intro to L ATEX
  • 38.
    Shapes usetikzlibrary{shapes} draw (0,0) rectangle(2,2); draw (0,0) circle (1); draw (0,0) ellipse (1 and 0,5); Brief intro to L ATEX
  • 39.
    Options draw[draw=yellow, thick, fill=orange](0,0) rectangle (2,2); draw[draw=none, fill=teal] (0,0) circle (1); draw[draw=red, ultra thick, dashed] (0,0) ellipse (1 and 0.5); Brief intro to L ATEX
  • 40.
    Tree 1 2 3 4 5 node{1} child {node {2}} child {node {3} child {node {4}} child {node {5}} } ; Brief intro to L ATEX
  • 41.
    Style for allnodes 1 2 3 4 5 Brief intro to L ATEX
  • 42.
    Style for allnodes begin{tikzpicture}[every node/.style={circle, draw=black}] node {1} child {node {2}} child {node {3} child {node {4}} child {node {5}} } ; end{tikzpicture} Brief intro to L ATEX
  • 43.
    Intelligence: Finding anerror in a Knuth text. Stupidity: Cashing that $2.56 check you got. Brief intro to L ATEX
  • 44.
    Useful resources ∠ TEXUsers Group ∠ TEXample ∠ TikZ PGF Manual ∠ L ATEXWiki Brief intro to L ATEX