Title: Text, not Word Processing
1Text, not Word Processing
- Gordon J. Pace
- March 2006
Before we start
2Document Organisation
- Logical
- Sectioning
- Emphasis
- Document style
- References
- Visual
- Font
- Local spacing
- Text size
3Pronunciation Guide
4Pronunciation Guide
- Latex pronounced lay-teks
5Pronunciation Guide
- Latex pronounced lay-teks
pronounced lay-tech (tech as in technical)
\documentclassarticle \begindocument \emphLo
ng Live \LaTeX Note the emphasis! \enddocument
6Your favourite text editor
acrobat
yap
dvi2pdf doc.dvi
latex doc.tex
Text file with embedded instructions doc.tex
Device independent document description doc.dvi
PDF document description doc.pdf
Some other printer format (eg postscript)
7Your favourite text editor
acrobat
Text file with embedded instructions doc.tex
PDF document description doc.pdf
pdftex doc.tex
8Some advantages of
- concentrate on content before appearance
- mathematical formulae easily described
- freely available for all popular platforms
- output comparable (equivalent) to that of
published books - various tools available eg
.
9Have you ever noticed
- how certain letters overlap in Word,
PowerPoint, etc? - fi ffi ff fl ffl
- because xxxxxx use ligatures and gives sexier
results
10What to Download
- . is a good Windows
implementation - WinEdt is a good editor for with a
full IDE for document writing - So is vi ?
- TeXPoint is perfect for including stuff
in PowerPoint presentations.
11Text, not Word Processing
- Gordon J. Pace
- March 2006
First steps
12Coding Basics
- . commands start with a backslash \
- Parameters are given in curly brackets
- Environments (blocks with a certain type of
content) are of the form - \beginenvironment_type
- environment content
- \endenvironment_type
13The Simplest Document
- \documentclassreport
- \begindocument
- \enddocument
14The Simplest Document
- \documentclassreport
- \begindocument
- \enddocument
This specifies the type of the document report,
book, article, letter, etc.
15The Simplest Document
- \documentclassreport
- \begindocument
- \enddocument
The way the document is formatted is deduced
through its class
16The Simplest Document
- \documentclassreport
- \begindocument
- \enddocument
Anything within the document environment is
typeset as output
17Hello World!
\documentclassreport \begindocument Hello Worl
d! Bye! \enddocument
18Hello World!
\documentclassreport \begindocument Hello Worl
d! Bye! \enddocument
19Hello World!
- Newlines in the source are ignored.
- Skipping a line in the source starts a new
paragraph
\documentclassreport \begindocument Hello Worl
d! Bye! \enddocument
20Commonly Used Symbols
21Excuse my French
\documentclassreport \begindocument He said
She said H\ell\o, jadore \LaTeX!
She was French, you see \ldots \enddocument
22Excuse my French
\documentclassreport \begindocument He said
She said H\ell\o, jadore \LaTeX!
She was French, you see \ldots \enddocument
23Useful Document Classes
- Article Ideal for a short paper (divided into
sections, subsections, etc). Typeset to be
printed double-sided. - Book Class to be used to typeset a book
(chapters, sections, etc). Typeset to be printed
double-sided. - Report (Almost) identical to the book class but
for single-sided printing. - Other classes include letter, slides, etc.
24Text, not Word Processing
- Gordon J. Pace
- March 2006
Logical Organisation
25Organising a Document
- A document is split into logical parts
- A title
- An abstract
- A number of parts
- A number of chapters in each part
- A number of sections in each chapter
- A number of subsections in each section
- A number of subsubsections in each subsection
- Availability of a logical part depends on the
document class (eg no chapters in a paper). - Typesetting of the sections may vary depending on
document class.
26The Title
\documentclassarticle \begindocument \title\
LaTeX Fun with Text \authorCikku
Flieles \date31st February 2000 \maketitle \e
nddocument
27The Title
\documentclassarticle \begindocument \title\
LaTeX Fun with Text \authorCikku
Flieles \date31st February 2000 \maketitle \en
ddocument
28The Abstract
- Available in article and report class.
- Used to give an overview of the content of the
document. - Is usually typeset with wider margins than the
main text. - Specified using the abstract environment
- \beginabstract
-
- \endabstract
29Logical Sections
- To start a named part, chapter, section,
subsection or subsubsection use the command - \section_typesection name
- where section_type is one of part, chapter,
section, subsection and subsubsection. - This will automatically create the title and
numbering of the section. - Any text after the command will appear inside the
section named. - Parts and chapters are only available in the
report and book class.
30Logical Sections
\documentclassreport \begindocument \chapterB
asics \sectionFirst of all \ldots Initially,
we think. \subsectionSit Down Find a chair and
sit down. \subsectionThink Think about the
chair. \enddocument
31Logical Sections
\documentclassreport \begindocument \chapterB
asics \sectionFirst of all \ldots Initially,
we think. \subsectionSit Down Find a chair and
sit down. \subsectionThink Think about the
chair. \enddocument
32Figures and Tables
- The figure environment is used to include a
floating figure in the text. - Similarly the table environment can be used to
insert a floating table. - A caption can be added to both using the
\caption command. - The two environments are identical except for the
caption title, and whether they appear in a list
of figures, or the list of tables.
33Figures and Tables
- The figure environment is used to include a
floating figure in the text. - Similarly the table environment can be used to
insert a floating table. - A caption can be added to both using the
\caption command. - The two environments are identical except for the
caption title, and whether they appear in a list
of figures, or the list of tables.
Floating objects do not have a fixed position in
the body of the text, but may be moved around by
to improve the layout
34Figures and Tables
\beginfigure Here include whatever you want
in the figure. \captionA demo
figure \endfigure Any other text
\ldots \begintable Here include whatever you
want in the table. \captionA demo
table \table Note that the figures and tables
may move \ldots
35Figures and Tables
\beginfigure Here include whatever you want in
the figure. \captionA demo figure \endfigure
Any other text \ldots \begintable Here
include whatever you want in the
table. \captionA demo table \table Note that
the figures and tables may move \ldots
36Figures and Tables
\beginfigure Here include whatever you want in
the figure. \captionA demo figure \endfigure
Any other text \ldots \begintable Here
include whatever you want in the
table. \captionA demo table \table Note that
the figures and tables may move \ldots
keeps count of the figure and table
numbering automatically.
37Figures and Tables
\beginfigure Here include whatever you want in
the figure. \captionA demo figure \endfigure
Any other text \ldots \begintable Here
include whatever you want in the
table. \captionA demo table \table Note that
the figures and tables may move \ldots
If puts the figures and tables
in strange positions there are ways of giving it
suggestions. Check a book on for
more details.
38Tables of Contents
- To add a table of contents, with parts, chapters,
sections, etc use the command \tableofcontents. - You may also include a list of figures and a list
of tables using \listoffigures and \listoftables.
39Tables of Contents
\titleA Quick \LaTeX\ Primer \authorGordon J.
Pace \date \maketitle \tableofcontents
40Tables of Contents
\titleA Quick \LaTeX\ Primer \authorGordon J.
Pace \date \maketitle \tableofcontents
41Tables of Contents
CAUTION . creates an auxiliary file
with all page numbers when run through a file.
Run twice to ensure that they match
\titleA Quick \LaTeX\ Primer \authorGordon J.
Pace \date \maketitle \tableofcontents
42Cross References
- Quite regularly, you will want to refer to
section 4.2.1.4 from section 7.6.4.2. - But when you add a section before section 4.2,
you will have to revise the numbering - provides a way of naming sections,
chapters, figures and tables to allow references
updated automatically.
43Cross References
- Use \labellabel name to name a numbered object
(figure, section, chapter, etc). It may appear
within the \caption, \section, etc parameter or
just after it. - Use \reflabel name to insert the number of the
object named using \label command. - Use \pagereflabel name to insert the page
number where the named object appears. - References may be forward or backward ones.
44Cross References
\sectionIntroduction ... more details can
be found in section \refsproof (in particular
look at figure \reffproof on page
\pagereffproof)... \sectionProofs and
Roofs ... \subsectionProof \labelsproof \b
eginfigure ... \captionProof outline
\labelfproof \endfigure ...
45Cross References
\sectionIntroduction ... more details can
be found in section \refsproof (in particular
look at figure \reffproof on page
\pagereffproof)... \sectionProofs and
Roofs ... \subsectionProof \labelsproof \b
eginfigure ... \captionProof outline
\labelfproof \endfigure ...
46Cross References
Using labels starting with f (for figures), s
(for sections), c (for chapters) is not
obligatory but will help you remember.
\sectionIntroduction ... more details can
be found in section \refsproof (in particular
look at figure \reffproof on page
\pagereffproof)... \sectionProofs and
Roofs ... \subsectionProof \labelsproof \b
eginfigure ... \captionProof outline
\labelfproof \endfigure ...
47Cross References
CAUTION As with tables of contents,
uses an auxiliary file with all references. Run
twice to ensure that references
match
\sectionIntroduction ... more details can
be found in section \refsproof (in particular
look at figure \reffproof on page
\pagereffproof)... \sectionProofs and
Roofs ... \subsectionProof \labelsproof \b
eginfigure ... \captionProof outline
\labelfproof \endfigure ...
48Organising a Large Document
- Writing a large document can make access to
different parts unwieldy. - has two commands to import files from
one another \inputfile, \includefile. - Both include the text in the file given as
parameter as-is into the main document. - They are identical except that \include starts a
new page automatically.
49Organising a Large Document
- Writing a large document can make access to
different parts unwieldy. - has two commands to import files from
one another \inputfile, \includefile. - Both include the text in the file given as
parameter as-is into the main document. - They are identical except that \include starts a
new page automatically.
Note that the although the files are assumed to
be files, the .tex extension is left
out.
50Typical Document Organisation
main.tex
Document FYP Chicken-Sort Date
1/9/2005 Author Cikku Flieles \documentstyle
report \begindocument \inputfrontpage
short introduction \inputintroduction The
algorithm \inputalgorithm Correctness
proof \inputproof Conclusions \inputconclusi
ons \enddocument
51Typical Document Organisation
proof.tex
main.tex
\chapterThe Proof of Correctness \section
Proof Outline We prove the correctness
of chicken sort using a technique based on the
Socratic method of discourse. Let us start by
assuming that Plato knew about this proof...
Document FYP Chicken-Sort Date
1/9/2005 Author Cikku Flieles \documentstyle
report \begindocument \inputfrontpage
short introduction \inputintroduction The
algorithm \inputalgorithm Correctness
proof \inputproof Conclusions \inputconclusi
ons \enddocument
52Text, not Word Processing
- Gordon J. Pace
- March 2006
Pictures Tables
53Images
- Images can be added anywhere in a document (not
just as a figure) - To include an image, use the command
\includegraphicsfilename - Various formats are allowed, including gif, jpg,
pdf (when using pdftex), etc.
54Resizing Images
- Images can be resized using the
- \resizeboxwidthheight
- object to resize
- Width and height can be set in various units cm,
mm, in, textwidth (the size of the page less the
margins). - Use ! as the width or height to scale it
according to the other given size.
55Il-Ahwa xFigure!
\beginfigure \resizebox0.8textwidth!
\includegraphicsgirlinlatex.gif \captionIl-Ah
wa xFigure \endfigure
56Il-Ahwa xFigure!
\beginfigure \resizebox0.8textwidth!
\includegraphicsgirlinlatex.gif \captionIl-Ah
wa xFigure \endfigure
57Tables
- To draw up tabular data, use the tabular
environment. - An extra parameter gives the information about
the column layout. - Separate lines using \\ and columns using the
ampersand () symbol. - \hline draws a horizontal line.
58Tables
- To draw up tabular data, use the tabular
environment. - An extra parameter gives the information about
the column layout. - Separate lines using \\ and columns using the
ampersand () symbol. - \hline draws a horizontal line.
eg lcr results in two vertical lines, a
left aligned column, another vertical line, a
centred column, and a right aligned column, and a
vertical line.
59Eurovision Singers
\begintabularlcr \hline Name Pos
Pnts \\ \hline Cikku 3rd 5 \\ Pippo 2nd
10 \\ Salvu 1st 15 \\
\hline \endtabular
60Eurovision Singers
\begintabularlcr \hline Name Pos
Pnts \\ \hline Cikku 3rd 5 \\ Pippo 2nd
10 \\ Salvu 1st 15 \\
\hline \endtabular
61Eurovision Singers
\begintabularlcr \hline Name Pos
Pnts \\ \hline Cikku 3rd 5 \\ Pippo 2nd
10 \\ Salvu 1st 15 \\
\hline \endtabular
left
centre
right
62Text, not Word Processing
- Gordon J. Pace
- March 2006
More Typesetting
63Footnotes
- To add a footnote, use the
-
- \footnotefootnote text
- A footnote mark (such as 1 or 2) appears where
the command is given, and the footnote at the
bottom of the page. - takes care of the rest.
64Unordered Lists
- The itemize environment creates an unordered list
(like this one). - Items are started using the \item command.
- You can have nested lists.
65Ordered Lists
- The enumerate environment creates an unordered
list (like this one). - Items are also started using the \item command.
- Nested ordered lists can be used.
66Description Lists
- The environment The description environment
creates a description list (like this one). - Items Items are started using the \item command,
with the title given as an optional parameter (in
square brackets) just after the command.
67Pre-Formatted Text
- Anything given within the verbatim environment is
typeset exactly as given in a monospaced font,
with no command interpretation. - To include a non-interpreted string within your
text, use \verbthe text command. You may use !,
or a number of other characters to start and
end the text (the same symbol must be used to
start and end the text).
68Centre Alignment
- Anything appearing within a center environment is
centred on the page. - If you have just one line, such as an image, you
can use - \centerlinecentred line
69Typesetting Haskell
\beginenumerate \item The first\footnotenot
second item \centerlinelambda.pdf \item The
second\footnotenot first item \beginverbatim
let f n n mod 17 in map (\x -gt x f x)
1..10 \endverbatim \endenumerate
70Typesetting Haskell
\beginenumerate \item The first\footnotenot
second item \centerlinelambda.pdf \item The
second\footnotenot first item \beginverbatim
let f n n mod 17 in map (\x -gt x f x)
1..10 \endverbatim \endenumerate
71Elephants and Giraffes
\begindescription \itemElephants Elephants
can be typeset using the \verb\elephant comma
nd. \itemGiraffes Two points should be kept
in mind \beginitemize \item \LaTeX\ offers
no support for giraffes. \item Neither does
Word. \enditemize \enddescription
72Elephants and Giraffes
\begindescription \itemElephants Elephants
can be typeset using the \verb\elephant comma
nd. \itemGiraffes Two points should be kept
in mind \beginitemize \item \LaTeX\ offers
no support for giraffes. \item Neither does
Word. \enditemize \enddescription
73Emphasis and Boldface
- Emphasised text is produced using the \emphtext
command. - Boldface is obtained through the use of
\textbftext. - Rarely used are sans-serif \textsftext, small
caps \textsctext and typewritten \texttttext.
74Bold Elephants in Occam
\textbfDefinition An \emphelephant can be
defined to be a giraffe who should go on a
diet. \textbfDefinition A \emphgiraffe is
nothing but an anorexic elephant. \textsfOccam
implements elephants very efficiently. Note that
\textsfOccam is not written \textscOccam or
\textttOccam!
75Bold Elephants in Occam
\textbfDefinition An \emphelephant can be
defined to be a giraffe who should go on a
diet. \textbfDefinition A \emphgiraffe is
nothing but an anorexic elephant. \textsfOccam
implements elephants very efficiently. Note that
\textsfOccam is not written \textscOccam or
\textttOccam!
76Text, not Word Processing
- Gordon J. Pace
- March 2006
Mathematics
77Some Symbols
- To illustrate the rest of this part, we will
introduce some mathematical symbols. More can be
found on the last few slides. - All mathematics must appear in maths mode but
more about this in a moment - The following symbols can be produced using the
commands \leq, \times, \pi, \infty.
78More Symbols
- Some symbols are used to combine other
mathematical expressions - Powers
- ei\pi -1
- Subscripts
- a_n1 2 \times a_n
- Fractions
- \fracx\pia_25
- Summation
- \sum_i0\infty ai
79Inline Mathematics
- If a mathematical expression appears in a line of
normal text, use a dollar symbol to start and
to end the mathematics. - This ensures that the lines are kept as narrow as
possible to avoid having to change
line spacing drastically.
80Inline Mathematics
- If a mathematical expression appears in a line of
normal text, use a dollar symbol to start and
to end the mathematics. - This ensures that the lines are kept as low as
possible to avoid having to change
line spacing.
It has already been shown that a_n1 2
\times a_n. We can thus conclude that
\fraca_na_0 2n.
81Inline Mathematics
- If a mathematical expression appears in a line of
normal text, use a dollar symbol to start and
to end the mathematics. - This ensures that the lines are kept as low as
possible to avoid having to change
line spacing.
It has already been shown that a_n1 2
\times a_n. We can thus conclude that
\fraca_na_0 2n.
82Large Formulae
- If the mathematical formulae are to appear on a
separate line, start the mathematics using \,
and end it with \.
It has already been shown that a_n1 2
\times a_n. We can thus conclude that
\\fraca_na_0 2n \ Note the difference
from inline mode \fraca_na_0 2n.
83Large Formulae
- If the mathematical formulae are to appear on a
separate line, start the mathematics using \,
and end it with \.
It has already been shown that a_n1 2
\times a_n. We can thus conclude that
\\fraca_na_0 2n \ Note the difference
from inline mode \fraca_na_0 2n.
84Equations
- Quite regularly, one needs equations with aligned
equality signs. The environment eqnarray is used
for this. - Separate lines using \\, and the left hand side,
equality, and right hand side of the equations
using .
85Equations
- Quite regularly, one needs equations with aligned
equality signs. The environment eqnarray is used
for this. - Separate lines using \\, and the left hand side,
equality, and right hand side of the equations
using .
\begineqnarray a_0 1 \\ a_n1
2\times a_n \endeqnarray
86Equations
- Quite regularly, one needs equations with aligned
equality signs. The environment eqnarray is used
for this. - Separate lines using \\, and the left hand side,
equality, and right hand side of the equations
using .
\begineqnarray a_0 1 \\ a_n1
2\times a_n \endeqnarray
87Equations
- Quite regularly, one needs equations with aligned
equality signs. The environment eqnarray is used
for this. - Separate lines using \\, and the left hand side,
equality, and right hand side of the equations
using .
Note that the equations are numbered. If you
dont want this feature, use the eqnarray
environment instead
\begineqnarray a_0 1 \\ a_n1
2\times a_n \endeqnarray
88Some Notes
- Spacing is ignored in math mode x y gives the
same result as xy. - If you need to escape from math mode to include
normal text (eg for the name of a function) use
the command \mboxtext (eg en\mboxfibonacci(
n1)) - Never use math mode to emphasise text because
different gives , not
!
89Some Mathematical Symbols
90Binary Operators
91Relational Operators
92Some Arrows
93Big Symbols
94Greek Letters
95Standard Functions
96Text, not Word Processing
- Gordon J. Pace
- March 2006
Bibliographies
97Simple Bibliographies
- To create the bibliography, use the
thebibliography environment. - Items in the bibliography are added using the
\bibitemlabel command. The label is used to
refer to the entry. - Citing a bibliography item in the main text can
be done using the \citelabel or \citelabel1,
label2, command to obtain citations such as 2
or 7,4.
98Citing Papers the Easy Way
\citealur94,asarin01 talk about
timed-automata, even if \citeasarin01 treats a
particular case of the general case appearing in
\citealur94. \beginthebibliography99 \bibi
temalur94 R. Alur and D.L. Dill, \emphA
theory of timed automata,\/ Theoretical
Computer Science 1261(183--235),
1994. \bibitemasarin01 E. Asarin, G.
Schneider and S. Yovine, \emphOn the
Decidability of the Reachability Problem for
Planar Differential Inclusions,\/ in Lecture
Notes in Computer Science 2034,
2001. \endthebibliography
99Citing Papers the Easy Way
\citealur94,asarin01 talk about
timed-automata, even if \citeasarin01 treats a
particular case of the general case appearing in
\citealur94. \beginthebibliography99 \bibi
temalur94 R. Alur and D.L. Dill, \emphA
theory of timed automata,\/ Theoretical
Computer Science 1261(183--235),
1994. \bibitemasarin01 E. Asarin, G.
Schneider and S. Yovine, \emphOn the
Decidability of the Reachability Problem for
Planar Differential Inclusions,\/ in Lecture
Notes in Computer Science 2034,
2001. \endthebibliography
100Citing Papers the Easy Way
\citealur94,asarin01 talk about
timed-automata, even if \citeasarin01 treats a
particular case of the general case appearing in
\citealur94. \beginthebibliography99 \bibi
temalur94 R. Alur and D.L. Dill, \emphA
theory of timed automata,\/ Theoretical
Computer Science 1261(183--235),
1994. \bibitemasarin01 E. Asarin, G.
Schneider and S. Yovine, \emphOn the
Decidability of the Reachability Problem for
Planar Differential Inclusions,\/ in Lecture
Notes in Computer Science 2034,
2001. \endthebibliography
The number here is used to tell
that no more than 99 entries will appear in the
bibliography
101Citing Papers the Easy Way
CAUTION creates an bibliography
file with all reference information when run
through a file. Run twice to ensure
that references and citations match
\citealur94,asarin01 talk about
timed-automata, even if \citeasarin01 treats a
particular case of the general case Appearing in
\citealur94. \beginthebibliography99 \bibi
temalur94 R. Alur and D.L. Dill, \emphA
theory of timed automata,\/ Theoretical
Computer Science 1261(183--235),
1994. \bibitemasarin01 E. Asarin, G.
Schneider and S. Yovine, \emphOn the
Decidability of the Reachability Problem for
Planar Differential Inclusions,\/ in Lecture
Notes in Computer Science 2034,
2001. \endthebibliography
102The Problems with This
- It is your responsibility to ensure that the
references appear in a standard way (eg all
journal papers start with the author name, have
an emphasised title, etc). - Reuse of bibliographies can be cumbersome.
103Using .
- is an additional tool, which takes
a list of references (generated by ),
a (.bib) file with all the bibliographic entries,
and generates a file with all the reference
entries to be used by .
104Using .
- Run to generate the list of citations.
- Run to obtain the reference
details. - Run to use the reference details.
- Run again to get references right.
105Using .
- Run to generate the list of citations.
- Run to obtain the reference
details. - Run to use the reference details.
- Run again to get references right.
Luckily, WinEdt does this at the click of one
button!
106Using .
- Citations in the file appear as before
using the \cite command. - At the point where you want the references to
appear, use the \bibliographyfile command,
where filename.bib is the name of the file with
the entries.
107Your Will Look Like This
_at_articlealur94, author"R. Alur and D.L.
Dill", title"A theory of timed
automata", journal"Theoretical Computer
Science", year1994, volume126, pages"183--23
5" _at_Bookbird88, author "R. Bird and P.
Wadler", title "Introduction to Functional
Programming", publisher "Prentice Hall
International, New York", year 1988
108Your Will Look Like This
You can either download these entries, type them
in yourself, or use a bibliography database tool
(eg JabRef) to manage them
_at_articlealur94, author"R. Alur and D.L.
Dill", title"A theory of timed
automata", journal"Theoretical Computer
Science", year1994, volume126, pages"183--23
5" _at_Bookbird88, author "R. Bird and P.
Wadler", title "Introduction to Functional
Programming", publisher "Prentice Hall
International, New York", year 1988
109Your Will Look Like This
_at_articlealur94, author"R. Alur and D.L.
Dill", title"A theory of timed
automata", journal"Theoretical Computer
Science", year1994, volume126, pages"183--23
5" _at_Bookbird88, author "R. Bird and P.
Wadler", title "Introduction to Functional
Programming", publisher "Prentice Hall
International, New York", year 1988
uses the entry type (article, book,
etc) to ensure a standard formatting. You dont
need to worry any longer whether its book or
article titles that should appear in italics.
110Using .
- Using will only show the items in
the bibliography referred to in the text. Use the
\nocite command in the file to show
all the items in the bibliography. - If you prefer citations of the form Alu94
instead of 1, add the command
\bibliographystylealpha before the bibliography
in the file.
111Quick and Dirty Bibliographies, or
?
- If youre writing a quick document, with
references you will use only once, dont bother
with . - However, in that case, make sure that your
bibliographic entries appear in a standard way,
and contain all the necessary information. - For a bigger project, even an FYP, I would start
building a database early on to
reduce work later on.
112Go forth and