LaTeX tutorial II
description
Transcript of LaTeX tutorial II
Introduction to LATEXSession #2
Oriol Borrega Pedro Tiago Martins
Universitat de Barcelona
January 21, 2013
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 1 / 41
Outline
1 A preamble: preamblesStyling with style
2 Listing the listsItemizing stuffEnumerating stuffDefining stuff
3 Floating elementsImagine imagesWhy must there always be a table?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 2 / 41
Before we begin. . .
Before we begin. . .
. . . remember your commands!
\documentclass[a4paper,12pt]{article}
\section{Your section name here}
\emph{some text here}
\begin{document}
Lots of stuff in here
\end{document}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 3 / 41
Before we begin. . .
Before we begin. . .
. . . remember your commands!
\documentclass[a4paper,12pt]{article}
\section{Your section name here}
\emph{some text here}
\begin{document}
Lots of stuff in here
\end{document}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 3 / 41
Before we begin. . .
Before we begin. . .
. . . remember your commands!
\documentclass[a4paper,12pt]{article}
\section{Your section name here}
\emph{some text here}
\begin{document}
Lots of stuff in here
\end{document}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 3 / 41
Before we begin. . .
(and a brief side comment)
Anything following a percent sign (%) will be ignored by the compiler.That’s very useful to put comments in your documents or to turn on/offcommands and lines of text.
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 4 / 41
A preamble: preambles
Outline
1 A preamble: preamblesStyling with style
2 Listing the listsItemizing stuffEnumerating stuffDefining stuff
3 Floating elementsImagine imagesWhy must there always be a table?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 5 / 41
A preamble: preambles
An example of a preamble
\documentclass{article}
\usepackage[english,catalan]{babel}
\usepackage[ansinew]{inputenc}
\usepackage{geometry} %Allows to change layout settings
\usepackage{enumerate} %Enables lists
\title{The Denisova Hominin}
\author{Wikipedia}
\date{January 21st, 2013}
\parskip=5mm
\geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 6 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
What is going on here?
We are declaring the kind of document we want X\ documentclass[a4paper,12pt]{article}
We are telling LATEX we will do some “special tricks”
\ usepackage[english,catalan]{babel}\ usepackage[ansinew]{inputenc}\ usepackage{geometry}\ usepackage{enumerate}
We are signing our document X\ title {The Denisova hominin}\ author {N.E.Ander et al.}\ date {Just about today}
We are changing the default layout of the document
\ parskip=5mm\ geometry{top=2.5cm,left=3cm,right=3cm,bottom=2.5cm}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 7 / 41
A preamble: preambles
Remember!
Title, author and date do not appear by default
\ maketitle
Something similar happens with languages
\ selectlanguage{catalan}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 8 / 41
A preamble: preambles
Remember!
Title, author and date do not appear by default
\ maketitle
Something similar happens with languages
\ selectlanguage{catalan}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 8 / 41
A preamble: preambles
Remember!
Title, author and date do not appear by default
\ maketitle
Something similar happens with languages
\ selectlanguage{catalan}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 8 / 41
A preamble: preambles
Remember!
Title, author and date do not appear by default
\ maketitle
Something similar happens with languages
\ selectlanguage{catalan}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 8 / 41
A preamble: preambles Styling with style
Just a word on styling: Font Size
this text is tiny
this text is in scriptsize
this text is in footnotesize
this text is still small
this is the normalsize
this text is large
this text is Large
Man, this text is LARGE
this is huge
this is really Huge
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 9 / 41
A preamble: preambles Styling with style
Just a word on styling: Text Alignment
Text in LATEX can be aligned as you like,
you just have to say how that is. You rather have it
centered, to the left or to the right?
\begin{flushleft}
Text in \LaTeX can be aligned as you like,
\end{flushleft}
\begin{center}
you just have to say how that is. You rather have it
\end{center}
\begin{flushright}
centered, to the left or to the right?
\end{flushright}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 10 / 41
A preamble: preambles Styling with style
Just a word on styling: Text Alignment
Text in LATEX can be aligned as you like,
you just have to say how that is. You rather have it
centered, to the left or to the right?
\begin{flushleft}
Text in \LaTeX can be aligned as you like,
\end{flushleft}
\begin{center}
you just have to say how that is. You rather have it
\end{center}
\begin{flushright}
centered, to the left or to the right?
\end{flushright}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 10 / 41
Listing the lists
Outline
1 A preamble: preamblesStyling with style
2 Listing the listsItemizing stuffEnumerating stuffDefining stuff
3 Floating elementsImagine imagesWhy must there always be a table?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 11 / 41
Listing the lists
Three examples of lists
Itemizing only puts bullets. . .
. . . it makes an unordered list.
1 Enumeration numbers each item. . .
2 . . . automatically, of course.
Description is seldom used, though it’s nice.
Items are put as in a dictionary.
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 12 / 41
Listing the lists
Three examples of lists
Itemizing only puts bullets. . .
. . . it makes an unordered list.
1 Enumeration numbers each item. . .
2 . . . automatically, of course.
Description is seldom used, though it’s nice.
Items are put as in a dictionary.
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 12 / 41
Listing the lists
Three examples of lists
Itemizing only puts bullets. . .
. . . it makes an unordered list.
1 Enumeration numbers each item. . .
2 . . . automatically, of course.
Description is seldom used, though it’s nice.
Items are put as in a dictionary.
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 12 / 41
Listing the lists
Three examples of lists
Itemizing only puts bullets. . .
. . . it makes an unordered list.
1 Enumeration numbers each item. . .
2 . . . automatically, of course.
Description is seldom used, though it’s nice.
Items are put as in a dictionary.
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 12 / 41
Listing the lists Itemizing stuff
Itemizing stuff
The basic way:
\begin{itemize}
\item First item
\item Second item
\item Third item
\end{itemize}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 13 / 41
Listing the lists Itemizing stuff
Itemizing stuff
Itemization provides four levels, by nesting several itemizeenvironments
\begin{itemize}
\item First level
\begin{itemize}
\item Second level
\begin{itemize}
\item Third level
\begin{itemize}
\item Fourth level
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 14 / 41
Listing the lists Itemizing stuff
Itemizing stuff
Itemization provides four levels, by nesting several itemizeenvironments
\begin{itemize}
\item First level
\begin{itemize}
\item Second level
\begin{itemize}
\item Third level
\begin{itemize}
\item Fourth level
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 14 / 41
Listing the lists Itemizing stuff
A quick challenge
First level
Second level
First levelSecond level
Third level
Second level
Third levelThird level
First level
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 15 / 41
Listing the lists Itemizing stuff
Was it hard?
\begin{itemize}
\item First level
\begin{itemize}
\item Second level
\end{itemize}
\item First level
\begin{itemize}
\item Second level
\begin{itemize}
\item Third level
\end{itemize}
\item Second level
\begin{itemize}
\item Third level
\item Third level
\end{itemize}
\end{itemize}
\item First level
\end{itemize}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 16 / 41
Listing the lists Enumerating stuff
Enumerating stuff
The basic way, almost like itemizing:
\begin{enumerate}
\item First item
\item Second item
\item Third item
\end{enumerate}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 17 / 41
Listing the lists Enumerating stuff
Enumerating stuff
Like with itemization, four levels are provided with differentnumeration symbols: Arabic numbers, bracketted latin letters, romannumbers and capital latin letters.
Good news is: it is very easy to change those symbols:
(i) roman numbers(ii) with brackets
1) arabic numbers2) with a single bracket
A.- capital latin lettersB.- with a dot and a dash
∀(x) →1 meaningless logical formula∀(x) →2 and an arabic number
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 18 / 41
Listing the lists Enumerating stuff
Enumerating stuff
Like with itemization, four levels are provided with differentnumeration symbols: Arabic numbers, bracketted latin letters, romannumbers and capital latin letters.
Good news is: it is very easy to change those symbols:
(i) roman numbers(ii) with brackets
1) arabic numbers2) with a single bracket
A.- capital latin lettersB.- with a dot and a dash
∀(x) →1 meaningless logical formula∀(x) →2 and an arabic number
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 18 / 41
Listing the lists Enumerating stuff
Enumerating stuff
Like with itemization, four levels are provided with differentnumeration symbols: Arabic numbers, bracketted latin letters, romannumbers and capital latin letters.
Good news is: it is very easy to change those symbols:
(i) roman numbers(ii) with brackets
1) arabic numbers2) with a single bracket
A.- capital latin lettersB.- with a dot and a dash
∀(x) →1 meaningless logical formula∀(x) →2 and an arabic number
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 18 / 41
Listing the lists Enumerating stuff
. . . enumeration not enumerating any more!
You can even make enumeration look like an itemized list:
- with dashes- and nothing else
% with percent symbols% if you fancy
with nothing at all(really, this is an enumeration too)
:-) with anything:-) that you want ;-)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 19 / 41
Listing the lists Enumerating stuff
. . . enumeration not enumerating any more!
You can even make enumeration look like an itemized list:
- with dashes- and nothing else
% with percent symbols% if you fancy
with nothing at all(really, this is an enumeration too)
:-) with anything:-) that you want ;-)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 19 / 41
Listing the lists Enumerating stuff
. . . enumeration not enumerating any more!
You can even make enumeration look like an itemized list:
- with dashes- and nothing else
% with percent symbols% if you fancy
with nothing at all(really, this is an enumeration too)
:-) with anything:-) that you want ;-)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 19 / 41
Listing the lists Enumerating stuff
. . . enumeration not enumerating any more!
You can even make enumeration look like an itemized list:
- with dashes- and nothing else
% with percent symbols% if you fancy
with nothing at all(really, this is an enumeration too)
:-) with anything:-) that you want ;-)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 19 / 41
Listing the lists Enumerating stuff
. . . enumeration not enumerating any more!
You can even make enumeration look like an itemized list:
- with dashes- and nothing else
% with percent symbols% if you fancy
with nothing at all(really, this is an enumeration too)
:-) with anything:-) that you want ;-)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 19 / 41
Listing the lists Enumerating stuff
Some examples
\usepackage{enumerate}
\begin{enumerate}[(i)]
\item roman numbers
\item with brackets
\end{enumerate}
\begin{enumerate}[]
\item with nothing at all
\item (really, this is an enumeration too)
\end{enumerate}\
\begin{enumerate}[:-)]
\item with anything
\item that you want ;-)
\end{enumerate}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 20 / 41
Listing the lists Defining stuff
Defining stuff
The basic way. Notice the defined term is entered as an optionalargument to \item:
\begin{description}
\item[One] First item
\item[Two] Second item
\item[Three] Third item
\end{description}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 21 / 41
Listing the lists Defining stuff
Defining stuff
It looks good, as in a dictionary:
One First itemTwo Second item
Three Third item
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 22 / 41
Floating elements
Outline
1 A preamble: preamblesStyling with style
2 Listing the listsItemizing stuffEnumerating stuffDefining stuff
3 Floating elementsImagine imagesWhy must there always be a table?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 23 / 41
Floating elements
Why “floating”?
There are two basic types: figures and tables
They do not have a fixed placing in the page: LATEX decides where isbest to anchor them so they don’t interrupt the flow of the text
They are containers to elements that cannot be split or brokenbetween pages.
Additionally, they have a caption defining them, and they arenumbered (so they can be referred to easily in the text).
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 24 / 41
Floating elements
Why “floating”?
There are two basic types: figures and tables
They do not have a fixed placing in the page: LATEX decides where isbest to anchor them so they don’t interrupt the flow of the text
They are containers to elements that cannot be split or brokenbetween pages.
Additionally, they have a caption defining them, and they arenumbered (so they can be referred to easily in the text).
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 24 / 41
Floating elements
Why “floating”?
There are two basic types: figures and tables
They do not have a fixed placing in the page: LATEX decides where isbest to anchor them so they don’t interrupt the flow of the text
They are containers to elements that cannot be split or brokenbetween pages.
Additionally, they have a caption defining them, and they arenumbered (so they can be referred to easily in the text).
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 24 / 41
Floating elements
Why “floating”?
There are two basic types: figures and tables
They do not have a fixed placing in the page: LATEX decides where isbest to anchor them so they don’t interrupt the flow of the text
They are containers to elements that cannot be split or brokenbetween pages.
Additionally, they have a caption defining them, and they arenumbered (so they can be referred to easily in the text).
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 24 / 41
Floating elements Imagine images
Figures: an example
Figure: Not this kind of latex
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 25 / 41
Floating elements Imagine images
Hands on: lets include an image
First of all, we must declare the graphicx package
\usepackage{graphicx}
Then, we prepare the figure environment
\begin{figure}[h]
\ldots
\end{figure}
Notice the [h] there?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 26 / 41
Floating elements Imagine images
Hands on: lets include an image
First of all, we must declare the graphicx package
\usepackage{graphicx}
Then, we prepare the figure environment
\begin{figure}[h]
\ldots
\end{figure}
Notice the [h] there?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 26 / 41
Floating elements Imagine images
Hands on: lets include an image
First of all, we must declare the graphicx package
\usepackage{graphicx}
Then, we prepare the figure environment
\begin{figure}[h]
\ldots
\end{figure}
Notice the [h] there?
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 26 / 41
Floating elements Imagine images
Hands off! Placing floats
All floats take an optional argument: the place specifier.There are four possible values:
h → here
t → top
b → bottom
p → sepparate page just for floats
They can be forced by adding an exclamation mark ([h!])However, in the end, they are just a suggestion: LATEX has the final word
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 27 / 41
Floating elements Imagine images
Hands off! Placing floats
All floats take an optional argument: the place specifier.There are four possible values:
h → here
t → top
b → bottom
p → sepparate page just for floats
They can be forced by adding an exclamation mark ([h!])However, in the end, they are just a suggestion: LATEX has the final word
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 27 / 41
Floating elements Imagine images
Hands off! Placing floats
All floats take an optional argument: the place specifier.There are four possible values:
h → here
t → top
b → bottom
p → sepparate page just for floats
They can be forced by adding an exclamation mark ([h!])However, in the end, they are just a suggestion: LATEX has the final word
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 27 / 41
Floating elements Imagine images
Hands on (again): lets include an image
Next step: tell LATEX what image we want to include, and how big itmust be
\begin{figure}[h]
\includegraphics[width=5cm]{images/image.png}
\end{figure}
Regarding size, we can tinker with
Image width → [width=Xcm]Image height → [height=Xcm]Scaling factor → [scale=1.5]Rotation angle (in degrees) → [angle=X]
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 28 / 41
Floating elements Imagine images
Hands on (again): lets include an image
Next step: tell LATEX what image we want to include, and how big itmust be
\begin{figure}[h]
\includegraphics[width=5cm]{images/image.png}
\end{figure}
Regarding size, we can tinker with
Image width → [width=Xcm]Image height → [height=Xcm]Scaling factor → [scale=1.5]Rotation angle (in degrees) → [angle=X]
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 28 / 41
Floating elements Imagine images
Hands on (again): lets include an image
Next step: tell LATEX what image we want to include, and how big itmust be
\begin{figure}[h]
\includegraphics[width=5cm]{images/image.png}
\end{figure}
Regarding size, we can tinker with
Image width → [width=Xcm]Image height → [height=Xcm]Scaling factor → [scale=1.5]Rotation angle (in degrees) → [angle=X]
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 28 / 41
Floating elements Imagine images
Hands on (again): lets include an image
Next step: tell LATEX what image we want to include, and how big itmust be
\begin{figure}[h]
\includegraphics[width=5cm]{images/image.png}
\end{figure}
Regarding size, we can tinker with
Image width → [width=Xcm]Image height → [height=Xcm]Scaling factor → [scale=1.5]Rotation angle (in degrees) → [angle=X]
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 28 / 41
Floating elements Imagine images
Hands on (again): lets include an image
Next step: tell LATEX what image we want to include, and how big itmust be
\begin{figure}[h]
\includegraphics[width=5cm]{images/image.png}
\end{figure}
Regarding size, we can tinker with
Image width → [width=Xcm]Image height → [height=Xcm]Scaling factor → [scale=1.5]Rotation angle (in degrees) → [angle=X]
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 28 / 41
Floating elements Imagine images
Hands on (again): lets include an image
Finally, we can add a caption to the image (either before or after theimage itself, within the environment)
\begin{figure}[h]
\includegraphics[width=5cm]{images/image.png}
\caption{This image has served us as a tutorial.}
\end{figure}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 29 / 41
Floating elements Imagine images
Imagine not only images
Although this is not as common, the contents of the figure environmentcan be text. For instance:
Com evident experiencia mostra, la debilitat de la nostra memoria, sotsmetent facilmenta oblivio no solament los actes per longitud de temps envellits, mas encara los actes
frescs de nostres dies, es estat doncs molt condecent, util e expedient deduir en escrit lesgestes e histories antigues dels homens forts e virtuosos, com sien espills molt clars,exemples e virtuosa doctrina de nostra vida, segons recita aquell gran orador Tul·li.
Figura: A fragment of Tirant lo Blanc
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 30 / 41
Floating elements Imagine images
Imagine not only images
Although this is not as common, the contents of the figure environmentcan be text. For instance:
Com evident experiencia mostra, la debilitat de la nostra memoria, sotsmetent facilmenta oblivio no solament los actes per longitud de temps envellits, mas encara los actes
frescs de nostres dies, es estat doncs molt condecent, util e expedient deduir en escrit lesgestes e histories antigues dels homens forts e virtuosos, com sien espills molt clars,exemples e virtuosa doctrina de nostra vida, segons recita aquell gran orador Tul·li.
Figura: A fragment of Tirant lo Blanc
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 30 / 41
Floating elements Why must there always be a table?
Ready? The tough part begins now...
...so take a deep breath.
The fun part begins now!
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 31 / 41
Floating elements Why must there always be a table?
How a table looks like in the final .pdf...
JOHN MARY JAMES
Monday ironing cooking vacuum cleaning
Tuesday cooking dusting sweepingWednesday shopping
Thursday bathroom cleaning cooking
Friday rest
Table: This table is neat!
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 32 / 41
Floating elements Why must there always be a table?
...and how it looks like in the .tex
\begin{table}[h!]
\begin{tabular}{|c|c|c|c|}
\cline{2-4}
\multicolumn{1}{c|}{} & JOHN & MARY & JAMES \\\hline
Monday & ironing & cooking & vacuum cleaning \\\hline
Tuesday & cooking & dusting & sweeping \\\cline{1-1}\cline{3-4}
Wednesday & & \multicolumn{2}{c|}{shopping}\\\hline
Thursday & \multicolumn{2}{c|}{bathroom cleaning} & cooking \\\hline
Friday & \multicolumn{3}{c|}{rest}\\\hline
\end{tabular}
\caption{This table is neat!}
\end{table}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 33 / 41
Floating elements Why must there always be a table?
Lets walk through it step by step
First, we prepare the table environment
\begin{table}[ht!]
...
\caption{This table is neat!}
\end{table}
\caption is optional
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 34 / 41
Floating elements Why must there always be a table?
Lets walk through it step by step
First, we prepare the table environment
\begin{table}[ht!]
...
\caption{This table is neat!}
\end{table}
\caption is optional
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 34 / 41
Floating elements Why must there always be a table?
Lets walk through it step by step
Next, we create the table with the tabular environment
\begin{table}[ht!]
\begin{tabular}{alignment}
...
\end{tabular}
\caption{This table is neat!}
\end{table}
Possible alignments are l (left), c (center) and r (right)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 35 / 41
Floating elements Why must there always be a table?
Lets walk through it step by step
Next, we create the table with the tabular environment
\begin{table}[ht!]
\begin{tabular}{alignment}
...
\end{tabular}
\caption{This table is neat!}
\end{table}
Possible alignments are l (left), c (center) and r (right)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 35 / 41
Floating elements Why must there always be a table?
Lets walk through it step by step
Next, we create the table with the tabular environment
\begin{table}[ht!]
\begin{tabular}{rcl}
...
\end{tabular}
\caption{This table is neat!}
\end{table}
Possible alignments are l (left), c (center) and r (right)
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 36 / 41
Floating elements Why must there always be a table?
Lets walk through it step by step
Finally, we add row after row of table
\begin{table}[ht!]
\begin{tabular}{rcl}
A & B & C \\
AA & BB & CC \\
AAA & BBB & CCC \\
AAAA & BBBB & CCCC \\
\end{tabular}
\caption{This table is neat!}
\end{table}
The ampersand (&) is the column divider, a linebreak (\\) finisheseach row.
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 37 / 41
Floating elements Why must there always be a table?
Ok, run it!
if we run the previous code, we get...
A B CAA BB CC
AAA BBB CCCAAAA BBBB CCCC
Table: This table is neat!
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 38 / 41
Floating elements Why must there always be a table?
Ok, run it!
if we run the previous code, we get...
A B CAA BB CC
AAA BBB CCCAAAA BBBB CCCC
Table: This table is neat!
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 38 / 41
Floating elements Why must there always be a table?
Lets add lines
\begin{table}[ht!]
\begin{tabular}{|r|c|l|}
\hline
A & B & C \\ \hline
AA & BB & CC \\ \cline{1-2}
AAA & BBB & CCC \\ \cline{2-3}
AAAA & BBBB & CCCC \\ \hline
\end{tabular}
\caption{This table is neat!}
\end{table}
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 39 / 41
Floating elements Why must there always be a table?
Lets add lines
A B C
AA BB CCAAA BBB CCC
AAAA BBBB CCCC
Table: This table is neat!
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 40 / 41
Floating elements Why must there always be a table?
Another quick challenge
COLUMN A COLUMN B COLUMN C
ROW 1 A1 B1 C1ROW 2 A2 B2 C2ROW 3 A3 B3 C3
Table: This table is a quick exercise
Borrega & Martins (UB) Introduction to LATEX Session #2 January 21, 2013 41 / 41