Introductory L TEX: DR Nicola Talbot
Introductory L TEX: DR Nicola Talbot
Introductory L TEX: DR Nicola Talbot
Dr Nicola Talbot
nlct@cmp.uea.ac.uk
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Summary
• Basic text, punctuation, accents and symbols.
• Simple font changing commands.
• Document classes, sectioning commands, and title pages.
• Centering and one-sided justification.
• Defining new commands.
• Converting to PostScript or Portable Document Format.
• Lists
• Tabulated material.
• Basic mathematics.
• Cross-referencing
Course Materials
• Each participant should have been given a handout.
• In addition, the following material is available on the web:
– On-line version of the slides (HTML and PDF)
– Advice and solutions to the exercises
– Explanations to common errors
– Terminology so that you can check the definition of a keyword.
– PostScript version of the slides
These can be found at:
http://theoval.cmp.uea.ac.uk/˜nlct/latex/csed/csed.html
Some Notes
• At the end of each topic there will be an exercise for you to do to
give you some practical experience with the topic.
• Be sure to read the instructions given in the handout, and pay
particular attention to any Notes.
• If you find yourself struggling, just do the parts of the exercises
marked e . If you’re speeding ahead, try doing the additional bits,
marked ! .
• If you skip ahead, please save your questions until everyone else
reaches that topic.
Some Notes
• At the end of each topic there will be an exercise for you to do to
give you some practical experience with the topic.
• Be sure to read the instructions given in the handout, and pay
particular attention to any Notes.
• If you find yourself struggling, just do the parts of the exercises
marked e . If you’re speeding ahead, try doing the additional bits,
marked ! .
• If you skip ahead, please save your questions until everyone else
reaches that topic.
Some Notes
• At the end of each topic there will be an exercise for you to do to
give you some practical experience with the topic.
• Be sure to read the instructions given in the handout, and pay
particular attention to any Notes.
• If you find yourself struggling, just do the parts of the exercises
marked e . If you’re speeding ahead, try doing the additional bits,
marked ! .
• If you skip ahead, please save your questions until everyone else
reaches that topic.
Some Notes
• At the end of each topic there will be an exercise for you to do to
give you some practical experience with the topic.
• Be sure to read the instructions given in the handout, and pay
particular attention to any Notes.
• If you find yourself struggling, just do the parts of the exercises
marked e . If you’re speeding ahead, try doing the additional bits,
marked ! .
• If you skip ahead, please save your questions until everyone else
reaches that topic.
What is TEX?
• TEX is a typesetting language written by Donald Knuth.
• Original format of TEX called: “plain TEX”.
• Plain TEX easy for simple documents (without equations, chapters
etc).
• Otherwise very tricky.
What is LATEX?
• Leslie Lamport wrote a format of TEX called LATEX.
• Simple documents slightly harder to produce in LATEX than plain
TEX.
• Otherwise much easier to use.
• Since LATEX is a format of TEX, you may get TEX as well as LATEX
error messages.
• We will be using LATEX 2ε version.
• Old LATEX2.09 version very out of date.
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
Programming Languages
C
Java
LATEX
1. Write/edit source code in text file (e.g. HelloWorld.tex)
2. LATEX source code. (e.g. Ilatex HelloWorld.tex)
• If there are errors, return to Step 1.
• If successful, device independent file (DVI) created (e.g.
HelloWorld.dvi)
3. Load DVI file into DVI viewer (e.g. Ixdvi HelloWorld.dvi).
LATEX
1. Write/edit source code in text file (e.g. HelloWorld.tex)
2. LATEX source code. (e.g. Ilatex HelloWorld.tex)
• If there are errors, return to Step 1.
• If successful, device independent file (DVI) created (e.g.
HelloWorld.dvi)
3. Load DVI file into DVI viewer (e.g. Ixdvi HelloWorld.dvi).
Logging On
• We will be using Exceed.
• Exceed allows us to access UNIX computers from Windows NT.
• You should all have an ITCS username and password.
• To run Exceed, double-click on the icon Staff1.
Using UNIX
• UNIX is command line driven.
• Commands are typed in at the command prompt.
• Some simple commands:
ls lists the contents of the current directory.
mkdir makes a new directory. e.g.
Imkdir latex
will create a directory called latex.
cd change directory. e.g.
Icd latex
will change to the directory called latex.
cp copies a file to a new location. We will be using this command
in some of the exercises.
xedit runs the text editor for the X Window System.
Icd ~/.uea-options
Itouch tex
Ilogout
This will exit Exceed, so you will now have to run Exceed again.
• Once you have done this, you don’t need to do it again.
Special Characters
• The following 10 symbols have special meaning and should be
used with care:
% $ # & { } _ ^ ~ \
• The percent symbol % is a comment character. Everything from
the % symbol onwards until the end of the line will be ignored by
LATEX.
Commands (Macros)
• Commands are available to specify how to format parts of the
document.
• Commands are either made up of a single special character (e.g. $)
or a backslash followed by a single symbol (e.g. \=) or a backslash
followed by one or more alphabetical characters (e.g. \today).
• Any spaces following a command name made up of alphabetical
characters are ignored. Notice the difference between
\oe œ
Input Output
and
\o e øe
Input Output
Commands (Macros)
• Commands are available to specify how to format parts of the
document.
• Commands are either made up of a single special character (e.g. $)
or a backslash followed by a single symbol (e.g. \=) or a backslash
followed by one or more alphabetical characters (e.g. \today).
• Any spaces following a command name made up of alphabetical
characters are ignored. Notice the difference between
\oe œ
Input Output
and
\o e øe
Input Output
Commands (Macros)
• Commands are available to specify how to format parts of the
document.
• Commands are either made up of a single special character (e.g. $)
or a backslash followed by a single symbol (e.g. \=) or a backslash
followed by one or more alphabetical characters (e.g. \today).
• Any spaces following a command name made up of alphabetical
characters are ignored. Notice the difference between
\oe œ
Input Output
and
\o e øe
Input Output
Commands (Macros)
• Commands are available to specify how to format parts of the
document.
• Commands are either made up of a single special character (e.g. $)
or a backslash followed by a single symbol (e.g. \=) or a backslash
followed by one or more alphabetical characters (e.g. \today).
• Any spaces following a command name made up of alphabetical
characters are ignored. Notice the difference between
\oe œ
Input Output
and
\o e øe
Input Output
Commands (Macros)
• Commands are available to specify how to format parts of the
document.
• Commands are either made up of a single special character (e.g. $)
or a backslash followed by a single symbol (e.g. \=) or a backslash
followed by one or more alphabetical characters (e.g. \today).
• Any spaces following a command name made up of alphabetical
characters are ignored. Notice the difference between
\oe œ
Input Output
and
\o e øe
Input Output
Commands (Macros)
• Commands are available to specify how to format parts of the
document.
• Commands are either made up of a single special character (e.g. $)
or a backslash followed by a single symbol (e.g. \=) or a backslash
followed by one or more alphabetical characters (e.g. \today).
• Any spaces following a command name made up of alphabetical
characters are ignored. Notice the difference between
\oe œ
Input Output
and
\o e øe
Input Output
Grouping
• Segments of code may be grouped by placing it within { and }
• Most commands occurring within a group will be local to that
group.
man{\oe}uvre manœuvre
Output
Input
Grouping
• Segments of code may be grouped by placing it within { and }
• Most commands occurring within a group will be local to that
group.
man{\oe}uvre manœuvre
Output
Input
Grouping
• Segments of code may be grouped by placing it within { and }
• Most commands occurring within a group will be local to that
group.
man{\oe}uvre manœuvre
Output
Input
Command Arguments
• Some commands take one or more arguments. For example, the
command \textbf takes one argument, and will typeset that
argument in a bold font.
Input
Input
Command Arguments
• Some commands take one or more arguments. For example, the
command \textbf takes one argument, and will typeset that
argument in a bold font.
Input
Input
Optional Arguments
• Some commands have optional arguments.
• Optional arguments are always enclosed in square brackets [ ]:
A new\\[5mm] A new
line.
Input line.
Output
Optional Arguments
• Some commands have optional arguments.
• Optional arguments are always enclosed in square brackets [ ]:
A new\\[5mm] A new
line.
Input line.
Output
Optional Arguments
• Some commands have optional arguments.
• Optional arguments are always enclosed in square brackets [ ]:
A new\\[5mm] A new
line.
Input line.
Output
Environments
• An environment is different to a command.
• \begin{name} indicates the beginning of an environment.
• \end{name} indicates the end of an environment.
\end{sffamily}
Input
Environments
• An environment is different to a command.
• \begin{name} indicates the beginning of an environment.
• \end{name} indicates the end of an environment.
\end{sffamily}
Input
Environments
• An environment is different to a command.
• \begin{name} indicates the beginning of an environment.
• \end{name} indicates the end of an environment.
\end{sffamily}
Input
Environments
• An environment is different to a command.
• \begin{name} indicates the beginning of an environment.
• \end{name} indicates the end of an environment.
\end{sffamily}
Input
Environments
• An environment is different to a command.
• \begin{name} indicates the beginning of an environment.
• \end{name} indicates the end of an environment.
\end{sffamily}
Input
Environments
• An environment is different to a command.
• \begin{name} indicates the beginning of an environment.
• \end{name} indicates the end of an environment.
\end{sffamily}
Input
Spaces
• Consecutive spaces are treated as one single space.
Spaces
• Consecutive spaces are treated as one single space.
Spaces
• Consecutive spaces are treated as one single space.
Spaces
• Consecutive spaces are treated as one single space.
Paragraphs
• Completely blank lines indicate the end of a paragraph.
Input
Creating a Document
• At the start of any LATEX 2ε file, you must have the command
\documentclass[options]{class}
Creating a Document
• At the start of any LATEX 2ε file, you must have the command
\documentclass[options]{class}
Creating a Document
All LATEX documents must have the following three lines:
\documentclass[a4paper,12pt]{article}
\begin{document}
\end{document}
Note that the text in blue may change, but the rest must occur exactly
as above.
z
\textrm{text} \textrm{Roman} Roman
Family
}|
\textsf{text} \textsf{Sans serif} Sans serif
\texttt{text} \texttt{typewriter} typewriter
{ z }| { z
Weight
\textmd{text} \textmd{medium} medium
\textbf{text} \textbf{bold} bold
Shape
}|
\textsl{text} \textsl{slanted} slanted
\textsc{text} \textsc{Small Caps} Small Caps
\emph{text} \emph{emphasized} emphasized
{
\textnormal{text} \textnormal{default} default
z
\rmfamily \rmfamily Roman Roman
Family
}|
\sffamily \sffamily Sans serif Sans serif
\ttfamily \ttfamily typewriter typewriter
{ z }| { z
Weight
\mdseries \mdseries medium medium
\bfseries \bfseries bold bold
\upshape \upshape upright upright
\itshape \itshape italic italic
Shape
}|
\slshape \slshape slanted slanted
\scshape \scshape Small Caps Small Caps
\em \em emphasized emphasized
{
\normalfont \normalfont default default
Input
Input
Input
Input
Input
Input Output
\end{footnotesize}
Input
\end{tiny}
Back to normal.
Input
Symbols
Remember the special characters? What if you actually want those
characters to appear? And what about other symbols not on your
keyboard?
Examples of Symbols
2. A, B \& C A, B & C
Input Output
Punctuation Symbols
• Standard punctuation characters can be entered as normal: , .
; : ? !
• Some symbols are obtained through a particular combination of
characters.
Foreign
Quotes Dashes
Punctation
‘ ‘ - - hyphen ?‘ ¿
’ ’ -- – en dash !‘ ¡
‘‘ “ --- — em dash
’’ ” $-$ − minus
• A thin space \, can be used to separate a single quote from a
double quote. For example, ’\,’’ produces ’ ”
Examples
Accents
The accent commands place the required accent over or under the
specified character.
Example Example
Definition Input Output Definition Input Output
\’{object} \’{c} ć \={object} \={c} c̄
\‘{object} \‘{c} c̀ \.{object} \.{c} ċ
\^{object} \^{c} ĉ \~{object} \~{c} c̃
\"{object} \"{c} c̈ \v{object} \v{c} č
\u{object} \u{c} c̆ \H{object} \H{c} c̋
\t{object} \t{cc} cc \c{object} \c{c} ç
\d{object} \d{c} c. \b{object} \b{c} c
¯
1. Caf\’e Café
Input Output
2. R\^ole Rôle
Input Output
3. P\^at\’e Pâté
Input Output
4. Na\"{\i}ve Naı̈ve
Input Output
Ligatures
Foreign Symbols
\AA Å \aa å \L L \l l
\O Ø \o ø \SS SS \ss ß
1. Man{\oe}uvre Manœuvre
Input Output
2. {\AE}olian Æolian
Input Output
3. {\OE}sophagus Œsophagus
Input Output
4. fluffier fluffier
Input Output
Document Classes
• As we have already seen, the document class is specified using the
command:
\documentclass[option-list]{class}
• There are many class files available. The standard ones are:
article report book slides letter
• Which class file should I use?
☞ What kind of document do you want to write?
☞ Do you need an abstract? (article or report class)
☞ Do you want only sections (article class), or do you need
chapters as well (report or book class)?
Document Classes
• As we have already seen, the document class is specified using the
command:
\documentclass[option-list]{class}
• There are many class files available. The standard ones are:
article report book slides letter
Document Classes
• As we have already seen, the document class is specified using the
command:
\documentclass[option-list]{class}
• There are many class files available. The standard ones are:
article report book slides letter
• Which class file should I use?
☞ What kind of document do you want to write?
☞ Do you need an abstract? (article or report class)
☞ Do you want only sections (article class), or do you need
chapters as well (report or book class)?
Document Classes
• As we have already seen, the document class is specified using the
command:
\documentclass[option-list]{class}
• There are many class files available. The standard ones are:
article report book slides letter
• Which class file should I use?
☞ What kind of document do you want to write?
☞ Do you need an abstract? (article or report class)
☞ Do you want only sections (article class), or do you need
chapters as well (report or book class)?
Document Classes
• As we have already seen, the document class is specified using the
command:
\documentclass[option-list]{class}
• There are many class files available. The standard ones are:
article report book slides letter
• Which class file should I use?
☞ What kind of document do you want to write?
☞ Do you need an abstract? (article or report class)
☞ Do you want only sections (article class), or do you need
chapters as well (report or book class)?
Document Classes
• As we have already seen, the document class is specified using the
command:
\documentclass[option-list]{class}
• There are many class files available. The standard ones are:
article report book slides letter
• Which class file should I use?
☞ What kind of document do you want to write?
☞ Do you need an abstract? (article or report class)
☞ Do you want only sections (article class), or do you need
chapters as well (report or book class)?
1. \section{Introduction} 1 Introduction
\LaTeX\ documents
are\ldots LATEX documents are. . .
Output
Input
3. \section*{Unnumbered Unnumbered
Sections}
Sections
Input
Output
Abstract
• Some class files such as article and report define an abstract
environment.
• Example:
\begin{abstract} Abstract
This is the body of This is the body
the abstract. of the abstract. The
The format depends format depends on
on the class the class file you use.
file you use. Output
\end{abstract}
Input
Title Page
• To create a title page, you first need to store information using
the commands:
\author{Author Names}
\title{Document Title}
\date{Date}
• The information is then displayed using the command:
\maketitle
N.L.C. Talbot
\maketitle
Input
November 2003
Output
Appendices
Example
\appendix A Tables
\section{Tables}
This is the first appendix. This is the first appendix.
\section{Proofs}
This is the second
B Proofs
appendix. This is the second ap-
Input pendix.
Output
Table of Contents
• The table of contents can be produced using the command:
\tableofcontents
• The sectioning commands write information to the table of
contents file (.toc).
• Next time you LATEX your document, the table of contents file will
be read, and the contents page will be generated.
• If you have a particularly long chapter or section title, you can use
the optional argument of the sectioning command to specify a
shorter title for the contents.
• The \tableofcontents command is usually placed after the
\maketitle command.
Table of Contents
• The table of contents can be produced using the command:
\tableofcontents
• The sectioning commands write information to the table of
contents file (.toc).
• Next time you LATEX your document, the table of contents file will
be read, and the contents page will be generated.
• If you have a particularly long chapter or section title, you can use
the optional argument of the sectioning command to specify a
shorter title for the contents.
• The \tableofcontents command is usually placed after the
\maketitle command.
Table of Contents
• The table of contents can be produced using the command:
\tableofcontents
• The sectioning commands write information to the table of
contents file (.toc).
• Next time you LATEX your document, the table of contents file will
be read, and the contents page will be generated.
• If you have a particularly long chapter or section title, you can use
the optional argument of the sectioning command to specify a
shorter title for the contents.
• The \tableofcontents command is usually placed after the
\maketitle command.
Table of Contents
• The table of contents can be produced using the command:
\tableofcontents
• The sectioning commands write information to the table of
contents file (.toc).
• Next time you LATEX your document, the table of contents file will
be read, and the contents page will be generated.
• If you have a particularly long chapter or section title, you can use
the optional argument of the sectioning command to specify a
shorter title for the contents.
• The \tableofcontents command is usually placed after the
\maketitle command.
Table of Contents
• The table of contents can be produced using the command:
\tableofcontents
• The sectioning commands write information to the table of
contents file (.toc).
• Next time you LATEX your document, the table of contents file will
be read, and the contents page will be generated.
• If you have a particularly long chapter or section title, you can use
the optional argument of the sectioning command to specify a
shorter title for the contents.
• The \tableofcontents command is usually placed after the
\maketitle command.
Page Styles
• Page numbers appear automatically
• By default, in the article class file the page numbers appear
centred in the footer.
• The page style (how headers and footers appear) can be changed
using the command:
\pagestyle{style}
• The most common styles are: plain, empty and headings.
• The style for the current page only can be set using:
\thispagestyle{style}
Page Styles
• Page numbers appear automatically
• By default, in the article class file the page numbers appear
centred in the footer.
• The page style (how headers and footers appear) can be changed
using the command:
\pagestyle{style}
• The most common styles are: plain, empty and headings.
• The style for the current page only can be set using:
\thispagestyle{style}
Page Styles
• Page numbers appear automatically
• By default, in the article class file the page numbers appear
centred in the footer.
• The page style (how headers and footers appear) can be changed
using the command:
\pagestyle{style}
• The most common styles are: plain, empty and headings.
• The style for the current page only can be set using:
\thispagestyle{style}
Page Styles
• Page numbers appear automatically
• By default, in the article class file the page numbers appear
centred in the footer.
• The page style (how headers and footers appear) can be changed
using the command:
\pagestyle{style}
• The most common styles are: plain, empty and headings.
• The style for the current page only can be set using:
\thispagestyle{style}
Page Styles
• Page numbers appear automatically
• By default, in the article class file the page numbers appear
centred in the footer.
• The page style (how headers and footers appear) can be changed
using the command:
\pagestyle{style}
• The most common styles are: plain, empty and headings.
• The style for the current page only can be set using:
\thispagestyle{style}
Paragraph Formatting
Examples (environments)
1.
\end{flushright}
Input
Input
Examples (declarations)
The justification declarations must be applied to whole paragraphs.
1. Justification applied to entire paragraph:
\centerline{text}
Example:
New Lines
• To force a new line: \\[length] or \newline
Input
Line breaks
• To break a line but keeping the text fully justified use:
\linebreak[n]
Input
Unbreakable Spaces
Alternatively, use a tilde ~ to produce a space that can not be broken
by a new line. For example:
Input
Input
Page Breaks
• To force a ragged page break, use:
\newpage
• To force a vertically justified page break, use:
\pagebreak[n]
• To prevent a page break, use:
\nopagebreak[n]
• To force a page break, and process all unprocessed floats, use:
\clearpage
The \envname{abstract}
environment\ldots
Input
Examples
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
PostScript
• DVI files can be converted to PostScript using dvips:
Idvips -o filename.ps filename.dvi
• The PostScript file can either be sent directly to a PostScript
printer, or can be loaded into ghostview where you can preview it
and send it to a non-PostScript printer.
• If you use dvips you can:
☞ Use the pstricks package and create some very fancy graphics.
☞ Incorporate PostScript commands into your document.
☞ Use the psutils suite:
– Rearrange pages (psbook)
– Print multiple logical pages on a single sheet (psnup)
– Convert, e.g., US letter documents to A4 paper (psresize)
Exercise 7 (Page 8)
• Try converting the document that you modified in Exercise 4
(sectioning.tex) into a PostScript file.
Idvips -o sectioning.ps sectioning
• Now view it using ghostview:
Ighostview sectioning.ps
• Try using PDFLATEX to generate a PDF version of this document:
Ipdflatex sectioning.tex
Ixpdf sectioning.pdf
Numbered Lists
The enumerate environment produces an ordered list.
\begin{enumerate}
1. The first item
\item The first item
\item The second item 2. The second item
\item The third item 3. The third item
\end{enumerate} Output
Input
\begin{enumerate}
1. The first item
\item The first item
(a) First item of nested list
\begin{enumerate}
\item First item (b) Second item of nested
of nested list list
\item Second item 2. The second item
of nested list Output
\end{enumerate}
\item The second item
\end{enumerate}
Input
\begin{enumerate}
1. The first item
\item The first item
• First item of nested list
\begin{itemize}
\item First item • Second item of nested
of nested list list
\item Second item 2. The second item
of nested list Output
\end{itemize}
\item The second item
\end{enumerate}
Input
Description
Tabulated Material
• Material can be aligned in rows and columns using the tabular
environment:
\begin{tabular}{column specifiers}
Each column is specified by one of the following letters: l (left
aligned) c (centred) or r (right aligned).
Examples:
1. \begin{tabular}{ccc}
Three columns, all centred.
2. \begin{tabular}{lr}
Two columns, the first left justified, the second right justified.
Tabulated Material
• Material can be aligned in rows and columns using the tabular
environment:
\begin{tabular}{column specifiers}
Each column is specified by one of the following letters: l (left
aligned) c (centred) or r (right aligned).
Examples:
1. \begin{tabular}{ccc}
Three columns, all centred.
2. \begin{tabular}{lr}
Two columns, the first left justified, the second right justified.
Tabulated Material
• Material can be aligned in rows and columns using the tabular
environment:
\begin{tabular}{column specifiers}
Each column is specified by one of the following letters: l (left
aligned) c (centred) or r (right aligned).
Examples:
1. \begin{tabular}{ccc}
Three columns, all centred.
2. \begin{tabular}{lr}
Two columns, the first left justified, the second right justified.
Tabulated Material
• Material can be aligned in rows and columns using the tabular
environment:
\begin{tabular}{column specifiers}
Each column is specified by one of the following letters: l (left
aligned) c (centred) or r (right aligned).
Examples:
1. \begin{tabular}{ccc}
Three columns, all centred.
2. \begin{tabular}{lr}
Two columns, the first left justified, the second right justified.
• Within the tabular environment:
– The special character & moves to the next column.
– The new line command \\ is used to move on to the next row.
Tabulated Material
• Material can be aligned in rows and columns using the tabular
environment:
\begin{tabular}{column specifiers}
Each column is specified by one of the following letters: l (left
aligned) c (centred) or r (right aligned).
Examples:
1. \begin{tabular}{ccc}
Three columns, all centred.
2. \begin{tabular}{lr}
Two columns, the first left justified, the second right justified.
• Within the tabular environment:
– The special character & moves to the next column.
– The new line command \\ is used to move on to the next row.
Simple Example
• This example has only 2 columns
• So each row can have no more than 1 &
• Column 1 is left justified, column 2 is centred.
Input
Example
\begin{tabular}{|l|c|}
\hline Item Cost
Item & Cost\\ CD £11.75
\hline\hline
Video £14.10
CD & \pounds 11.75\\
Video & \pounds 14.10\\ Total £25.85
\hline Output
Spanning Columns
• An entry can span several columns:
\multicolumn{cols}{align}{text}
• cols is the number of columns to be spanned.
• align is the alignment for this entry. This can only contain one
alignment letter (e.g. c), but can also contain vertical bar
specifiers.
• text The text for this entry.
• Can also be used to change the specification for a single column.
\begin{tabular}{|l|cc|}\hline
& \multicolumn{2}{c|}{Cost}\\
Item & ex VAT & inc VAT (@17.5\%)\\\hline\hline
CD & \pounds 10.00 & \pounds 11.75\\
Video & \pounds 12.00 & \pounds 14.10\\\hline
\multicolumn{1}{l|}{Total} & \pounds 22.00 &
\pounds 25.85\\\cline{2-3}
\end{tabular}
Input
Cost
Item ex VAT inc VAT (@17.5%)
CD £10.00 £11.75
Video £12.00 £14.10
Total £22.00 £25.85
Output
• When creating tables, it’s best to start with a simple table, and
then add to it.
e Try creating the output shown in Figure 6 on page 10
! Try creating the output shown in Figure 7 on page 10.
• The table is created using just one tabular environment. The lines
Equipment Expenditure and Travel Expenditure span all 5
columns.
• Once you’ve finished it, centre the table, using the \centerline
command.
Basic Mathematics
• TEX has two modes:
1. Text mode
2. Maths mode
• So far we have only been using text mode.
• All maths must be placed in maths mode, as the fonts and
spacing are different.
– Text mode: y-c=mx
– Maths mode: y − c = mx
• There are two types of maths: in-line maths and displayed maths
In-Line Mathematics
• In-line maths occurs within a line of text.
P
• Symbols such as are small so that it doesn’t take up to much
space.
• Can be broken across a line.
• For in-line maths, use the math environment:
\begin{math}
...
\end{math}
• Shorthand notation: \( ... \)
• Even shorter notation: $ ...$
Another special character!
In-Line Mathematics
• In-line maths occurs within a line of text.
P
• Symbols such as are small so that it doesn’t take up to much
space.
• Can be broken across a line.
• For in-line maths, use the math environment:
\begin{math}
...
\end{math}
• Shorthand notation: \( ... \)
• Even shorter notation: $ ...$
Another special character!
In-Line Mathematics
• In-line maths occurs within a line of text.
P
• Symbols such as are small so that it doesn’t take up to much
space.
• Can be broken across a line.
• For in-line maths, use the math environment:
\begin{math}
...
\end{math}
• Shorthand notation: \( ... \)
• Even shorter notation: $ ...$
Another special character!
In-Line Mathematics
• In-line maths occurs within a line of text.
P
• Symbols such as are small so that it doesn’t take up to much
space.
• Can be broken across a line.
• For in-line maths, use the math environment:
\begin{math}
...
\end{math}
• Shorthand notation: \( ... \)
• Even shorter notation: $ ...$
Another special character!
In-Line Mathematics
• In-line maths occurs within a line of text.
P
• Symbols such as are small so that it doesn’t take up to much
space.
• Can be broken across a line.
• For in-line maths, use the math environment:
\begin{math}
...
\end{math}
• Shorthand notation: \( ... \)
• Even shorter notation: $ ...$
Another special character!
In-Line Mathematics
• In-line maths occurs within a line of text.
P
• Symbols such as are small so that it doesn’t take up to much
space.
• Can be broken across a line.
• For in-line maths, use the math environment:
\begin{math}
...
\end{math}
• Shorthand notation: \( ... \)
• Even shorter notation: $ ...$
Another special character!
Examples
Displayed Mathematics
• Displayed maths is placed on a line of its own so that it stands out
better.
X
• Symbols such as are larger.
• Lots of different environments go into displayed math mode.
• Basic ones:
1. The displaymath environment displays a single unnumbered
line of maths.
\begin{displaymath} ... \end{displaymath}
Shorthand: \[ ... \]
2. The equation environment displays a single numbered line of
maths.
\begin{equation} ... \end{equation}
Displayed Mathematics
• Displayed maths is placed on a line of its own so that it stands out
better.
X
• Symbols such as are larger.
• Lots of different environments go into displayed math mode.
• Basic ones:
1. The displaymath environment displays a single unnumbered
line of maths.
\begin{displaymath} ... \end{displaymath}
Shorthand: \[ ... \]
2. The equation environment displays a single numbered line of
maths.
\begin{equation} ... \end{equation}
Displayed Mathematics
• Displayed maths is placed on a line of its own so that it stands out
better.
X
• Symbols such as are larger.
• Lots of different environments go into displayed math mode.
• Basic ones:
1. The displaymath environment displays a single unnumbered
line of maths.
\begin{displaymath} ... \end{displaymath}
Shorthand: \[ ... \]
2. The equation environment displays a single numbered line of
maths.
\begin{equation} ... \end{equation}
Displayed Mathematics
• Displayed maths is placed on a line of its own so that it stands out
better.
X
• Symbols such as are larger.
• Lots of different environments go into displayed math mode.
• Basic ones:
1. The displaymath environment displays a single unnumbered
line of maths.
\begin{displaymath} ... \end{displaymath}
Shorthand: \[ ... \]
2. The equation environment displays a single numbered line of
maths.
\begin{equation} ... \end{equation}
Displayed Mathematics
• Displayed maths is placed on a line of its own so that it stands out
better.
X
• Symbols such as are larger.
• Lots of different environments go into displayed math mode.
• Basic ones:
1. The displaymath environment displays a single unnumbered
line of maths.
\begin{displaymath} ... \end{displaymath}
Shorthand: \[ ... \]
2. The equation environment displays a single numbered line of
maths.
\begin{equation} ... \end{equation}
Displayed Mathematics
• Displayed maths is placed on a line of its own so that it stands out
better.
X
• Symbols such as are larger.
• Lots of different environments go into displayed math mode.
• Basic ones:
1. The displaymath environment displays a single unnumbered
line of maths.
\begin{displaymath} ... \end{displaymath}
Shorthand: \[ ... \]
2. The equation environment displays a single numbered line of
maths.
\begin{equation} ... \end{equation}
Examples
Input
Input
Examples
A quadratic function:
\[f(x) = a_0 + a_1 x + a_2 x^2\]
Input
A quadratic function:
f (x) = a0 + a1 x + a2 x2
Output
Function Names
\arccos \arcsin \arctan \arg \cos \cosh
\cot \coth \csc \deg \det \dim
\exp \gcd \hom \inf \ker \lg
\lim \liminf \limsup \ln \log \max
\min \Pr \sec \sin \sinh \sup
\tan \tanh
Wrong: $log x$ logx
Correct: $\log x$ log x
Commands in blue indicate commands that can take a limit which can
be specified using the command.
Examples
\begin{displaymath}
\exp(ix) = \sin(x) + i\cos(x)
exp(ix) = sin(x)+i cos(x)
\end{displaymath}
Output
Input
\begin{displaymath}
\lim_{x \rightarrow 0} f(x)
lim f (x)
\end{displaymath} x→0
Input Output
\begin{displaymath}
e^{i\theta} = \cos\theta
eiθ = cos θ + i sin θ
+ i\sin\theta
Output
\end{displaymath}
Input
T \ S [ J K
\bigcap \bigcup \bigodot
N O L M F G
\bigotimes \bigoplus \bigsqcup
U ] W _ V ^
\biguplus \bigvee \bigwedge
a Z I
` R H
\coprod \int \oint
Q Y P X
\prod \sum
Examples
\begin{displaymath}
f(x) = \sum_{i=0}^{n} n
X
\alpha_i x^i f (x) = αi xi
i=0
\end{displaymath}
Output
Input
Pn i
In text : In text : f (x) = i=0 αi x
\begin{math} Output
f(x) = \sum_{i=0}^n
\alpha_i x^i
\end{math}
Input
Delimiters
• Placing brackets around a tall object in maths mode, such as
fractions, does not look right if you use normal sized brackets. For
example:
\begin{displaymath}
1
(\frac{1}{1+x}) ( )
1+x
\end{displaymath}
Output
Input
Delimiters
• Placing brackets around a tall object in maths mode, such as
fractions, does not look right if you use normal sized brackets. For
example:
\begin{displaymath}
1
(\frac{1}{1+x}) ( )
1+x
\end{displaymath}
Output
Input
Delimiters
• Placing brackets around a tall object in maths mode, such as
fractions, does not look right if you use normal sized brackets. For
example:
\begin{displaymath}
1
(\frac{1}{1+x}) ( )
1+x
\end{displaymath}
Output
Input
Delimiters
( ( ) ) [ [ ] ]
\{ { \} } | | \| k
/ / \backslash \ \langle h \rangle i
\lfloor b \rfloor c \lceil d \rceil e
\uparrow ↑ \downarrow ↓ \Uparrow ⇑ \Downarrow ⇓
\updownarrow l \Updownarrow m
Examples
\begin{displaymath}
\left( 1
\frac{1}{1+x} 1+x
\right) Output
\end{displaymath}
Input
\begin{displaymath}
1
\left|
1 + x
\frac{1}{1+x}
\right| Output
\end{displaymath}
Input
Arrays
• Arrays can be created using the array environment.
• Similar to the tabular environment, but must be in maths mode.
• Elements are arranged in rows and columns to form mathematical
structures such as vectors and matrices.
\begin{displaymath}
\begin{array}{cc}
0 1
0 & 1 \\
2 & 3 2 3
\end{array} Output
\end{displaymath}
Input
\begin{displaymath}
\left (
0 1
\begin{array}{cc}
0 & 1 \\ 2 3
2 & 3
Output
\end{array}
\right )
\end{displaymath}
Input
\begin{displaymath}
\left[
0 1
\begin{array}{cc}
0 & 1 \\ 2 3
2 & 3 Output
\end{array}
\right\}
\end{displaymath}
Input
\begin{displaymath}
f(x) =
0 x≤0
\left \{ f (x) =
1 x>0
\begin{array}{cl}
0 & x \leq 0 \\ Output
1 & x > 0
\end{array}
\right .
\end{displaymath}
Input
\cdots ···
..
\vdots .
..
\ddots .
\neq 6=
Multiline Formulæ
• The displaymath and equation environments only allow one line of
mathematics.
• The eqnarray environment allows multiple equations to be aligned.
• The eqnarray environment has three columns: the first is right
aligned, the second is centrally aligned and the third is left aligned.
• Each line is numbered in the eqnarray environment.
• The eqnarray* environment is unnumbered.
• To suppress line numbering in the eqnarray, use the command
\nonumber on the appropriate line.
Multiline Formulæ
• The displaymath and equation environments only allow one line of
mathematics.
• The eqnarray environment allows multiple equations to be aligned.
• The eqnarray environment has three columns: the first is right
aligned, the second is centrally aligned and the third is left aligned.
• Each line is numbered in the eqnarray environment.
• The eqnarray* environment is unnumbered.
• To suppress line numbering in the eqnarray, use the command
\nonumber on the appropriate line.
Multiline Formulæ
• The displaymath and equation environments only allow one line of
mathematics.
• The eqnarray environment allows multiple equations to be aligned.
• The eqnarray environment has three columns: the first is right
aligned, the second is centrally aligned and the third is left aligned.
• Each line is numbered in the eqnarray environment.
• The eqnarray* environment is unnumbered.
• To suppress line numbering in the eqnarray, use the command
\nonumber on the appropriate line.
Multiline Formulæ
• The displaymath and equation environments only allow one line of
mathematics.
• The eqnarray environment allows multiple equations to be aligned.
• The eqnarray environment has three columns: the first is right
aligned, the second is centrally aligned and the third is left aligned.
• Each line is numbered in the eqnarray environment.
• The eqnarray* environment is unnumbered.
• To suppress line numbering in the eqnarray, use the command
\nonumber on the appropriate line.
Multiline Formulæ
• The displaymath and equation environments only allow one line of
mathematics.
• The eqnarray environment allows multiple equations to be aligned.
• The eqnarray environment has three columns: the first is right
aligned, the second is centrally aligned and the third is left aligned.
• Each line is numbered in the eqnarray environment.
• The eqnarray* environment is unnumbered.
• To suppress line numbering in the eqnarray, use the command
\nonumber on the appropriate line.
Multiline Formulæ
• The displaymath and equation environments only allow one line of
mathematics.
• The eqnarray environment allows multiple equations to be aligned.
• The eqnarray environment has three columns: the first is right
aligned, the second is centrally aligned and the third is left aligned.
• Each line is numbered in the eqnarray environment.
• The eqnarray* environment is unnumbered.
• To suppress line numbering in the eqnarray, use the command
\nonumber on the appropriate line.
\begin{eqnarray}
\ln(f(x)) & = & x^2 + \frac{1}{x+3}\\
f(x) & = & \exp \left ( x^2
+ \frac{1}{x+3} \right )
\end{eqnarray}
Input
1
ln(f (x)) = x2 + (2)
x+3
1
f (x) = exp x2 + (3)
x+3
Output
\begin{eqnarray}
\ln(f(x)) & = & x^2 + \frac{1}{x+3} \nonumber\\
f(x) & = & \exp \left ( x^2
+ \frac{1}{x+3} \right )
\end{eqnarray}
Input
1
ln(f (x)) = x2 +
x+3
1
f (x) = exp x2 + (4)
x+3
Output
Cross-Referencing
• Assign a textual label using \label{string}
Example:
\section{Introduction}
\label{sec:intro}
Example:
\begin{equation}
E = mc^2
\label{eqn:einstein}
\end{equation}
Cross-Referencing
• Assign a textual label using \label{string}
Example:
\section{Introduction}
\label{sec:intro}
Example:
\begin{equation}
E = mc^2
\label{eqn:einstein}
\end{equation}
Cross-Referencing
• Assign a textual label using \label{string}
Example:
\section{Introduction}
\label{sec:intro}
Example:
\begin{equation}
E = mc^2
\label{eqn:einstein}
\end{equation}
Cross-Referencing
• Assign a textual label using \label{string}
Example:
\section{Introduction}
\label{sec:intro}
Example:
\begin{equation}
E = mc^2
\label{eqn:einstein}
\end{equation}
• Refer to the object using \ref{string}.
• Refer to the page that the object is on using \pageref{string}.
Cross-Referencing
• Assign a textual label using \label{string}
Example:
\section{Introduction}
\label{sec:intro}
Example:
\begin{equation}
E = mc^2
\label{eqn:einstein}
\end{equation}
• Refer to the object using \ref{string}.
• Refer to the page that the object is on using \pageref{string}.
Examples
\section{Introduction} 1 Introduction
\label{sec:intro} . . . See Section 1 for
\ldots a brief introduction.
See Section~\ref{sec:intro} Output
Examples
See Appendix~\ref{apd:tables} See Appendix A for
for tables\ldots tables. . .
\appendix
\section{Tables}\label{apd:tables} A Tables
Output
Input
\begin{equation}
\label{eqn:Emc} E = mc2 (5)
E = mc^2
. . . See Equation 5 on
\end{equation}
page 253.
\ldots
Output
See Equation~\ref{eqn:Emc}
on page~\pageref{eqn:Emc}.
Input
Packages
• Packages are files with the extension .sty
• Packages can redefine existing commands, or provide new
commands.
• To include a package in your document:
\usepackage[options]{package-name}
Packages
• Packages are files with the extension .sty
• Packages can redefine existing commands, or provide new
commands.
• To include a package in your document:
\usepackage[options]{package-name}
Packages
• Packages are files with the extension .sty
• Packages can redefine existing commands, or provide new
commands.
• To include a package in your document:
\usepackage[options]{package-name}
Packages
• Packages are files with the extension .sty
• Packages can redefine existing commands, or provide new
commands.
• To include a package in your document:
\usepackage[options]{package-name}
Examples
• The babel package redefines names such as “Chapter” to another
language.
• ukdate redefines \today, as does datetime.
• xr defines a new command
\externaldocument{filename}
Examples
• The babel package redefines names such as “Chapter” to another
language.
• ukdate redefines \today, as does datetime.
• xr defines a new command
\externaldocument{filename}
Examples
• The babel package redefines names such as “Chapter” to another
language.
• ukdate redefines \today, as does datetime.
• xr defines a new command
\externaldocument{filename}
Examples
• The babel package redefines names such as “Chapter” to another
language.
• ukdate redefines \today, as does datetime.
• xr defines a new command
\externaldocument{filename}
Examples cont.
• hyperref defines commands that allows you to have active links in your
document if used in combination with PDFLATEX. E.g.
Input
Examples cont.
• hyperref defines commands that allows you to have active links in your
document if used in combination with PDFLATEX. E.g.
Input
Example
\today
\end{document}
Input
\begin{document}
\today
\end{document}
Input
Example
\today
\end{document}
Input
\begin{document}
\today
\end{document}
Input
Self-Extracting Documentation
• Packages not currently on your TEX installation can be
downloaded from the TEX archive.
• Increasingly packages are bundled up with their documentation in
a file with the extension .dtx
• The package should also come with a driver or installation script
(.ins)
• The documentation can usually be obtained by LATEXing the .dtx
file. For example:
Ilatex datetime.dtx
• The package can be extracted by LATEXing the installation script.
For example:
Ilatex datetime.ins
Self-Extracting Documentation
• Packages not currently on your TEX installation can be
downloaded from the TEX archive.
• Increasingly packages are bundled up with their documentation in
a file with the extension .dtx
• The package should also come with a driver or installation script
(.ins)
• The documentation can usually be obtained by LATEXing the .dtx
file. For example:
Ilatex datetime.dtx
• The package can be extracted by LATEXing the installation script.
For example:
Ilatex datetime.ins
Self-Extracting Documentation
• Packages not currently on your TEX installation can be
downloaded from the TEX archive.
• Increasingly packages are bundled up with their documentation in
a file with the extension .dtx
• The package should also come with a driver or installation script
(.ins)
• The documentation can usually be obtained by LATEXing the .dtx
file. For example:
Ilatex datetime.dtx
• The package can be extracted by LATEXing the installation script.
For example:
Ilatex datetime.ins
Self-Extracting Documentation
• Packages not currently on your TEX installation can be
downloaded from the TEX archive.
• Increasingly packages are bundled up with their documentation in
a file with the extension .dtx
• The package should also come with a driver or installation script
(.ins)
• The documentation can usually be obtained by LATEXing the .dtx
file. For example:
Ilatex datetime.dtx
• The package can be extracted by LATEXing the installation script.
For example:
Ilatex datetime.ins
Self-Extracting Documentation
• Packages not currently on your TEX installation can be
downloaded from the TEX archive.
• Increasingly packages are bundled up with their documentation in
a file with the extension .dtx
• The package should also come with a driver or installation script
(.ins)
• The documentation can usually be obtained by LATEXing the .dtx
file. For example:
Ilatex datetime.dtx
• The package can be extracted by LATEXing the installation script.
For example:
Ilatex datetime.ins
Citations
• thebibliography environment
\begin{thebibliography}{2}
\end{thebibliography}
• Use \cite[text]{key-list} to cite a reference in the bibliography
Example
Addison-Wesley, 1993.
\end{thebibliography}
Input
BibTEX
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Author Format
Authors should be entered in one of the following formats:
Examples:
Entry Output (“abbrv” style)
"Alex Thomas von Neumann" A.T. von Neumann
"John Chris {Smith Jones}" J.C. Smith Jones
"van de Klee, Mary-Jane" M.-J. van de Klee
"Smith, Jr, Fred John" F.J. Smith, Jr
"Maria {\uppercase{d}e La} Cruz" M. De La Cruz
Compare last example with:
"Maria De La Cruz" M. D. L. Cruz (Incorrect!)
Multiple Authors
Multiple authors should be separated by the keyword and
@book{goossens97,
author = "Goossens, Michel and Rahtz, Sebastian and
Mittelbach, Frank",
title = "The \LaTeX\ graphics companion: illustrating
documents with \TeX\ and {PostScript}",
publisher = "Addison Wesley Longman, Inc",
year = 1997
}
Month Entries
• Bibliography styles always have three-letter abbreviations for
months: jan, feb, mar, . . .
• Always use these abbreviations for consistency.
@inproceedings{talbot97,
author = "Talbot, Nicola and Cawley, Gavin",
title = "A fast index assignment algorithm for
robust vector quantisation of image data",
booktitle = "Proceedings of the I.E.E.E. International
Conference on Image Processing",
address = "Santa Barbara, California, USA",
month = oct,
year = 1997
}
Example (incollection)
@incollection{wainwright,
author = "Wainwright, Robert B.",
title = "Hazards from {Northern} Native Foods",
booktitle = "\emph{Clostridium botulinum}: Ecology and
Control in Foods",
chapter = 12,
pages = "305--322",
editor = "Hauschild, Andreas H. W. and Dodds,
Karen L.",
publisher = "Marcel Dekker, Inc",
year = 1993
}
Example
In filename.tex (where database.bib contains the bibliography
database):
This is the document \ldots
\bibliographystyle{plain}
\bibliography{database}
Input
LATEX/BibTEX Process
LATEX
.tex - .aux .bib .bst
BibTEX
?
LATEX
.bbl
\bibliographystyle{plain}
[1] Gavin C. Cawley and Nicola L. C. Talbot. A fast index assignment
algorithm for vector quantization over noisy transmission channels.
I.E.E. Electronic Letters, 32(15):1343–1344, July 1996.
\bibliographystyle{alpha}
[CT96 ] Gavin C. Cawley and Nicola L. C. Talbot. A fast index assignment
algorithm for vector quantization over noisy transmission channels.
I.E.E. Electronic Letters, 32(15):1343–1344, July 1996.
[Kre88] Erwin Kreyszig. Advanced Engineering Mathematics. Wiley, 6th
edition, 1988.
[TC96 ] Nicola L. C. Talbot and Gavin C. Cawley. A quadratic index
assignment algorithm for vector quantisation over noisy
transmission channels. In Proceedings of the Institute of Acoustics
Autumn Conference on Speech and Hearing, volume 18, pages
195–199, November 1996.
[TC97 ] Nicola L. C. Talbot and Gavin C. Cawley. A fast index assignment
algorithm for robust vector quantisation of image data. In
Proceedings of the I.E.E.E. International Conference on Image
Processing, Santa Barbara, California, USA, October 1997.
\bibliographystyle{ieeetr}
[1] E. Kreyszig, Advanced Engineering Mathematics. Wiley, 6th ed., 1988.
\bibliographystyle{acm}
[1] Cawley, G. C., and Talbot, N. L. C. A fast index assignment
algorithm for vector quantization over noisy transmission channels.
I.E.E. Electronic Letters 32, 15 (July 1996), 1343–1344.
\bibliographystyle{apalike}
This style file requires the apalike package.
Cawley, G. C. and Talbot, N. L. C. (1996) A fast index assignment
algorithm for vector quantization over noisy transmission channels.
I.E.E. Electronic Letters, 32(15):1343–1344.
Lengths
• LATEX has commands that represent lengths, such as \textwidth.
• There are two types of lengths: rigid and rubber.
• A rigid length is a fixed length, such as 4in.
• A rubber length is a length with a certain amount of elasticity, for
example: 2in plus 0.1in minus 0.1in.
A rubber length is a way of telling LATEX your preferred length, and
the amount of deviation from that length which you are prepared
to put up with.
• Most LATEX lengths are rigid lengths.
Lengths
• LATEX has commands that represent lengths, such as \textwidth.
• There are two types of lengths: rigid and rubber.
• A rigid length is a fixed length, such as 4in.
• A rubber length is a length with a certain amount of elasticity, for
example: 2in plus 0.1in minus 0.1in.
A rubber length is a way of telling LATEX your preferred length, and
the amount of deviation from that length which you are prepared
to put up with.
• Most LATEX lengths are rigid lengths.
Lengths
• LATEX has commands that represent lengths, such as \textwidth.
• There are two types of lengths: rigid and rubber.
• A rigid length is a fixed length, such as 4in.
• A rubber length is a length with a certain amount of elasticity, for
example: 2in plus 0.1in minus 0.1in.
A rubber length is a way of telling LATEX your preferred length, and
the amount of deviation from that length which you are prepared
to put up with.
• Most LATEX lengths are rigid lengths.
Lengths
• LATEX has commands that represent lengths, such as \textwidth.
• There are two types of lengths: rigid and rubber.
• A rigid length is a fixed length, such as 4in.
• A rubber length is a length with a certain amount of elasticity, for
example: 2in plus 0.1in minus 0.1in.
A rubber length is a way of telling LATEX your preferred length, and
the amount of deviation from that length which you are prepared
to put up with.
• Most LATEX lengths are rigid lengths.
Lengths
• LATEX has commands that represent lengths, such as \textwidth.
• There are two types of lengths: rigid and rubber.
• A rigid length is a fixed length, such as 4in.
• A rubber length is a length with a certain amount of elasticity, for
example: 2in plus 0.1in minus 0.1in.
A rubber length is a way of telling LATEX your preferred length, and
the amount of deviation from that length which you are prepared
to put up with.
• Most LATEX lengths are rigid lengths.
Lengths
• LATEX has commands that represent lengths, such as \textwidth.
• There are two types of lengths: rigid and rubber.
• A rigid length is a fixed length, such as 4in.
• A rubber length is a length with a certain amount of elasticity, for
example: 2in plus 0.1in minus 0.1in.
A rubber length is a way of telling LATEX your preferred length, and
the amount of deviation from that length which you are prepared
to put up with.
• Most LATEX lengths are rigid lengths.
Common Units
1
pt Point ( 72.27 in)
1
bp Big point, or PostScript point ( 72 in)
mm Millimetre (2.845pt)
cm Centimetre (28.45pt)
in Inch (25.4mm)
ex Height of lowercase x in current font
em Width of capital M in current font
Changing Lengths
• A length can be assigned a new value using the command:
\setlength{cmd}{length}
For example:
\setlength{\textwidth}{6in}
• A length can be incremented using the command:
\addtolength{cmd}{length}
so to make the text width 1in wider than it was previously, do:
\addtolength{\textwidth}{1in}
Changing Lengths
• A length can be assigned a new value using the command:
\setlength{cmd}{length}
For example:
\setlength{\textwidth}{6in}
• A length can be incremented using the command:
\addtolength{cmd}{length}
so to make the text width 1in wider than it was previously, do:
\addtolength{\textwidth}{1in}
Changing Lengths
• A length can be assigned a new value using the command:
\setlength{cmd}{length}
For example:
\setlength{\textwidth}{6in}
• A length can be incremented using the command:
\addtolength{cmd}{length}
so to make the text width 1in wider than it was previously, do:
\addtolength{\textwidth}{1in}
Changing Lengths
• A length can be assigned a new value using the command:
\setlength{cmd}{length}
For example:
\setlength{\textwidth}{6in}
• A length can be incremented using the command:
\addtolength{cmd}{length}
so to make the text width 1in wider than it was previously, do:
\addtolength{\textwidth}{1in}
Lengths
• There are three more commands that can change a length, and
they are:
\settowidth{cmd}{text}
\settoheight{cmd}{text}
\settodepth{cmd}{text}
These set the length cmd to the width, height or depth of the
text. Note that the actual text itself is not displayed.
• To create a new length:
\newlengthcmd
• To display the value of a length:
\thecmd
Lengths
• There are three more commands that can change a length, and
they are:
\settowidth{cmd}{text}
\settoheight{cmd}{text}
\settodepth{cmd}{text}
These set the length cmd to the width, height or depth of the
text. Note that the actual text itself is not displayed.
• To create a new length:
\newlengthcmd
• To display the value of a length:
\thecmd
Lengths
• There are three more commands that can change a length, and
they are:
\settowidth{cmd}{text}
\settoheight{cmd}{text}
\settodepth{cmd}{text}
These set the length cmd to the width, height or depth of the
text. Note that the actual text itself is not displayed.
• To create a new length:
\newlengthcmd
• To display the value of a length:
\thecmd
Example
Layout Lengths
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
• Everything on a page can be broken down into boxes.
• Each box has an associated width, height and depth.
y a
• The simplest form of box is a single letter
height height
depth
width width
• More complicated boxes are made up of smaller boxes.
• Example: The phrase “cabbages and peas” is made up of 15
boxes: c a b b a g e s a n d p e a s
• Between the boxes is “glue”.
• The job of the typesetter is to fix the boxes together according to
typographical rules.
Boxes
Boxes
Boxes
Boxes
Boxes
line 1
line 1 line 2
Baseline line 2 line 3 line 1
line 3 line 2
line 3
Output
• \makebox[width][alignment]{contents}
Like \mbox, but you can specify the width of the box, and how
the text is justified within it: left, right or centred.
• \makebox[width][alignment]{contents}
Like \mbox, but you can specify the width of the box, and how
the text is justified within it: left, right or centred.
• \makebox[width][alignment]{contents}
Like \mbox, but you can specify the width of the box, and how
the text is justified within it: left, right or centred.
• \makebox[width][alignment]{contents}
Like \mbox, but you can specify the width of the box, and how
the text is justified within it: left, right or centred.
Input
Input
\makebox[0pt][l]{/////}Hello!
Input
Hello!
/////
Input
Here is a \fbox{box}
Input
Here is a box
Output
Output
\setlength{\fboxsep}{10pt}
Some Text
\fbox{Some Text}
• \fboxrule : This is the width of the frame. For example:
\setlength{\fboxrule}{4pt}
Some Text
\fbox{Some Text}
\setlength{\fboxsep}{10pt}
Some Text
\fbox{Some Text}
• \fboxrule : This is the width of the frame. For example:
\setlength{\fboxrule}{4pt}
Some Text
\fbox{Some Text}
\setlength{\fboxsep}{10pt}
Some Text
\fbox{Some Text}
• \fboxrule : This is the width of the frame. For example:
\setlength{\fboxrule}{4pt}
Some Text
\fbox{Some Text}
\setlength{\fboxsep}{10pt}
Some Text
\fbox{Some Text}
• \fboxrule : This is the width of the frame. For example:
\setlength{\fboxrule}{4pt}
Some Text
\fbox{Some Text}
fancybox package
The fancybox package provides four commands, analogous to \fbox:
Input Output
\ovalbox{An oval frame} An oval frame
\Ovalbox{A thicker oval frame} A thicker oval frame
A shadow frame
\shadowbox{A shadow frame}
fancybox package
The fancybox package provides four commands, analogous to \fbox:
Input Output
\ovalbox{An oval frame} An oval frame
\Ovalbox{A thicker oval frame} A thicker oval frame
A shadow frame
\shadowbox{A shadow frame}
fancybox package
The fancybox package provides four commands, analogous to \fbox:
Input Output
\ovalbox{An oval frame} An oval frame
\Ovalbox{A thicker oval frame} A thicker oval frame
A shadow frame
\shadowbox{A shadow frame}
fancybox package
The fancybox package provides four commands, analogous to \fbox:
Input Output
\ovalbox{An oval frame} An oval frame
\Ovalbox{A thicker oval frame} A thicker oval frame
A shadow frame
\shadowbox{A shadow frame}
fancybox package
The fancybox package provides four commands, analogous to \fbox:
Input Output
\ovalbox{An oval frame} An oval frame
\Ovalbox{A thicker oval frame} A thicker oval frame
A shadow frame
\shadowbox{A shadow frame}
Examples
Here is a \ovalbox{box}
Input
Here is a box
Output
Here is a 1in box
Output
Examples
Here is a \Ovalbox{box}
Input
Here is a box
Output
Here is a 1in box
Output
Examples
Here is a \doublebox{box}
Input
Here is a box
Output
Output
Examples
Here is a \shadowbox{box}
Input
box
Here is a
Output
a 1in
Here is box
Output
\parbox[alignment][height]{width}{contents of box}
For example:
A paragraph within a box : \parbox{0.75in}{This box is
three quarters of an inch wide} so there!
Input
This box is
three quar-
A paragraph within a box : so there!
ters of an
inch wide
Output
Output
♦
With the
shapepar pack-
age, you can create
some rather fancy effects.
There are four predefined paragraph
shapes: diamond, square, heart and nut
shaped. It is possible to define other
shapes using \shapepar.
The argument must be
a whole para-
graph.
♦
some raised
some text some lowered
Output
Rules
• A rule is a rectangular blob of ink
• Syntax: \rule[lift]{width}{height}
Some text
\rule{0.5in}{10pt}
\rule[-3pt]{0.5in}{10pt}
some text.
Input
Example
\newlength\mylen
\settowidth{\mylen}{Some Text}%
\makebox[0pt][l]{\rule[0.5ex]{\mylen}{1pt}}%
Some Text
Input
Some Text
Output
Example
\newlength\mylen
\settowidth{\mylen}{Some Text}%
\makebox[0pt][l]{\rule[0.5ex]{\mylen}{1pt}}%
Some Text
Input
Some Text
Output
Example
\newlength\mylen
\newcommand{\strikethrough}[1]{%
\settowidth{\mylen}{#1}%
\makebox[0pt][l]{\rule[0.5ex]{\mylen}{1pt}}%
#1}
This example won’t allow for line breaks. Better to use ulem package.
Example
\newlength\mylen
\newcommand{\strikethrough}[1]{%
\settowidth{\mylen}{#1}%
\makebox[0pt][l]{\rule[0.5ex]{\mylen}{1pt}}%
#1}
This example won’t allow for line breaks. Better to use ulem package.
Struts
A zero width rule is called a strut:
\fbox{text}
\fbox{\rule[-10pt]{0pt}{20pt}text}
text\rule{1in}{0pt}text
Input
Output
Saveboxes
• A savebox allows you to save some typeset text for later use.
• Define new savebox: \newsavebox{cmd}.
• To save text to a savebox:
– command:
\sbox{cmd}{text}
– lrbox environment:
\begin{lrbox}{cmd}
text
\end{lrbox}
Saveboxes
• A savebox allows you to save some typeset text for later use.
• Define new savebox: \newsavebox{cmd}.
• To save text to a savebox:
– command:
\sbox{cmd}{text}
– lrbox environment:
\begin{lrbox}{cmd}
text
\end{lrbox}
Saveboxes
• A savebox allows you to save some typeset text for later use.
• Define new savebox: \newsavebox{cmd}.
• To save text to a savebox:
– command:
\sbox{cmd}{text}
– lrbox environment:
\begin{lrbox}{cmd}
text
\end{lrbox}
Saveboxes
• A savebox allows you to save some typeset text for later use.
• Define new savebox: \newsavebox{cmd}.
• To save text to a savebox:
– command:
\sbox{cmd}{text}
– lrbox environment:
\begin{lrbox}{cmd}
text
\end{lrbox}
Saveboxes
• A savebox allows you to save some typeset text for later use.
• Define new savebox: \newsavebox{cmd}.
• To save text to a savebox:
– command:
\sbox{cmd}{text}
– lrbox environment:
\begin{lrbox}{cmd}
text
\end{lrbox}
• To display the contents of a savebox: \usebox{cmd}
\newsavebox{\mysbox}
\sbox{\mysbox}{Some interesting text}
\usebox{\mysbox}\\
\fbox{\usebox{\mysbox}}\\
\Ovalbox{\usebox{\mysbox}}
Input
\newsavebox{\mysbox}
\begin{lrbox}{\mysbox}
Some more interesting text.
\end{lrbox}
\usebox{\mysbox}\\
\fbox{\usebox{\mysbox}}
Input
Output
\ttfamily \sometext.
Input
TEX has to work out how to typeset “Some text” three times.
\sffamily \usebox{\mysbox}.\\
\ttfamily \usebox{\mysbox}.
Input
TEX only has to work out how to typeset “Some text” once.
Incorporating Images
• It is possible to generate images using LATEX picture drawing
commands. The pstricks or pgf set of packages can create very
complex graphics, however most people find this too complicated.
• A more convenient approach is to create the image using a
graphics application, and import it into your LATEX document using
the command:
\includegraphics[options]{filename}
Incorporating Images
• It is possible to generate images using LATEX picture drawing
commands. The pstricks or pgf set of packages can create very
complex graphics, however most people find this too complicated.
• A more convenient approach is to create the image using a
graphics application, and import it into your LATEX document using
the command:
\includegraphics[options]{filename}
Incorporating Images
• It is possible to generate images using LATEX picture drawing
commands. The pstricks or pgf set of packages can create very
complex graphics, however most people find this too complicated.
• A more convenient approach is to create the image using a
graphics application, and import it into your LATEX document using
the command:
\includegraphics[options]{filename}
Syntax
\includegraphics[options]{filename}
Some of the more common options are:
angle=x rotate the picture by x◦
width=len scale the picture so that the width is len.
height=len scale the picture so that the height is len.
scale=x scale the picture.
trim=lx by rx ty trim the picture so that the bottom left co-
ordinate is (lx, by) and the top right co-
ordinate is (rx, ty).
draft don’t display the image, just draw the bound-
ing box with the filename inside.
An Example
• You don’t need to specify the extension.
\includegraphics[angle=90,width=1in]{shapes}
Input
Output
Examples
xt
te
e
m
So
\rotatebox{45}{Some text}
Input Output
Examples
\resizebox{6mm}{1cm}{Some
text}
Some text Output
Input
text} Output
Input
An Example Figure
\begin{figure}[tbh]
\centerline{\includegraphics[height=1.25cm]{shapes.ps}}
\caption{Some shapes}
\label{fig:shapes}
\end{figure}
Input
Output
An Example Table
\begin{table}[tbh]
\caption{An example table}
\label{tab:example} Table 1: An example table
\vspace{10pt}
A B
\centerline{
\begin{tabular}{l|ll} I 0.5 1.0
& A & B\\\hline II 12 14
I & 0.5 & 1.0\\
II & 12 & 14 Output
\end{tabular}
}
\end{table}
Input
Adjacent Figures
Two figures can be placed side by side in one figure environment:
\begin{figure}[tbh]
\begin{minipage}{0.4\textwidth}
\centerline{\includegraphics{circle.ps}}
\caption{A Circle}\label{fig:circ}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\centerline{\includegraphics{rectangle.ps}}
\caption{A Rectangle}\label{fig:rect}
\end{minipage}
\end{figure}
Adjacent Figures
Subfigures
Subfigures can be created using the command \subfigure[caption]{contents}
which is defined in the package subfigure.
\begin{figure}[tbh]
\centering \subfigure[A Circle]{\label{fig:circle}%
\includegraphics[height=1in,clip]{circle.ps}}
\hspace{0.5in}
\subfigure[A Rectangle]{\label{fig:rectangle}%
\includegraphics[height=1in,clip]{rectangle.ps}}
List of Figures/Tables
• A list of figures can be produced using the command:
\listoffigures
• A list of tables can be produced using the command:
\listoftables
• These commands should be placed at the start of the document,
after the table of contents.
• The document should be LATEXed twice to ensure that the list of
figures and list of tables are up-to-date.
List of Figures/Tables
• A list of figures can be produced using the command:
\listoffigures
• A list of tables can be produced using the command:
\listoftables
• These commands should be placed at the start of the document,
after the table of contents.
• The document should be LATEXed twice to ensure that the list of
figures and list of tables are up-to-date.
List of Figures/Tables
• A list of figures can be produced using the command:
\listoffigures
• A list of tables can be produced using the command:
\listoftables
• These commands should be placed at the start of the document,
after the table of contents.
• The document should be LATEXed twice to ensure that the list of
figures and list of tables are up-to-date.
List of Figures/Tables
• A list of figures can be produced using the command:
\listoffigures
• A list of tables can be produced using the command:
\listoftables
• These commands should be placed at the start of the document,
after the table of contents.
• The document should be LATEXed twice to ensure that the list of
figures and list of tables are up-to-date.
Title Slides
As with the other class files we have looked at, we can use the \title, \author,
\date and \maketitle commands.
\begin{slide}
\maketitle
\end{slide}
Input
Notes
\documentclass[article]{seminar}
Notes
\documentclass[article]{seminar}
Notes
\documentclass[article]{seminar}
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard styles:
– none (no frame)
– plain (plain rectangle).
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard styles:
– none (no frame)
– plain (plain rectangle).
• The fancybox package defines the additional styles:
– shadow
– double
– oval
– Oval.
• Example: \slideframe{none}
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard styles:
– none (no frame)
– plain (plain rectangle).
• The fancybox package defines the additional styles:
– shadow
– double
– oval
– Oval.
• Example: \slideframe{none}
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard style:
– none (no frame)
– plain (plain rectangle).
• The fancybox package defines the additional frames:
– shadow
– double
– oval
– Oval.
• Example: \slideframe{plain}
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard style:
– none (no frame)
– plain (plain rectangle).
• The fancybox package defines the additional frames:
– shadow
– double
– oval
– Oval.
• Example: \slideframe{Oval}
& %
Previous Next First Last Back Index 206
Creating Slides
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard style:
– none (no frame)
– plain (plain rectangle).
• The fancybox package defines the additional frames:
– shadow
– double
– oval
– Oval.
• Example: \slideframe{shadow}
Slide Frames
• Slide frames can be changed using the \slideframe{style}
command. There are two standard style:
– none (no frame)
– plain (plain rectangle).
• The fancybox package defines the additional frames:
– shadow
– double
– oval
– Oval.
• Example: \slideframe{double}
\newpagestyle{name}{header}{footer}
• Example:
\newpagestyle{csedlatex}{}{%
\textsc{Introductory \LaTeX}\hfill\thepage}
\pagestyle{csedlatex}
\newenvironment{env-name}[n][default]{begin-code}{end-code}
\begin{bfitemize}
\item First item
\item Second item
\end{bfitemize}
Input
\newsavebox{\fminibox}
\newenvironment{fminipage}[2][c]%
{\begin{lrbox}{\fminibox}\begin{minipage}[#1]{#2}}%
{\end{minipage}\end{lrbox}%
\shadowbox{\usebox{\fminibox}}}
Input
\begin{fminipage}{1.5in}
Some text in a 1.5 inch
Some text in a 1.5
framed minipage
inch framed minipage
\end{fminipage}
Output
Input
Some text.
Counters
Counters
Counters
Counters
Counters
Examples
Examples
Examples
Examples
Examples
Examples
\ordinal{slide} 220th
Input Output
Examples
\binary{slide} 11011110
Input Output
\octal{slide} 336
Input Output
\hexadecimal{slide} de
Input Output
\aaalph{slide} nnnnnnnnn
Input Output
\abalph{slide} hn
Input Output
Enumeration Counters
Up to four nested enumerate environments are permitted. Each level
has an associated counter:
Counter Representation Default Example
enumi \theenumi \arabic{enumi} 1
\labelenumi \theenumi. 1.
enumii \theenumii \alph{enumii} a
\labelenumii \theenumii) a)
enumiii \theenumiii \roman{enumiii} i
\labelenumiii \theenumiii. i.
enumiv \theenumiv \Alph{enumiv} A
\labelenumiv \theenumiv. A.
\renewcommand{\theenumi}{\Roman{enumi}}
Input
\begin{enumerate}
I. First item
\item\label{itm:first} First item
\item Second item II. Second item
\end{enumerate} Item I . . .
Item~\ref{itm:first} \ldots
Output
Input
\renewcommand{\labelenumi}{\#\theenumi}
Input
\begin{enumerate}
#1 First item
\item\label{itm:first} First item
\item Second item #2 Second item
\end{enumerate} Item 1 . . .
Item~\ref{itm:first} \ldots
Output
Input
\renewcommand{\theenumi}{\Numberstring{enumi}}
\renewcommand{\labelenumi}{\theenumi:}
Input
\begin{enumerate}
One: First item
\item\label{itm:first} First item
\item Second item Two: Second item
\end{enumerate} Item One . . .
Item~\ref{itm:first} \ldots
Output
Input
Exercise 1
Some text.
Conditionals
• As with all programming languages, TEX has conditionals.
• TEX conditionals are of the form:
\iftype . . . \else . . . \fi
• We have already encountered a conditional (ifpdf package):
\ifpdf . . . \else . . . \fi
• The \ifcase command is similar to the switch statement found
in some languages such as C. Example:
\ifcase\month \or Jan\or Feb\or Mar\or Apr\or May\or
Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi
Conditionals
• As with all programming languages, TEX has conditionals.
• TEX conditionals are of the form:
\iftype . . . \else . . . \fi
• We have already encountered a conditional (ifpdf package):
\ifpdf . . . \else . . . \fi
• The \ifcase command is similar to the switch statement found
in some languages such as C. Example:
\ifcase\month \or Jan\or Feb\or Mar\or Apr\or May\or
Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi
Conditionals
• As with all programming languages, TEX has conditionals.
• TEX conditionals are of the form:
\iftype . . . \else . . . \fi
• We have already encountered a conditional (ifpdf package):
\ifpdf . . . \else . . . \fi
• The \ifcase command is similar to the switch statement found
in some languages such as C. Example:
\ifcase\month \or Jan\or Feb\or Mar\or Apr\or May\or
Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi
Conditionals
• As with all programming languages, TEX has conditionals.
• TEX conditionals are of the form:
\iftype . . . \else . . . \fi
• We have already encountered a conditional (ifpdf package):
\ifpdf . . . \else . . . \fi
• The \ifcase command is similar to the switch statement found
in some languages such as C. Example:
\ifcase\month \or Jan\or Feb\or Mar\or Apr\or May\or
Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi
Boolean Operations
• Boolean variables can be defined using the command:
\newboolean{name}
\setboolean{name}{value}
where name is the name of the boolean variable and value is either
true or false.
• The value of a boolean variable can be tested using
\boolean{name}
Boolean Operations
• Boolean variables can be defined using the command:
\newboolean{name}
\setboolean{name}{value}
where name is the name of the boolean variable and value is either
true or false.
• The value of a boolean variable can be tested using
\boolean{name}
Boolean Operations
• Boolean variables can be defined using the command:
\newboolean{name}
\setboolean{name}{value}
where name is the name of the boolean variable and value is either
true or false.
• The value of a boolean variable can be tested using
\boolean{name}
Example
• Suppose I have to teach the same course to two separate classes.
The majority of the notes will be the same, with minor differences
regarding dates and times.
• Suppose one class is on Fridays at 9:00am and the other is on
Mondays at 10:00am.
• Define a boolean variable:
\newboolean{friday}
• Specify whether or not this variable is true. e.g.:
\setboolean{friday}{true}
• Can now use \ifthenelse and \boolean:
Classes are on
\ifthenelse{\boolean{friday}}{Fridays}{Mondays} at
\ifthenelse{\boolean{friday}}{9:00am}{10:00am}.
Example
• All the TEX conditionals, such as \ifpdf have equivalent boolean
variables, such as pdf.
• Better to use \ifthenelse instead of the lower-level \ifpdf etc.
• Our earlier example can now be written:
A \LaTeX\ document
}
Input
Testing Text
• To test whether two strings are equal, use:
\equal{string 1}{string 2}
• Example:
The work is written in
\ifthenelse{\equal{\lang}{English}}
{English} {another language}
If the command \lang has been defined to be English, the following
output will appear:
The work is written in English.
Output
Testing Numbers
• Two numbers can be compared using <, = and >
• The value of a counter can be compared using \value{name}
• Example:
This
\ifthenelse{\value{page}=42}{is}{isn’t}
my favourite page.
• To test whether a number is odd or even use
\isodd{value}
• Example:
This page is an
\ifthenelse{\isodd{page}}{odd}{even}
numbered page.
\whiledo example
\newcounter{lines}
\whiledo{\value{lines}<6}
{I will hand my homework in on time.\par
\stepcounter{lines}}
Input
Testing Lengths
• Lengths can be tested using
\lengthtest{relation}
• Example:
This page is in
\ifthenelse{\lengthtest{\paperwidth > \paperheight}}
{landscape} {portrait}
Input
• The last line of the file should have the command \endinput
• The last line of the file should have the command \endinput
• The last line of the file should have the command \endinput
• The last line of the file should have the command \endinput
• The last line of the file should have the command \endinput
• The last line of the file should have the command \endinput
Example
This is a very simple package. It redefines \today to produce the date
in the form 21/5/2004.
\NeedsTeXFormat{LaTeX2e}
\renewcommand{\today}{\the\day/\the\month/\the\year}
\endinput
vardate.sty
Package Options
• We have already come across packages that can have options passed to
them (e.g. graphicx)
• Options can be defined using
\DeclareOption{option}{code}
where option is the option name and code is what LATEX should do if
this option is specified.
• The default action for any option not defined is given by
\DeclareOption*{code}
Package Options
• We have already come across packages that can have options passed to
them (e.g. graphicx)
• Options can be defined using
\DeclareOption{option}{code}
where option is the option name and code is what LATEX should do if
this option is specified.
• The default action for any option not defined is given by
\DeclareOption*{code}
Package Options
• We have already come across packages that can have options passed to
them (e.g. graphicx)
• Options can be defined using
\DeclareOption{option}{code}
where option is the option name and code is what LATEX should do if
this option is specified.
• The default action for any option not defined is given by
\DeclareOption*{code}
Package Options
• The options are then processed using the commands
\ExecuteOptions{options} list of default options
\ProcessOptions process in order defined
\ProcessOptions* process in order specified.
• It is also possible to pass options to another package using
\RequirePackage{package name}
Package Options
• The options are then processed using the commands
\ExecuteOptions{options} list of default options
\ProcessOptions process in order defined
\ProcessOptions* process in order specified.
• It is also possible to pass options to another package using
\RequirePackage{package name}
Package Options
• The options are then processed using the commands
\ExecuteOptions{options} list of default options
\ProcessOptions process in order defined
\ProcessOptions* process in order specified.
• It is also possible to pass options to another package using
\RequirePackage{package name}
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\RequirePackage{ifthen}
\newboolean{dashdate}
\DeclareOption{dashdate}{\setboolean{dashdate}{true}}
\DeclareOption{nodashdate}{\setboolean{dashdate}{false}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{datetime}}
\ExecuteOptions{dashdate}
\ProcessOptions
\RequirePackage{datetime}
\newdateformat{dashdate}{\THEDAY-\THEMONTH-\THEYEAR}
\ifthenelse{\boolean{dashdate}}{\dashdate}{}
\endinput
\PassOptionsToClass{options}{class name}
to pass options to the named class. This class file should later be
loaded using
\LoadClass{class name}
\DeclareOption*{\PassOptionsToClass{report}}
\ProcessOptions
\LoadClass{report}
\RequirePackage[margins=1in]{geometry}
\renewcommand{\thechapter}{\Roman{chapter}}
\endinput
@ Commands
• The @ character behaves differently depending whether it is in a
class or package (.cls/.sty) file or whether it is in the document
(.tex) file.
• In a .tex file, @ is treated as a symbol. The symbol can not occur
within a command name.
E.g. \c@page will produce: @ ¸ page.
• In a .cls or .sty file, @ is treated as a letter. The letter can
occur within a command name.
E.g. \c@page is a command name (an internal representation of
the page counter.)
• Commands containing the @ symbol are internal commands, and
should only be used in a class or package file.
@ Commands
• The @ character behaves differently depending whether it is in a
class or package (.cls/.sty) file or whether it is in the document
(.tex) file.
• In a .tex file, @ is treated as a symbol. The symbol can not occur
within a command name.
E.g. \c@page will produce: @ ¸ page.
• In a .cls or .sty file, @ is treated as a letter. The letter can
occur within a command name.
E.g. \c@page is a command name (an internal representation of
the page counter.)
• Commands containing the @ symbol are internal commands, and
should only be used in a class or package file.
@ Commands
• The @ character behaves differently depending whether it is in a
class or package (.cls/.sty) file or whether it is in the document
(.tex) file.
• In a .tex file, @ is treated as a symbol. The symbol can not occur
within a command name.
E.g. \c@page will produce: @ ¸ page.
• In a .cls or .sty file, @ is treated as a letter. The letter can
occur within a command name.
E.g. \c@page is a command name (an internal representation of
the page counter.)
• Commands containing the @ symbol are internal commands, and
should only be used in a class or package file.
@ Commands
• The @ character behaves differently depending whether it is in a
class or package (.cls/.sty) file or whether it is in the document
(.tex) file.
• In a .tex file, @ is treated as a symbol. The symbol can not occur
within a command name.
E.g. \c@page will produce: @ ¸ page.
• In a .cls or .sty file, @ is treated as a letter. The letter can
occur within a command name.
E.g. \c@page is a command name (an internal representation of
the page counter.)
• Commands containing the @ symbol are internal commands, and
should only be used in a class or package file.
Example
Suppose you want to change the section headings so that they appear
in a large italic font, you could do something like:
\renewcommand{\section}{\@startsection
{section}% % the name
{1}% % the level
{0mm}% % the indent
{-\baselineskip}% % the before skip
{0.5\baselineskip}% % the after skip
{\normalfont\large\itshape}} % the style
Example
This example changes the numbered chapter headings so that a line appears above
and below the heading, and the heading itself appears in small capitals.
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\hrule % horizontal line
\vspace{5pt}% % add some vertical space
\ifnum \c@secnumdepth >\m@ne
\huge\scshape \@chapapp\space \thechapter % Chapter followed by number
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge \scshape #1\par % chapter title
\vspace{5pt}% % add some vertical space
\hrule % horizontal rule
\nobreak
\vskip 40\p@
}}
References
[1] “A Guide to LATEX 2ε : document preparation for beginners and
advanced users”, Helmut Kopka and Patrick W. Daly,
Addison-Wesley (1995).
[2] “The LATEX Companion”, Michel Goossens, Frank Mittelbach and
Alexander Samarin (Addison-Wesley, 1994).
[3] “The LATEX Graphics Companion”, Michel Goossens, Sebastian
Rahtz and Frank Mittelbach, Addison-Wesley (1997).
[4] “The LATEX Web Companion”, Michel Goossens and Sebastian
Rahtz, Addison-Wesley (1999).
Web Sites