Driving Behavioral Change for Information Management through Data-Driven Gree...
Editing documents with LaTeX
1. Editing documents
with L TEX
A
Laura M. Castro Souto
Master on Free Software
2. List of topics
1 Introduction
2 Creating documents
3 Formatting documents
4 Editting documents
5 Conclusions
Master on Free Software
3. Introduction: what is LaTeX?
Software system to produce high-quality digital
documents
Master on Free Software
4. Introduction: what is LaTeX?
Software system to produce high-quality digital
documents . . . oh, yet another text processor?
Master on Free Software
5. Introduction: what is LaTeX?
Software system to produce high-quality digital
documents . . . oh, yet another text processor?
Not really:
• Not a WYSIWYG tool
• Any text editor can be used for editing
• Together with the text content, some
commands are written
• Commands specify how the text is turned
into the digital document
Master on Free Software
6. Introduction: what is LaTeX?
Input file Document
Text
+
Commands
LATEX
Master on Free Software
7. Introduction: what is LaTeX?
Input file Document
Text
+
Commands
LATEX
Actually, this is L TEX too.
A
Master on Free Software
8. Introduction: what for?
Text typesetting = Text processing
• Page numbering
• Context-sensitive headings
• Chapters, sections, figures. . . numbering
• Management of indexes, notes, refs. . .
Master on Free Software
9. Introduction: what for?
Text typesetting = Text processing
• Page numbering
• Context-sensitive headings
• Chapters, sections, figures. . . numbering
• Management of indexes, notes, refs. . .
L TEX automatizes text processing
A
Master on Free Software
10. Introduction: what for?
Text typesetting = Text processing
• Page numbering
• Context-sensitive headings
• Chapters, sections, figures. . . numbering
• Management of indexes, notes, refs. . .
L TEX automatizes text processing
A
. . . so that you can focus on text typesetting.
Master on Free Software
12. Introduction: what for?
• Articles, reports
• Dissertations, manuals, books
also,
• letters
• presentations
• web content
• ...
Master on Free Software
13. Introduction: how?
1 Source text edition
• Input file (plain text, .tex)
• Embedded L TEX commands
A
2 Compilation
• L TEX compiler processes source code,
A
applying commands to text content to
produce final document
3 Visualization/printing
• L TEX’s compiler DVI output is usually
A
transformed into Postscript or PDF
Master on Free Software
14. Introduction: how?
document.aux
document.log
... document.ps
dvips
pdf2ps
LA T E X document.dvi
document.tex
ps2pdf
dvipdfm
P D F LA T E X document.pdf
Master on Free Software
15. Introduction: how?
document.aux
document.log
... document.ps
dvips
pdf2ps
LA T E X document.dvi
document.tex
ps2pdf
dvipdfm
P D F LA T E X document.pdf
Master on Free Software
17. Creating documents:
basic structure
L TEX source files are logically divided in two
A
parts:
Preamble At the beginning of the document,
includes general settings
Body After the preamble, includes text
content together with embedded
commands with limited scope
Master on Free Software
18. Creating documents:
basic structure
documentclass{ a r t i c l e }
begin{document}
This i s my f i r s t LaTeX document .
end{document}
Master on Free Software
19. Creating documents:
basic structure
Preamble
documentclass{ a r t i c l e }
begin{document}
This i s my f i r s t LaTeX document .
end{document}
Master on Free Software
20. Creating documents:
basic structure
Preamble
documentclass{ a r t i c l e }
begin{document}
This i s my f i r s t LaTeX document .
end{document}
Body
Master on Free Software
21. Creating documents:
basic structure
documentclass{ a r t i c l e } command
begin{document}
This i s my f i r s t LaTeX document .
end{document}
Master on Free Software
22. Creating documents:
basic structure
documentclass{ a r t i c l e } command
begin{document}
This i s my f i r s t LaTeX document .
end{document}
environment
Master on Free Software
23. Creating documents:
document types
Every document begins with the command:
documentclass [ options ]{document−class−name}
Basic L TEX document classes:
A
article, proc Suitable for short documents
book, report Suitable for long documents
letter, slides Specific purpose documents
Master on Free Software
24. Creating documents:
document types
Document class options:
Base font size: 10pt, 11pt, 12pt
Paper format: letterpaper, a4paper. . .
Page format: oneside, twoside ⇒
openright/openany
Column format: onecolumn, twocolumn
Title page: titlepage, notitlepage
Master on Free Software
25. Creating documents:
global settings
L TEX assumes English language, but:
A
usepackage [ spanish ]{babel}
usepackage [ utf8 ]{ inputenc}
• Command usepackage loads modules
• Placed always in the preamble
• May receive options (spanish, utf8. . . )
Master on Free Software
26. Formatting documents:
front (title) page
L TEX generates simple title pages if we provide
A
some information in the preamble:
t i t l e {Document t i t l e }
author{Author or authors of the document}
date{Document date}
To actually display the title page, in the body:
maketitle
Master on Free Software
27. Formatting documents:
divisions
Syntax:
section [ Short t i t l e ]{Long t i t l e of d i v i s i o n}
L TEX divisions: part, chapter, section,
A
subsection, subsubsection, paragraph,
subparagraph
Related commands: tableofcontents, appendix
Master on Free Software
28. Formatting documents:
styles
There are 3 basic headings/footers styles:
empty empty headers and footers
plain empty header, centered page
number in footer
headings page number and current division
title in header
Used/changed adding to the preamble:
pagestyle{style −name}
Master on Free Software
29. Editting documents:
basic elements
An environment is a document portion
between a pair of begin-end commands:
begin{environment−name}
...
end{environment−name}
Similarly, a block is a document portion
between two brackets:
{ ... }
Master on Free Software
30. Editting documents:
basic elements
Environments and blocks:
• affect the portion of the document inside
• can be nested
• when nested, their effects are combined
Master on Free Software
31. Editting documents: fonts
L TEX font families:
A
1 roman (default)
2 sanserif
3 typewriter
textrm{Short text} { rmfamily Text }
t e x t s f{Short text} { sffamily Text }
t e x t t t{Short text} { t t f a m i l y Text }
begin{rmfamily} Long text end{rmfamily}
begin{sffamily} Long text end{sffamily}
begin{t t f a m i l y} Long text end{t t f a m i l y}
Master on Free Software
32. Editting documents: fonts
L TEX font shapes:
A
1 up (default) 3 slanted
2 italics 4 small caps
textup{Short text} { upshape Text }
t e x t i t {Short text} { itshape Text }
t e x t s l{Short text} { slshape Text }
textsc{Short text} { scshape Text }
begin{upshape} Long text end{upshape}
begin{itshape} Long text end{itshape}
begin{slshape} Long text end{slshape}
begin{scshape} Long text end{scshape}
Master on Free Software
33. Editting documents: fonts
L TEX font faces:
A
1 medium (default)
2 bold
textmd{Short text} { mdseries Text }
textbf{Short text} { bfseries Text }
begin{mdseries} Long text end{mdseries}
begin{bfseries} Long text end{bfseries}
Different font families, shapes and fonts can be
combined, but not every combination exists. . .
Master on Free Software
35. Editting documents: fonts
{tiny Text }
{scriptsize Text }
{footnotesize Text } L TEX font sizes
A
{small Text }
{normalsize Text }
{large Text }
{Large Text }
{LARGE Text }
{huge Text }
{Huge Text }
Master on Free Software
37. Editting documents: lists
There are three kinds of lists in L TEX:
A
• this is one of them
• a list of items
• the most widely used
begin{itemize}
item t h i s i s one of them
item a l i s t of items
item the most widely used
end{itemize}
Master on Free Software
38. Editting documents: lists
1 This is another kind of list,
2 a list of items with a numbered label,
3 presents ordered items.
begin{enumerate}
item This i s another kind of l i s t ,
item a l i s t of items with a numbered label ,
item presents ordered items .
end{enumerate}
Master on Free Software
39. Editting documents: lists
last this is the third kind of lists
keyword a description after the highlighted
term
begin{description}
item [ l a s t ] t h i s i s the t h i r d kind of l i s t s
item [keyword] a description a f t e r the
highlighted term
end{description}
Master on Free Software
40. Editting documents: lists
1 Of course:
• different kinds of lists
• can be combined
2 as needed.
begin{enumerate}
item Of course : begin{itemize}
item d i f f e r e n t kinds of l i s t s
item can be combined
end{itemize}
item as needed .
end{enumerate}
Master on Free Software
41. Editting documents:
text alignment
L TEX always aligns text in both margins.
A
begin{ f l u s h l e f t }
Left−only aligned text
end{ f l u s h l e f t }
l e f t l i n e {Left−only aligned l i n e }
Master on Free Software
42. Editting documents:
text alignment
But we can customize it. . .
begin{f l u s h r i g h t}
Right−only aligned text
end{ f l u s h l e f t }
r i g h t l i n e {Right−only aligned l i n e }
Master on Free Software
43. Editting documents:
text alignment
. . . to fit our needs.
begin{center}
Centered text
end{center}
centerline{Centered l i n e }
Master on Free Software
44. Editting documents:
citations and notes
Side notes and footnotes1 :
footnote{Footnote text}
marginpar{Side note text}
Text in a quote or quotation environment:
Wider margins and emphasized font,
so that it stands out among the rest.
1
Are very easy to include.
Master on Free Software
45. Editting documents:
floating elements
Text can be rearranged; some elements can’t:
floating elements
• position of a floating element will be
determined depending on its context
• dimensions and placement of the floating
element are as important as its content
Typical floating elements: tables and figures
Master on Free Software
46. Editting documents: tables
Text can be arranged as a table using the
tabular environment:
this is just a simple
example of a table
begin{tabular}{ r c l }
this & i s j u s t & a simple
example & & of a table
end{tabular}
Master on Free Software
47. Editting documents: tables
There are several commands to draw lines
alongside rows and columns:
this is just a simple
example of a table
begin{tabular }{| r | c | l |} hline
this & i s j u s t & a simple hline
example & & of a table hline
end{tabular}
Master on Free Software
48. Editting documents: tables
There are several commands to draw lines
alongside rows and columns:
this is just a simple
example of a table
begin{tabular }{| rc | l |} hline hline
this & i s j u s t & a simple c l i n e{1−2}
example & & of a table hline hline
end{tabular}
Master on Free Software
49. Editting documents: tables
Same-row/-column cells can be combined:
this is just
table
a simple example of
begin{tabular }{| r | c | l |} hline
multicolumn{2}{c}{t h i s i s j u s t}
& multirow{2}{*}{table } c l i n e{1−2}
a simple & example of & c l i n e{1−2}
end{tabular}
Master on Free Software
50. Editting documents: tables
Same-row/-column cells can be combined:
this is just
table
a simple example of
begin{tabular }{| r | c | l |} hline
multicolumn{2}{c}{t h i s i s j u s t}
& multirow{2}{*}{table } c l i n e{1−2}
a simple & example of & c l i n e{1−2}
end{tabular}
usepackage{multirow}
Master on Free Software
51. Editting documents: tables
Tabular is not a floating environment, we use
table to wrap it as such:
this is just
table
a simple example of
Table: Sample table
begin{table }[hp ! ]
TABLE DEFINITION HERE
caption{Sample table}
end{table}
Master on Free Software
52. Editting documents: tables
Floating elements placement preference
options:
h preferred location is here
b preferred location is page bottom
t preferred location is page top
p preferred location is exclusive page
! demands flexibility
Table index: listoftables
Master on Free Software
53. Editting documents: images
Images can be inserted using command
includegraphics from package graphicx:
includegraphics [ width=2cm]{ figures / sample . png}
Master on Free Software
55. Editting documents: images
Includegraphics does not turn an image into a
floating element, figure environment does:
begin{figure }[hp ! ]
IMAGE DEFINITION HERE
caption{Sample image}
end{figure}
Figure: Sample image Image index:
listoffigures
Master on Free Software
56. Editting documents: images
Image formats supported by
includegraphics depend on the tool
we use to produce the final document!
dvips eps, ps
dvipdf eps, jpg, pdf, png, ps
pdflatex jpg, png, pdf, tiff
Master on Free Software
57. Editting documents:
references
To include references in a L TEX document:
A
1 Mark referrable elements with a label:
label{label −name}
• enumerate items
• floating elements with caption
• document sections
• (and pretty much anything with a number)
2 Refer to a label:
• element number ref{label−name}
• element page number pageref{label−name}
Master on Free Software
58. Editting documents:
bibliographic references
begin{thebibliography}{ZZ}
bibitem{libroLaTeX}
Bernardo Cascales Salinas .
{ itshape El l i b r o de LaTeX{}}.
Prentice Hall , 2004.
bibitem{iniciacionLaTeX}
J a v i e r Sanguino Botella .
{ itshape I n i c i a c i o n a LaTeX{}}.
Addison−Wesley , 1997.
end{thebibliography}
References are made using cite{bibitem−label}
Master on Free Software
59. Editting documents:
bibliographic references
BibTEX is a complementary tool to L TEX which
A
• allows an easier management of
bibliographic reference sets
• integrates with L T X and automatically
A
E
generates thebibliography environment
1 Create bibliographic references file (.bib)
2 Include .bib file usage in L TEX source file
A
Master on Free Software
60. Editting documents:
bibliographic references
Bibliographic references file (.bib) format:
@BOOK{libroLatex ,
author = {Cascales Salinas , Bernardo} ,
publisher = {Prentice Hall } ,
title = {El l i b r o de LaTeX{}},
year = {2004}}
@ARTICLE{iniciacionLaTeX ,
author = {Sanguino Botella , J a v i e r } ,
title = {I n i c i a c i o n a LaTeX{}},
journal = {Addison−Wesley Series } ,
year = {1997}}
Master on Free Software
61. Editting documents:
bibliographic references
BibTEX file (sample.bib) usage in L TEX source:
A
bibliography{sample}
bibliographystyle{bibliography−style −name}
plain numbered refs, alphabetic order
unsrt numbered refs, citation order
alpha alphanumeric refs, alphabetic order
abbrv shortened version of plain
Master on Free Software
62. Editting documents:
bibliographic references
latex document . tex
bibtex document . aux
latex document . tex
• BibT X uses cites information in .aux
E
• Only cited references will be part of the
generated bibliography
• We can use nocite{bibitem−label}, to
consider uncited references (or nocite*)
Master on Free Software
63. Conclusions
L TEX is a very powerful tool which
A
• automatizes many of the formatting
tasks involved in producing a digital
document
• generates high-quality results
• requires very lightweight source files
• produces consistent output regardless of
editor or platform
Master on Free Software
64. Conclusions
We have learned to create a L TEX document,
A
• choose the appropriate document class
and/or modify its basic appearance,
• generate basic title pages,
• select font families, shapes, faces, sizes,
alignment. . . ,
• insert lists, notes, tables, images,
references, bibliography,
and deliver a standard, safe version (PS/PDF).
Master on Free Software
65. L TEX references
A
El libro de L TEX.
A
Bernardo Cascales Salinas et al.
Prentice Hall, 2004.
Iniciación a L TEX 2ε .
A
Un sistema para preparar documentos.
Javier Sanguino Botella.
Addison-Wesley, 1997.
Una descripción de L TEX 2ε .
A
Toms Bautista et al.
www.lsi.upc.es/~eipec/pdf/ldesc2e.pdf
Master on Free Software
66. L TEX references
A
The Comprehensive TEX Archive Network
(CTAN)
www.ctan.org
L TEX – A document preparation system
A
www.latex-project.org
CervanTEX: Grupo de usuarios
hispanohablantes de TEX
www.cervantex.es
Master on Free Software
67. Advanced topics:
what do you want to know?
How do I. . . ?
• structure a document in different files?
• set up my own customized title page?
• arrange text into columns?
• change the headings of a document?
• customize the margins in a document?
Master on Free Software
68. Advanced topics:
what do you want to know?
• adjust spacing?
• personalize an itemize list?
• use color in text or tables?
• write a letter?
• create a slide presentation?
Master on Free Software
69. How to:
structure a file (physically)
input{ f i l e . tex}
include{ f i l e }
Diferences:
• include assumes .tex file extension
• include starts over in a new page
• include cannot be nested
• for each included file, a .aux is generated
Master on Free Software
70. How to:
create your title page
To create a customized front/title page:
begin{titlepage}
TITLE PAGE DEFINITION HERE
end{titlepage}
Master on Free Software
71. How to:
set up columns
Whole document: documentclass[twocolumn]{...}
Document portion: usepackage{multicol}
begin{multicols}{3}
This text i s automatically rearranged into a
many columns as stated in the argument of
the multicols environment .
end{multicols}
This text is into as many argument of
automatically columns as the multicols
rearranged stated in the environment.
Master on Free Software
72. How to:
change headings
Customizable page style myheadings,
enables use of
markright{right −header}
markboth{ l e f t −header}{right −header}
in preamble (default values match headings).
Useful commands: thesection, sectionname
For more complex customization:
usepackage{fancyhdr}, usepackage{titleref}
Master on Free Software
73. How to:
customize margins
Easiest way:
usepackage{anysize}
enables use of
marginsize{ l e f t }{r i g h t}{top}{bottom}
in preamble.
Master on Free Software
74. How to:
mess with spacing
Change line spacing:
usepackage{setspace}
singlespacing onehalfspacing doublespacing
Introduce page changes:
newpage clearpage cleardoublepage
Introduce blank spaces:
hspace{length} vspace{length}
To fill in space:
hfill dotfill hrulefill vfill
Master on Free Software
75. How to:
personalize lists
Customizable list environment: list
♣ list
♣ with customized
♣ symbol
begin{ l i s t }{$ clubsuit$}{}
item l i s t
item with customized
item symbol
end{ l i s t }
Master on Free Software
76. How to:
use color
Using package color we can:
text textcolor{green}{text}
background colorbox{green}{background}
Predefined colors: white, black, red, blue, green,
cyan, magenta, yellow
Define colors:
definecolor{color−name}{schema}{specification}
Master on Free Software
77. How to:
use color
Using package color we can:
text textcolor{green}{text}
background colorbox{green}{background}
Predefined colors: white, black, red, blue, green,
cyan, magenta, yellow
gray|rgb|RGB|HTML|cmyk
Define colors:
definecolor{color−name}{schema}{specification}
Master on Free Software
78. How to:
use color
this is just a simple
example of a table
begin{tabular }{| rc |>{columncolor{green}} l |}
hline hline
rowcolor{green} t h i s & i s j u s t & a simple
c l i n e{1−2} example & & of a table
hline hline
end{tabular}
Master on Free Software
79. How to:
use color
this is just a simple
example of a table
begin{tabular }{| rc |>{columncolor{green}} l |}
hline hline
rowcolor{green} t h i s & i s j u s t & a simple
c l i n e{1−2} example & & of a table
hline hline
end{tabular}
Master on Free Software
80. How to:
create letters
documentclass{ l e t t e r }
begin{document}
begin{ l e t t e r }{Chalmers University}
opening{To Whom i t May Concern:}
Please consider the following . . .
signature{Laura M. Castro}
closing{Sincerely ,}
end{ l e t t e r }
end{document}
Master on Free Software
81. How to:
create slides
• First L T X document class aimed for slide
A
E
presentations: slides
• Each slide:
begin{s l i d e}{ T i t l e }
SLIDE CONTENTS
end{s l i d e}
• Poor results
• No flexibility, no customizability
Master on Free Software
82. How to:
create slides
• One of the first alternatives: Prosper
• Best result/effort ration
• documentclass{prosper}, environment slides
• Predefined designs (document option):
alienglow autumn azure contemporain
darkblue frames lignesbleues nuancegris
troispoints gyom rico
• Still low customization level, no dynamism
Master on Free Software
83. How to:
create slides
• 3rd tool generation: Beamer
• The most flexible, powerful, popular
• Class beamer, environment frame
begin{frame}{ T i t l e }{S u b t i t l e}
begin{itemize}
item One
item Two
item Three
end{itemize}
end{frame}
Master on Free Software