3rd presentation of the bib latex course
TRANSCRIPT
Introduction to LATEXSession #3
Oriol Borrega Pedro Tiago Martins
Universitat de Barcelona
February 4, 2013
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 1 / 29
Outline
1 A bit more on. . .. . . tables. . .. . . and sections.
2 ReferencesCross-referencesBibliography
3 Basic maths
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 2 / 29
A bit more on. . .
Outline
1 A bit more on. . .. . . tables. . .. . . and sections.
2 ReferencesCross-referencesBibliography
3 Basic maths
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 3 / 29
A bit more on. . . . . . tables. . .
What if I wanted to. . .
Col A Col B Col C Col D Col E
Row 1 A1 B1 C1 D1 E1
Row 2 A2-B2 C2 D2 E2
Row 3 A3-C3 D3 E3
Row 4 A4-D4 E4
Row 5 A5-E5
Table: A table with rows spanning over several columns
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 4 / 29
A bit more on. . . . . . tables. . .
Easy peasy!
First, call the package in the preamble:
\usepackage{multicol}
Then, in the corresponding cell, specify the columns the cell mustspan over, its text alignment and vertical lines, and its content:
\multicolumn{3}{|c|}{Content of the cell}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 5 / 29
A bit more on. . . . . . tables. . .
Easy peasy!
First, call the package in the preamble:
\usepackage{multicol}
Then, in the corresponding cell, specify the columns the cell mustspan over, its text alignment and vertical lines, and its content:
\multicolumn{3}{|c|}{Content of the cell}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 5 / 29
A bit more on. . . . . . tables. . .
Ready!
First column Second column
First row MULTICOLUMN
Second row single column single column
\begin{table}[h]
\begin{tabular}{|l|l|l|}
\cline{2-3}
\multicolumn{1}{c|}{} & First column & Second column \\ \hline
First row & \multicolumn{2}{|c|}{MULTICOLUMN} \\ \hline
Second row & single column & single column \\ \hline
\end{tabular}
\end{table}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 6 / 29
A bit more on. . . . . . tables. . .
Ready!
First column Second column
First row MULTICOLUMN
Second row single column single column
\begin{table}[h]
\begin{tabular}{|l|l|l|}
\cline{2-3}
\multicolumn{1}{c|}{} & First column & Second column \\ \hline
First row & \multicolumn{2}{|c|}{MULTICOLUMN} \\ \hline
Second row & single column & single column \\ \hline
\end{tabular}
\end{table}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 6 / 29
A bit more on. . . . . . tables. . .
Set!
Text alignment within cells (and number of columns):\begin{tabular}{clr}Vertical lines: \begin{tabular}{|c|l|r|}Horizontal lines: \hline
Cells that span over several columns: \multicolumn{}{}{}Cells that span over several rows: \cline{}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 7 / 29
A bit more on. . . . . . tables. . .
Set!
Text alignment within cells (and number of columns):\begin{tabular}{clr}Vertical lines: \begin{tabular}{|c|l|r|}Horizontal lines: \hline
Cells that span over several columns: \multicolumn{}{}{}Cells that span over several rows: \cline{}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 7 / 29
A bit more on. . . . . . tables. . .
Set!
Text alignment within cells (and number of columns):\begin{tabular}{clr}Vertical lines: \begin{tabular}{|c|l|r|}Horizontal lines: \hline
Cells that span over several columns: \multicolumn{}{}{}Cells that span over several rows: \cline{}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 7 / 29
A bit more on. . . . . . tables. . .
Set!
Text alignment within cells (and number of columns):\begin{tabular}{clr}Vertical lines: \begin{tabular}{|c|l|r|}Horizontal lines: \hline
Cells that span over several columns: \multicolumn{}{}{}Cells that span over several rows: \cline{}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 7 / 29
A bit more on. . . . . . tables. . .
Set!
Text alignment within cells (and number of columns):\begin{tabular}{clr}Vertical lines: \begin{tabular}{|c|l|r|}Horizontal lines: \hline
Cells that span over several columns: \multicolumn{}{}{}Cells that span over several rows: \cline{}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 7 / 29
A bit more on. . . . . . tables. . .
Go!
Column 1 Column 2 Column 3 Column 4
Row A AboveRow B Below AboveRow C Below AboveRow D Below AboveRow E Below
Table: Today’s first exercise.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 8 / 29
A bit more on. . . . . . tables. . .
The solution
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5}
\multicolumn{1}{c|}{} & Column 1 & Column 2 & Column 3 & Column 4 \\ \hline
Row A & \multicolumn{4}{|l|}{Above} \\
\cline{1-2}
Row B & \multicolumn{1}{|r}{Below} & \multicolumn{3}{|l|}{Above} \\
\cline{1-1} \cline{3-3}
Row C & \multicolumn{2}{|r|}{Below}& \multicolumn{2}{|l|}{Above} \\
\cline{1-1} \cline{4-4}
Row D & \multicolumn{3}{|r|}{Below}& \multicolumn{1}{l|}{Above} \\
\cline{1-1} \cline{5-5}
Row E & \multicolumn{4}{|r|}{Below} \\ \hline
\end{tabular}
\caption{Today’s first exercise.}
\end{table}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 9 / 29
A bit more on. . . . . . and sections.
Section: others
If we want sections to appear with a different name in the table ofcontents:
\section[Title for the ToC]{Real title of the section}
If we want sections not to appear in the table of contents:
\section*{Title of the section}
To include appendices (sections numbered in letters):
\appendix AT THE BEGINNING OF THEM ALL
To make an abstract:
\begin{abstract}
...
\end{abstract}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 10 / 29
A bit more on. . . . . . and sections.
Section: others
If we want sections to appear with a different name in the table ofcontents:
\section[Title for the ToC]{Real title of the section}
If we want sections not to appear in the table of contents:
\section*{Title of the section}
To include appendices (sections numbered in letters):
\appendix AT THE BEGINNING OF THEM ALL
To make an abstract:
\begin{abstract}
...
\end{abstract}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 10 / 29
A bit more on. . . . . . and sections.
Section: others
If we want sections to appear with a different name in the table ofcontents:
\section[Title for the ToC]{Real title of the section}
If we want sections not to appear in the table of contents:
\section*{Title of the section}
To include appendices (sections numbered in letters):
\appendix AT THE BEGINNING OF THEM ALL
To make an abstract:
\begin{abstract}
...
\end{abstract}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 10 / 29
A bit more on. . . . . . and sections.
Section: others
If we want sections to appear with a different name in the table ofcontents:
\section[Title for the ToC]{Real title of the section}
If we want sections not to appear in the table of contents:
\section*{Title of the section}
To include appendices (sections numbered in letters):
\appendix AT THE BEGINNING OF THEM ALL
To make an abstract:
\begin{abstract}
...
\end{abstract}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 10 / 29
A bit more on. . . . . . and sections.
Section: others
To limit the depth of the table of contents:
\setcounter{tocdepth}{2} IN THE PREAMBLE
All possible levels and their depth:
-1 \part{title} NOT FOR ARTICLE
0 \chapter{title} NOT FOR ARTICLE
1 \section{title}
2 \subsection{title}
3 \subsubsection{title}
4 \paragraph{title}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 11 / 29
A bit more on. . . . . . and sections.
Section: others
To limit the depth of the table of contents:
\setcounter{tocdepth}{2} IN THE PREAMBLE
All possible levels and their depth:
-1 \part{title} NOT FOR ARTICLE
0 \chapter{title} NOT FOR ARTICLE
1 \section{title}
2 \subsection{title}
3 \subsubsection{title}
4 \paragraph{title}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 11 / 29
A bit more on. . . . . . and sections.
Yet another ‘copy what you see’ exercise. . .https://dl.dropbox.com/u/4636832/exercise2.rar
Download the file above. . .. . . and try to reproduce the file TocToc.pdf
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 12 / 29
References
Outline
1 A bit more on. . .. . . tables. . .. . . and sections.
2 ReferencesCross-referencesBibliography
3 Basic maths
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 13 / 29
References Cross-references
Label and refer
To refer to an element, first we must label it:
\label{sec:biology}
Once labeled, it can be refered to anywhere in the text:
\ref{sec:biology}
Or you can refer to the page the element is in:
\pageref{sec:biology}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 14 / 29
References Cross-references
Label and refer
To refer to an element, first we must label it:
\label{sec:biology}
Once labeled, it can be refered to anywhere in the text:
\ref{sec:biology}
Or you can refer to the page the element is in:
\pageref{sec:biology}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 14 / 29
References Cross-references
Label and refer
To refer to an element, first we must label it:
\label{sec:biology}
Once labeled, it can be refered to anywhere in the text:
\ref{sec:biology}
Or you can refer to the page the element is in:
\pageref{sec:biology}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 14 / 29
References Cross-references
What and how to label
You can label/reference almost anything: figures, tables, sections,items, equations,. . .
Where do I put the label?
sections Anywhere within the section (it is recommended toplace the label just after the \section{} command).
figures Just after the \caption{} (or within it).tables Just after the \caption{} (or within it).items Either after the \item label or after the item’s text. By
default, this only works in enumerations.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 15 / 29
References Cross-references
What and how to label
You can label/reference almost anything: figures, tables, sections,items, equations,. . .
Where do I put the label?
sections Anywhere within the section (it is recommended toplace the label just after the \section{} command).
figures Just after the \caption{} (or within it).tables Just after the \caption{} (or within it).items Either after the \item label or after the item’s text. By
default, this only works in enumerations.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 15 / 29
References Cross-references
What and how to label
You can label/reference almost anything: figures, tables, sections,items, equations,. . .
Where do I put the label?
sections Anywhere within the section (it is recommended toplace the label just after the \section{} command).
figures Just after the \caption{} (or within it).tables Just after the \caption{} (or within it).items Either after the \item label or after the item’s text. By
default, this only works in enumerations.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 15 / 29
References Cross-references
What and how to label
You can label/reference almost anything: figures, tables, sections,items, equations,. . .
Where do I put the label?
sections Anywhere within the section (it is recommended toplace the label just after the \section{} command).
figures Just after the \caption{} (or within it).tables Just after the \caption{} (or within it).items Either after the \item label or after the item’s text. By
default, this only works in enumerations.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 15 / 29
References Cross-references
What and how to label
You can label/reference almost anything: figures, tables, sections,items, equations,. . .
Where do I put the label?
sections Anywhere within the section (it is recommended toplace the label just after the \section{} command).
figures Just after the \caption{} (or within it).tables Just after the \caption{} (or within it).items Either after the \item label or after the item’s text. By
default, this only works in enumerations.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 15 / 29
References Cross-references
What and how to label
You can label/reference almost anything: figures, tables, sections,items, equations,. . .
Where do I put the label?
sections Anywhere within the section (it is recommended toplace the label just after the \section{} command).
figures Just after the \caption{} (or within it).tables Just after the \caption{} (or within it).items Either after the \item label or after the item’s text. By
default, this only works in enumerations.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 15 / 29
References Cross-references
What and how to label
As labels grow in number, they might get messy.
Advice: use semantically meaningful labels.
chap:name chapter
sec:name section
fig:name figure
tab:name table
itm:keyword item
Table: The usual method of labelling in LATEX
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 16 / 29
References Cross-references
Let’s try all this on the file exercise2.tex
First:1 Create an abstract at the beginning.2 Change the title of section 4 in the ToC to Interbreeding.3 Make section 5 disappear from the ToC.4 Make The sapiens ascent an appendix.
Then, build references to:1 Image 22 A table.3 A section4 A subsection.5 An item of a list.6 The page containing image 1.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 17 / 29
References Bibliography
Bibliography: the basics
Bibliography is best managed with BibTeX, a sepparate extension toLaTeX.
References are stored in a .bib file.
The file is linked at the end of the main .tex file.
The style of the references is declared with the link to thebibliography.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 18 / 29
References Bibliography
Bibliography: the basics
Bibliography is best managed with BibTeX, a sepparate extension toLaTeX.
References are stored in a .bib file.
The file is linked at the end of the main .tex file.
The style of the references is declared with the link to thebibliography.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 18 / 29
References Bibliography
Bibliography: the basics
Bibliography is best managed with BibTeX, a sepparate extension toLaTeX.
References are stored in a .bib file.
The file is linked at the end of the main .tex file.
The style of the references is declared with the link to thebibliography.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 18 / 29
References Bibliography
Bibliography: the basics
Bibliography is best managed with BibTeX, a sepparate extension toLaTeX.
References are stored in a .bib file.
The file is linked at the end of the main .tex file.
The style of the references is declared with the link to thebibliography.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 18 / 29
References Bibliography
The Bibliography .bib file
It is a database with all the references you wish to use in a specifiedformat.
Each type of publication needs some specific fields, and may haveadditional information.
A piece of advice: put all your references in a single file, and use it forany paper/thesis/abstract/whatever you are writting at the moment.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 19 / 29
References Bibliography
The Bibliography .bib file
It is a database with all the references you wish to use in a specifiedformat.
Each type of publication needs some specific fields, and may haveadditional information.
A piece of advice: put all your references in a single file, and use it forany paper/thesis/abstract/whatever you are writting at the moment.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 19 / 29
References Bibliography
The Bibliography .bib file
It is a database with all the references you wish to use in a specifiedformat.
Each type of publication needs some specific fields, and may haveadditional information.
A piece of advice: put all your references in a single file, and use it forany paper/thesis/abstract/whatever you are writting at the moment.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 19 / 29
References Bibliography
Hands on
@article{gibbons2011,
author = {Ann Gibbons},
title = {Who were the Denisovans?},
journal = {Science},
number = {333},
pages = {1084-87},
year = {2011}
}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 20 / 29
References Bibliography
Types of publications
compulsory optional@article author, title, journal, year volume, number, pages,
month, note
@book author/editor, title, publisher,year
address, edition, volume,number, series, month, note
@inproceedings author, title, booktitle, year editor, volume, number, se-ries, pages, address, month,organization, publisher, note
@inbook author/editor, title, chapterand/or pages, publisher, year
volume, number, series, type,address, edition, month, note
@phdthesis author, title, year, school address, month, keywords,note
@misc — auhor, title, howpublished,month, year, note
Table: Quick reference chart for types of publications and their fields.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 21 / 29
References Bibliography
And citing, actually
In text references are called using the label of the publication:
\cite{label}
\nocite{label}
The bibliography is displayed by calling the bib file at the end of thedocument:
\bibliography{exercise2}
\bibliographystyle{apalike}
\end{document}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 22 / 29
References Bibliography
And citing, actually
In text references are called using the label of the publication:
\cite{label}
\nocite{label}
The bibliography is displayed by calling the bib file at the end of thedocument:
\bibliography{exercise2}
\bibliographystyle{apalike}
\end{document}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 22 / 29
References Bibliography
Try it on the file exercise2.tex
1 Add Gibbons’ reference to the end of the last paragraph of section 4.
2 Add Gould’s reference to his citation at the beginning of thedocument.
3 Add Skoglund’s reference in the footnote
4 Change your bibliography style from apalike to plain
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 23 / 29
References Bibliography
Bibliography styles
You can find online examples of bibliography styles
herehereand here
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 24 / 29
References Bibliography
What if I like the author(year) format?
\usepackage{natbib} IN THE PREAMBLE, as always
\begin{document}
... \citet{label} ...
... \citep{label} ...
... \citep[e.g.,][]{label} ...
... \citep[see][p.103]{label} ...
... \citep[hereafter SJG, 89]{label} ...
\end{document}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 25 / 29
Basic maths
Outline
1 A bit more on. . .. . . tables. . .. . . and sections.
2 ReferencesCross-referencesBibliography
3 Basic maths
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 26 / 29
Basic maths
Writing maths is easier than understanding maths
The maths environment allows for the use of lots of symbols:
Greek letters: α, β, ψ, ω, Σ, Θ, ΞArrows: →, , ↙, ⇔Logic: ∀, ∃, ∈, ⊆Maths:
√root, ÷, ≤, ≈
Miscellaneous: ℵ, c©, ∞, ♥, ♠, ‡, [Equations and complicated stuff:
∑ni=0 i
3 =∫∞0
e−x2
dx =√π2
It is delimited by $ . . . $ (inline) or $$ . . . $$ (displayed)
To use it properly, call the amsmath packages in the preamble:
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 27 / 29
Basic maths
Writing maths is easier than understanding maths
The maths environment allows for the use of lots of symbols:
Greek letters: α, β, ψ, ω, Σ, Θ, ΞArrows: →, , ↙, ⇔Logic: ∀, ∃, ∈, ⊆Maths:
√root, ÷, ≤, ≈
Miscellaneous: ℵ, c©, ∞, ♥, ♠, ‡, [Equations and complicated stuff:
∑ni=0 i
3 =∫∞0
e−x2
dx =√π2
It is delimited by $ . . . $ (inline) or $$ . . . $$ (displayed)
To use it properly, call the amsmath packages in the preamble:
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 27 / 29
Basic maths
Writing maths is easier than understanding maths
The maths environment allows for the use of lots of symbols:
Greek letters: α, β, ψ, ω, Σ, Θ, ΞArrows: →, , ↙, ⇔Logic: ∀, ∃, ∈, ⊆Maths:
√root, ÷, ≤, ≈
Miscellaneous: ℵ, c©, ∞, ♥, ♠, ‡, [Equations and complicated stuff:
∑ni=0 i
3 =∫∞0
e−x2
dx =√π2
It is delimited by $ . . . $ (inline) or $$ . . . $$ (displayed)
To use it properly, call the amsmath packages in the preamble:
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 27 / 29
Basic maths
A couple of examples...
(∀x)A(x)↔ ¬(∃x)B(x)
$(\forall x)A(x) \leftrightarrow \neg(\exists x)B(x)$
T[past] ↔ ∅ {√Hit}
$T_{[past]} \leftrightarrow \emptyset \ \_\_\{\sqrt{\textsc{Hit}}\}$
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 28 / 29
Basic maths
A couple of examples...
(∀x)A(x)↔ ¬(∃x)B(x)
$(\forall x)A(x) \leftrightarrow \neg(\exists x)B(x)$
T[past] ↔ ∅ {√Hit}
$T_{[past]} \leftrightarrow \emptyset \ \_\_\{\sqrt{\textsc{Hit}}\}$
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 28 / 29
Basic maths
Lists of symbols
Online, short reference guide.
PDF, comprehensive symbol list.
Borrega & Martins (UB) Introduction to LATEX Session #3 February 4, 2013 29 / 29