editing documents with latex

83
Master on Free Software Editing documents with L A T E X Laura M. Castro Souto

Upload: laura-m-castro

Post on 26-Jan-2015

113 views

Category:

Technology


1 download

DESCRIPTION

Master on Free Software.

TRANSCRIPT

Page 1: Editing documents with LaTeX

Master on Free Software

Editing documentswith LATEX

Laura M. Castro Souto

Page 2: Editing documents with LaTeX

Master on Free Software

List of topics

1 Introduction

2 Creating documents

3 Formatting documents

4 Editting documents

5 Conclusions

Page 3: Editing documents with LaTeX

Master on Free Software

Introduction: what is LaTeX?Software system to produce high-quality digitaldocuments

. . . oh, yet another text processor?Not really:

• Not a WYSIWYG tool

• Any text editor can be used for editing

• Together with the text content, somecommands are written

• Commands specify how the text is turnedinto the digital document

Page 4: Editing documents with LaTeX

Master on Free Software

Introduction: what is LaTeX?Software system to produce high-quality digitaldocuments . . . oh, yet another text processor?

Not really:

• Not a WYSIWYG tool

• Any text editor can be used for editing

• Together with the text content, somecommands are written

• Commands specify how the text is turnedinto the digital document

Page 5: Editing documents with LaTeX

Master on Free Software

Introduction: what is LaTeX?Software system to produce high-quality digitaldocuments . . . oh, yet another text processor?Not really:

• Not a WYSIWYG tool

• Any text editor can be used for editing

• Together with the text content, somecommands are written

• Commands specify how the text is turnedinto the digital document

Page 6: Editing documents with LaTeX

Master on Free Software

Introduction: what is LaTeX?

TEXLACommands

Text+

DocumentInput file

Actually, this is LATEX too.

Page 7: Editing documents with LaTeX

Master on Free Software

Introduction: what is LaTeX?

TEXLACommands

Text+

DocumentInput file

Actually, this is LATEX too.

Page 8: Editing documents with LaTeX

Master on Free Software

Introduction: what for?

Text typesetting 6= Text processing

• Page numbering

• Context-sensitive headings

• Chapters, sections, figures. . . numbering

• Management of indexes, notes, refs. . .

LATEX automatizes text processing. . . so that you can focus on text typesetting.

Page 9: Editing documents with LaTeX

Master on Free Software

Introduction: what for?

Text typesetting 6= Text processing

• Page numbering

• Context-sensitive headings

• Chapters, sections, figures. . . numbering

• Management of indexes, notes, refs. . .

LATEX automatizes text processing

. . . so that you can focus on text typesetting.

Page 10: Editing documents with LaTeX

Master on Free Software

Introduction: what for?

Text typesetting 6= Text processing

• Page numbering

• Context-sensitive headings

• Chapters, sections, figures. . . numbering

• Management of indexes, notes, refs. . .

LATEX automatizes text processing. . . so that you can focus on text typesetting.

Page 11: Editing documents with LaTeX

Master on Free Software

Introduction: what for?

• Articles, reports

• Dissertations, manuals, books

also,• letters• presentations• web content• . . .

Page 12: Editing documents with LaTeX

Master on Free Software

Introduction: what for?

• Articles, reports

• Dissertations, manuals, books

also,• letters• presentations• web content• . . .

Page 13: Editing documents with LaTeX

Master on Free Software

Introduction: how?

1 Source text edition• Input file (plain text, .tex)• Embedded LATEX commands

2 Compilation• LATEX compiler processes source code,

applying commands to text content toproduce final document

3 Visualization/printing• LATEX’s compiler DVI output is usually

transformed into Postscript or PDF

Page 14: Editing documents with LaTeX

Master on Free Software

Introduction: how?

TEXLA

TEXLAFDP

...document.log

document.ps

document.pdf

dvipdfm

dvips

document.texdocument.dvi

pdf2ps

ps2pdf

document.aux

Page 15: Editing documents with LaTeX

Master on Free Software

Introduction: how?

TEXLA

TEXLAFDP

...document.log

document.ps

document.pdf

dvipdfm

dvips

document.texdocument.dvi

pdf2ps

ps2pdf

document.aux

Page 16: Editing documents with LaTeX

Master on Free Software

Introduction: how?

• Linux:• texlive; kile, texmaker; evince, okular. . .

• Windows:• MikTEX; TEXnicCenter

• Mac:• MacTEX; TEXShop, iTEXMac

Page 17: Editing documents with LaTeX

Master on Free Software

Creating documents:basic structure

LATEX source files are logically divided in twoparts:

Preamble At the beginning of the document,includes general settings

Body After the preamble, includes textcontent together with embeddedcommands with limited scope

Page 18: Editing documents with LaTeX

Master on Free Software

Creating documents:basic structure

\ documentclass{art ic le}

\ begin{document}

This is my f i r s t LaTeX document.

\end{document}

Preamble

Body

command

environment

Page 19: Editing documents with LaTeX

Master on Free Software

Creating documents:basic structure

\ documentclass{art ic le}

\ begin{document}

This is my f i r s t LaTeX document.

\end{document}

Preamble

Body

command

environment

Page 20: Editing documents with LaTeX

Master on Free Software

Creating documents:basic structure

\ documentclass{art ic le}

\ begin{document}

This is my f i r s t LaTeX document.

\end{document}

Preamble

Body

command

environment

Page 21: Editing documents with LaTeX

Master on Free Software

Creating documents:basic structure

\ documentclass{art ic le}

\ begin{document}

This is my f i r s t LaTeX document.

\end{document}

Preamble

Body

command

environment

Page 22: Editing documents with LaTeX

Master on Free Software

Creating documents:basic structure

\ documentclass{art ic le}

\ begin{document}

This is my f i r s t LaTeX document.

\end{document}

Preamble

Body

command

environment

Page 23: Editing documents with LaTeX

Master on Free Software

Creating documents:document types

Every document begins with the command:

\ documentclass[ options]{document−class−name}

Basic LATEX document classes:

article, proc Suitable for short documents

book, report Suitable for long documents

letter, slides Specific purpose documents

Page 24: Editing documents with LaTeX

Master on Free Software

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

Page 25: Editing documents with LaTeX

Master on Free Software

Creating documents:global settings

LATEX assumes English language, but:

\usepackage[spanish]{babel}\usepackage[ utf8]{inputenc}

• Command usepackage loads modules

• Placed always in the preamble

• May receive options (spanish, utf8. . . )

Page 26: Editing documents with LaTeX

Master on Free Software

Formatting documents:front (title) page

LATEX generates simple title pages if we providesome 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

Page 27: Editing documents with LaTeX

Master on Free Software

Formatting documents:divisions

Syntax:

\ section [Short t i t l e ]{Long t i t l e of division}

LATEX divisions: part, chapter, section,subsection, subsubsection, paragraph,subparagraph

Related commands: tableofcontents, appendix

Page 28: Editing documents with LaTeX

Master on Free Software

Formatting documents:styles

There are 3 basic headings/footers styles:

empty empty headers and footers

plain empty header, centered pagenumber in footer

headings page number and current divisiontitle in header

Used/changed adding to the preamble:

\ pagestyle{style−name}

Page 29: Editing documents with LaTeX

Master on Free Software

Editting documents:basic elements

An environment is a document portionbetween a pair of begin-end commands:

\ begin{environment−name}. . .\end{environment−name}

Similarly, a block is a document portionbetween two brackets:

{ . . . }

Page 30: Editing documents with LaTeX

Master on Free Software

Editting documents:basic elements

Environments and blocks:

• affect the portion of the document inside

• can be nested

• when nested, their effects are combined

Page 31: Editing documents with LaTeX

Master on Free Software

Editting documents: fontsLATEX font families:

1 roman (default)

2 sanserif

3 typewriter

\ textrm{Short text} { \ rmfamily Text }\ textsf{Short text} { \ sffamily Text }\ texttt{Short text} { \ ttfamily Text }\ begin{rmfamily} Long text \end{rmfamily}\ begin{sffamily} Long text \end{sffamily}\ begin{ttfamily} Long text \end{ttfamily}

Page 32: Editing documents with LaTeX

Master on Free Software

Editting documents: fontsLATEX font shapes:

1 up (default)

2 italics

3 slanted

4 small caps

\ textup{Short text} { \upshape Text }\ text i t{Short text} { \ itshape Text }\ textsl{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}

Page 33: Editing documents with LaTeX

Master on Free Software

Editting documents: fonts

LATEX font faces:

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 becombined, but not every combination exists. . .

Page 34: Editing documents with LaTeX

Master on Free Software

Editting documents: fonts

Page 35: Editing documents with LaTeX

Master on Free Software

Editting documents: fonts{\tiny Text }

{\scriptsize Text }

{\footnotesize Text } LATEX font sizes{\small Text }

{\normalsize Text }{\large Text }{\Large Text }{\LARGE Text }{\huge Text }{\Huge Text }

Page 36: Editing documents with LaTeX

Master on Free Software

Editting documents: fonts

Context-sensitive emphasis:

\emph{Text}

Underline:

\ underline{Text}

Unprocessed text:

\ begin{verbatim}Verbatim environment

\end{verbatim}

Page 37: Editing documents with LaTeX

Master on Free Software

Editting documents: lists

There are three kinds of lists in LATEX:

• this is one of them

• a list of items

• the most widely used

\ begin{itemize}\ item this is one of them\ item a l i s t of items\ item the most widely used\end{itemize}

Page 38: Editing documents with LaTeX

Master on Free Software

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 is 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}

Page 39: Editing documents with LaTeX

Master on Free Software

Editting documents: lists

last this is the third kind of lists

keyword a description after the highlightedterm

\ begin{description}\ item [ last ] this i s the third kind of l i s t s\ item [keyword] a description after the

highlighted term\end{description}

Page 40: Editing documents with LaTeX

Master on Free Software

Editting documents: lists1 Of course:

• different kinds of lists• can be combined

2 as needed.

\ begin{enumerate}\ item Of course : \ begin{itemize}

\ item different kinds of l i s t s\ item can be combined\end{itemize}

\ item as needed.\end{enumerate}

Page 41: Editing documents with LaTeX

Master on Free Software

Editting documents:text alignment

LATEX always aligns text in both margins.

\ begin{f lush le f t}Left−only aligned text\end{f lush le f t}

\ l e f t l i ne{Left−only aligned l ine}

Page 42: Editing documents with LaTeX

Master on Free Software

Editting documents:text alignment

But we can customize it. . .

\ begin{flushright}Right−only aligned text\end{f lush le f t}

\ r ight l ine{Right−only aligned l ine}

Page 43: Editing documents with LaTeX

Master on Free Software

Editting documents:text alignment

. . . to fit our needs.

\ begin{center}Centered text\end{center}

\ centerline{Centered l ine}

Page 44: Editing documents with LaTeX

Master on Free Software

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.

1Are very easy to include.

Page 45: Editing documents with LaTeX

Master on Free Software

Editting documents:floating elements

Text can be rearranged; some elements can’t:floating elements

• position of a floating element will bedetermined depending on its context

• dimensions and placement of the floatingelement are as important as its content

Typical floating elements: tables and figures

Page 46: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

Text can be arranged as a table using thetabular environment:

this is just a simpleexample of a table

\ begin{tabular}{rc l}this & is just & a simple \ \example & & of a table \ \\end{tabular}

Page 47: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

There are several commands to draw linesalongside rows and columns:

this is just a simpleexample of a table

\ begin{tabular}{| r | c | l |} \ hlinethis & is just & a simple \ \ \ hlineexample & & of a table \ \ \ hline\end{tabular}

Page 48: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

There are several commands to draw linesalongside rows and columns:

this is just a simpleexample of a table

\ begin{tabular}{|rc | l |} \ hline \ hlinethis & is just & a simple \ \ \ cl ine{1−2}example & & of a table \ \ \ hline \ hline\end{tabular}

Page 49: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

Same-row/-column cells can be combined:

this is justtable

a simple example of

\ begin{tabular}{| r | c | l |} \ hline\ multicolumn{2}{c}{this is just}

& \ multirow{2}{*}{table }\ \ \ cl ine{1−2}a simple & example of & \ \ \ cl ine{1−2}\end{tabular}

\usepackage{multirow}

Page 50: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

Same-row/-column cells can be combined:

this is justtable

a simple example of

\ begin{tabular}{| r | c | l |} \ hline\ multicolumn{2}{c}{this is just}

& \ multirow{2}{*}{table }\ \ \ cl ine{1−2}a simple & example of & \ \ \ cl ine{1−2}\end{tabular}

\usepackage{multirow}

Page 51: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

Tabular is not a floating environment, we usetable to wrap it as such:

this is justtable

a simple example of

Table: Sample table

\ begin{table}[hp! ]TABLE DEFINITION HERE\ caption{Sample table}\end{table}

Page 52: Editing documents with LaTeX

Master on Free Software

Editting documents: tables

Floating elements placement preferenceoptions:

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

Page 53: Editing documents with LaTeX

Master on Free Software

Editting documents: images

Images can be inserted using commandincludegraphics from package graphicx:

\ includegraphics [width=2cm]{ figures /sample .png}

Page 54: Editing documents with LaTeX

Master on Free Software

Editting documents: images

Includegraphics options:

width = integer/decimal + unit

height = integer/decimal + unit

scale = scale factor (decimal)

angle = rotate factor (0 ≥ |integer| ≥ 360)

Useful commands:

\ textheight \ textwidth \columnwidth

Page 55: Editing documents with LaTeX

Master on Free Software

Editting documents: images

Includegraphics does not turn an image into afloating element, figure environment does:

Figure: Sample image

\ begin{figure}[hp! ]IMAGE DEFINITION HERE\ caption{Sample image}\end{figure}

Image index:\listoffigures

Page 56: Editing documents with LaTeX

Master on Free Software

Editting documents: images

Image formats supported byincludegraphics depend on the toolwe use to produce the final document!

dvips eps, ps

dvipdf eps, jpg, pdf, png, ps

pdflatex jpg, png, pdf, tiff

Page 57: Editing documents with LaTeX

Master on Free Software

Editting documents:references

To include references in a LATEX document:

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}

Page 58: Editing documents with LaTeX

Master on Free Software

Editting documents:bibliographic references

\ begin{thebibliography}{ZZ}\ bibitem{libroLaTeX}

Bernardo Cascales Salinas . \ \{\ itshape El l ibro de \LaTeX{}}. \ \Prentice Hall , 2004.

\ bibitem{iniciacionLaTeX}Javier Sanguino Botella . \ \{\ itshape Inic iacion a \LaTeX{}}. \ \Addison−Wesley , 1997.

\end{thebibliography}

References are made using \cite{bibitem−label}

Page 59: Editing documents with LaTeX

Master on Free Software

Editting documents:bibliographic references

BibTEX is a complementary tool to LATEX which

• allows an easier management ofbibliographic reference sets

• integrates with LATEX and automaticallygenerates thebibliography environment

1 Create bibliographic references file (.bib)

2 Include .bib file usage in LATEX source file

Page 60: Editing documents with LaTeX

Master on Free Software

Editting documents:bibliographic references

Bibliographic references file (.bib) format:

@BOOK{libroLatex ,author = {Cascales Salinas , Bernardo},publisher = {Prentice Hall } ,t i t l e = {El l ibro de \LaTeX{}},year = {2004}}

@ARTICLE{iniciacionLaTeX ,author = {Sanguino Botella , Javier },t i t l e = {Inic iacion a \LaTeX{}},journal = {Addison−Wesley Series},year = {1997}}

Page 61: Editing documents with LaTeX

Master on Free Software

Editting documents:bibliographic references

BibTEX file (sample.bib) usage in LATEX source:

\ 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

Page 62: Editing documents with LaTeX

Master on Free Software

Editting documents:bibliographic references

latex document. texbibtex document.auxlatex document. tex

• BibTEX uses cites information in .aux

• Only cited references will be part of thegenerated bibliography

• We can use \nocite{bibitem−label}, toconsider uncited references (or \nocite*)

Page 63: Editing documents with LaTeX

Master on Free Software

Conclusions

LATEX is a very powerful tool which

• automatizes many of the formattingtasks involved in producing a digitaldocument

• generates high-quality results

• requires very lightweight source files

• produces consistent output regardless ofeditor or platform

Page 64: Editing documents with LaTeX

Master on Free Software

Conclusions

We have learned to create a LATEX document,

• choose the appropriate document classand/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).

Page 65: Editing documents with LaTeX

Master on Free Software

LATEX references

El libro de LATEX.Bernardo Cascales Salinas et al.Prentice Hall, 2004.

Iniciación a LATEX2ε.Un sistema para preparar documentos.Javier Sanguino Botella.Addison-Wesley, 1997.

Una descripción de LATEX2ε.Toms Bautista et al.www.lsi.upc.es/~eipec/pdf/ldesc2e.pdf

Page 66: Editing documents with LaTeX

Master on Free Software

LATEX references

The Comprehensive TEX Archive Network(CTAN)www.ctan.org

LATEX – A document preparation systemwww.latex-project.org

CervanTEX: Grupo de usuarioshispanohablantes de TEXwww.cervantex.es

Page 67: Editing documents with LaTeX

Master on Free Software

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?

Page 68: Editing documents with LaTeX

Master on Free Software

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?

Page 69: Editing documents with LaTeX

Master on Free Software

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

Page 70: Editing documents with LaTeX

Master on Free Software

How to:create your title page

To create a customized front/title page:

\ begin{titlepage}

TITLE PAGE DEFINITION HERE

\end{titlepage}

Page 71: Editing documents with LaTeX

Master on Free Software

How to:set up columns

Whole document: \documentclass[twocolumn]{...}

Document portion: \usepackage{multicol}

\ begin{multicols}{3}This text is automatically rearranged into amany columns as stated in the argument ofthe multicols environment .\end{multicols}

This text isautomaticallyrearranged

into as manycolumns asstated in the

argument ofthe multicolsenvironment.

Page 72: Editing documents with LaTeX

Master on Free Software

How to:change headings

Customizable page style myheadings,enables use of

\ markright{right−header}\markboth{lef t−header}{right−header}

in preamble (default values match headings).

Useful commands: \thesection, \sectionname

For more complex customization:\usepackage{fancyhdr}, \usepackage{titleref}

Page 73: Editing documents with LaTeX

Master on Free Software

How to:customize margins

Easiest way:

\usepackage{anysize}

enables use of

\ marginsize{ le f t}{right}{top}{bottom}

in preamble.

Page 74: Editing documents with LaTeX

Master on Free Software

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:\ h f i l l \ d o t f i l l \ h r u l e f i l l \ v f i l l

Page 75: Editing documents with LaTeX

Master on Free Software

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 }

Page 76: Editing documents with LaTeX

Master on Free Software

How to:use color

Using package color we can:

textbackground

\ textcolor{green}{text}\ colorbox{green}{background}

Predefined colors: white, black, red, blue, green,cyan, magenta, yellow

Define colors:\definecolor{color−name}{schema}{specification}

gray|rgb|RGB|HTML|cmyk

Page 77: Editing documents with LaTeX

Master on Free Software

How to:use color

Using package color we can:

textbackground

\ textcolor{green}{text}\ colorbox{green}{background}

Predefined colors: white, black, red, blue, green,cyan, magenta, yellow

Define colors:\definecolor{color−name}{schema}{specification}

gray|rgb|RGB|HTML|cmyk

Page 78: Editing documents with LaTeX

Master on Free Software

How to:use color

this is just a simpleexample of a table

\ begin{tabular}{|rc|>{\columncolor{green}} l |}\ hline \ hline\ rowcolor{green} this & is just & a simple \ \

\ cl ine{1−2} example & & of a table \ \\ hline \ hline\end{tabular}

Page 79: Editing documents with LaTeX

Master on Free Software

How to:use color

this is just a simpleexample of a table

\ begin{tabular}{|rc|>{\columncolor{green}} l |}\ hline \ hline\ rowcolor{green} this & is just & a simple \ \

\ cl ine{1−2} example & & of a table \ \\ hline \ hline\end{tabular}

Page 80: Editing documents with LaTeX

Master on Free Software

How to:create letters

\ documentclass{let ter}\ begin{document}\ begin{let ter}{Chalmers University}\opening{To Whom i t May Concern:}

Please consider the following . . .

\ signature{Laura M. Castro}\ closing{Sincerely ,}\end{letter}\end{document}

Page 81: Editing documents with LaTeX

Master on Free Software

How to:create slides

• First LATEX document class aimed for slidepresentations: slides

• Each slide:

\ begin{sl ide}{T i t le}SLIDE CONTENTS

\end{sl ide}

• Poor results

• No flexibility, no customizability

Page 82: Editing documents with LaTeX

Master on Free Software

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 contemporaindarkblue frames lignesbleues nuancegris

troispoints gyom rico

• Still low customization level, no dynamism

Page 83: Editing documents with LaTeX

Master on Free Software

How to:create slides

• 3rd tool generation: Beamer

• The most flexible, powerful, popular

• Class beamer, environment frame

\ begin{frame}{T i t le}{Subtit le}\ begin{itemize}\ item One\ item Two\ item Three\end{itemize}

\end{frame}