|
LaTeX: Basics and Reports, Articles and Slides
KOM Computer Workshop
help@kom.auc.dk
Release 1.19 Thu Oct 18 08:05:38 2001
This guide to LATEX will introduce you to the basic concepts all you
need afterwards is the not so short guide to LATEX found on the
internet and probably the two most important books: The Lion Book
(LaTeX introduction by Leslie Lamport) and the Dog Book (The LaTeX
Companion by ...).
Including the basic concepts it will also cover the topics of setting
up your report to format and print nicely, make your 7th semester
articles look perfect and make equations look brilliant when presenting
your slides. Letters to mom ``asking for more bread'' will not be
forgotten...
Each autumn semester one mini-course will be held in using LATEX to
write and format your reports. Materials can be found there which can
form the basis of your report or your article
You will find templates for a Institute of Electronic Systems report
which already include a lot of the tips included in this guide, a full
article written using one of the supported article styles, other
helpful documentation, and links to other webpages.
- Overview
Whenever you are getting ready to write a document consider formatting
it with LATEXwhatever the type of document you are writing. The
following sections will present you with reports, articles, slides or
letters covering most of your needs as a student, teacher or
researcher. This section will deal with the different commands you
have to execute to format, convert and print your LaTeX documents.
You start by creating a TEX file (suffix is named .tex)
which you are able to convert to either DVI, Postscript, PDF or
HTML. The DVI is used to view your document on-screen, Postscript
files can either be printed or priviewed, PDF is an portable and
compact way to give access your document on the internet and last HTML
is good for web pages.
Several command line programs are available for formatting your
document and convert it to the right format. Please spend some time to
get yourself accustomed to the names of the programs and the result
they produce.
LaTeX Document (.tex)
|
+-----------------------+---------------------------+
| | |
DVI File (.dvi) PDF Document (.pdf) HTML File (.html)
|
|
Postscript File (.ps)
|
|
PDF File (.pdf)
Several different programs are involved and will be explained in the
following subsections.
- Format your Document
You have created a document abc.tex (with no formatting
errors in it) and you want to process it
alfred@lada> latex abc
or more laborously
alfred@lada> latex abc.tex
If no errors are met inside the abc.tex file the
result will be the abc.dvi. This file is the first
step to print your document or create either Postscript or PDF from
it.
Several other files might also be the result of the processing of
the TeX document. These might be log files (.log and
.blg), intermediate files for generating cross references
(.aux files) or list of tables or figures or table of
contents (.lof, .lot, or .toc files).
When you have the result you want you do not need these files
anymore.
Another issue worth mentioning is that you might have to run
latex several times in order to have the correctly
formatted result. The latex program will tell you if reruns
are needed. For large reports usually above 150 pages op to four or
five reruns can be needed, but in normal conditions latex
need only to be run single or twice.
+---------+ +-------------+ +---------+
| abc.tex |---->| `latex abc' |---->| abc.dvi |
+---------+ +-------------+ +---------+
- Preview or View the Document
When you have formatted your LaTeX document correctly run it through
xdvi to preview it.
alfred@lada> xdvi abc
When you start the XDvi application, you are able to browse through the pages
you have created. By clicking on the left, middle and right mouse
button you are able to zoom smaller to larger areas of the pages
previewed.
XDvi has many keyboard shortcuts (callede keystrokes in the manual
page) which are available with
alfred@lada> man xdvi
Please be aware of the following normal keyboard shortcuts:
q -- quit
n -- next page
p -- previous page
g # -- goto page number #
s # -- shrink factor #, zoom to #
G -- greyscale toogle
Please note that XDvi may show eps figures wrongly sometimes. Don't
be alarmed - the figures will look correct on the printed output!
- Print the Document
When you have previewed your document all you often need is to print
it with dvips or lpr for more special printing
needs. The program dvips is a DVI to Postscript converter
and can either print directly or output to a file. The following
prints to default printer
alfred@lada> dvips abc.dvi
and this will print to the printer ``lwa51'':
alfred@lada> dvips -Plwa51 abc.dvi
Dvips have many interesting options for converting DVI
files to Postscript files eg. printing crop marks for non-standard
page sizes, range of pages to print, selection of papertype, etc.
The most used function is output to a file:
alfred@lada> dvips -o abc.ps abc.dvi
which generate a Postscript file from the DVI file. The postscript
file is used to verify that the upcoming print is OK, but other
interesting options apply to Postscript including:
- Print 2-up pages (convert pages to A5 and put two of them on a
single A4 for printouts which result in only half the actual
amount printed):
alfred@lada> psnup -2 abc.ps abc-2up.ps
or even 4-up pages
alfred@lada> psnup -4 abc.ps abc-4up.ps
which really saves the actual amount of pages printed,
- Convert to PDF files which translates the Postscript to the
internet friendly and platform independent PDF format. Two
different programs exists - from Adobe comes:
alfred@lada> distill abc.ps abc.pdf
and from Alladan Ghostscript comes:
alfred@lada> ps2pdf abc.ps abc.pdf
- Convert to books, booklet or leaflets using the Postscript
utilities (psutils software package). You need to convert a series
of A4 single-sided pages into a A5 booklet with double-sided pages
where the A4 pages are transformed into A5 pages. It can be done
by first creating a normal A4 page. Perhaps you are going to use
the scale package to make the A5 pages look realistic.
alfred@lada> latex booklet.tex
alfred@lada> latex booklet.tex
The A4 pages have to be converted into landscape A5 pages during
the DVI to Postscript proces
alfred@lada> dvips -t landscape -x 707 -o booklet-a5-landscape.ps booklet.dvi
The next part needs you to distribute or rearrange the A5 pages
into signatures which is needed if you print books or
booklets. Here it is very important that your docuemnt
consists of a multiplum of four (4) pages; the rearrangement
proces have to take an argument of a multiplum of four pages. For
the example we will have thirty-two (32)
alfred@lada> psbook -s32 booklet-a5-landscape.ps booklet-a5-book.ps
The last conversion will copy two A5 Postscript pages onto one
and align the two pages on the A4 media.
alfred@lada> pstops '2:0(7.44mm,7.44mm)+1(7.44mm,-141.06mm)' \
booklet-a5-book.ps booklet.ps
All the Postscript output can be viewed with Ghostview
(gv, ghostview). To print the
booklet.ps you have to use a short duplex enabled printer
alfred@lada> lpr -P lw -Z sduplex booklet.ps
You are all done with the booklet.
- Convert to a HTML File
- Whenever you need to
convert part of your texts to HTML, which you want to present on the
web, you can also use LaTeX documents (they can also be converted to HTML).
alfred@lada> latex2html abc.tex
The software package LaTeX2HTML have many parts which can be
configured to do what you want. Please consult the manual pages for
more information. Most things have to do with how to present the
HTML pages, how to translate mathematics and what to do about
header, footer and navigational parts of the HTML pages produced.
Another option that you have with translating HTML is called
dlh, but is not nearly as advaned as Latex2HTML.
alfred@lada> dlh abc.tex
DLH cannot convert mathematics but is good at converting
smaller documents for the web.
You can use the parts of this document to get the overview of how to
structure your LaTeX report, but you will have to look elsewhere for
the syntax of LaTeX (the Lion Book by Leslie Lamport). Here you will
be provided with help and tricks on how to set up the basic report,
divide your report into a multifile document and how to provide your document with report specificnesses.
- Basic Document
Your basic report document will look like
\documentclass{report}
\title{Basic Report}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\end{document}
which provide you with a front page, table of contents and the first
chapter without text. You can save the text and commands in a file
called firstreport.tex and run latex on it several
times and end up with your first report.
- Minimum LaTeX Packages
- There exists a minimum of required
packages that you will need to use in order to get a high quality
report
\documentclass[12pt,danish,a4paper]{report}
\usepackage{t1enc} # danish letters
\usepackage{babel} # danish hyphenation
\usepackage{geometry} # page layout and A4 paper
\begin{document}
If you stick to those packages you will get decent performance from
LaTeX for the first few weeks, when you begin using it.
- Next Few Packages
- Minimum packages got you set up with LaTeX
but to get on with polishing the layout you need some more packages
and tune them
\usepackage{fancyhdr}
\usepackage{booktabs}
\usepackage[hang,bf,small]{caption}
If you are in need for more formatting then please consult the ``Dog
Book'', also reffered to as the LATEX Companion. It provides
information on almost all basic LATEX Packages and advanced too.
The fancy header package gives you control over the header and
footers. With that package you can easily control which information
goes where. The following might look a bit technical but is easy to
use if you read the LATEX Companion
\pagestyle{fancy}%
\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\fancyhf{}
\fancyhead[LE,RO]{\sffamily\bfseries\thepage}
\fancyhead[LO]{\sffamily\bfseries\rightmark}
\fancyhead[RE]{\sffamily\bfseries\leftmark}
\fancyfoot{}
Basicly it creates fancy pages with a horizontal line beneath the
header and no line above the footer. On even pages it puts
pagenumber to the left header and chapter name on the right
header. On odd pages it puts pagenumber on the right header and
section name on the left header. It enables you to produce very nice
reports which are printed on both sides. This has already been taken
care of with the latexreport.tar.gz template.
The booktabs package enable you to create professional
level tables in your articles and reports. Please consult the
information on booktabs by issuing
alfred@lada> texdoc booktabs
and look at the examples in latexreport.tar.gz. For many
other LATEX packages you can do similar with the texdoc
command.
The caption package looks different than the other used
packages in that it has options. Documentation on packages, either
directly or from the LATEX companion, include options for pacakges
which you can use to configure the behaviour of a certain
package. It will modify how your report is formatted. Captions are
texts which follow either tables or figures and the caption
package is a central place to modify the formatting of captions.
The options [hang,bf,small] will create hanging, small bold-face
font captions. You can change it to provide the setup you want.
- Synopsis and Abstract with AAU Logo
- All reports which are
written at Institute of Electronic Systems have a history of
including a specific ``synopsis'' and a ``abstracts'' page. Since
they are formatted in a very specific way they are not always easy
to reproduce with LATEX. The latexreport.tar.gz template
includes a full setup for a Danish synopsis and an English abstract.
Look at the contents of the file
latexreport/text/frontmatter.tex
You are more than welcome to use them for your own purposes as long
as you remember to change the contents. They can be used both with
the template and with your own setup of a report template.
- Table of Contents, List of Figures and List of Tables
- To include these often needed lists please include the following
into your report
\tableofcontents
\listoffigures
\listoftables
They will provide you with the needed results. You will end up with
at least three different pages each with a table of contents, a list
of figures, and a list of tables.
- New Items in TOC
- Also you might need to include a header for a un-numbered section
into the table of contents (un-numbered sections are not normally
included into the table of contents). This is the case if you have a
colophon or the bibliography, which is an un-numbered section, that
goes into the table of contents:
\addcontentsline{toc}{chapter}{\numberline{}\bibname}
or
\addcontentsline{toc}{chapter}{\numberline{}Colophon}
Traditionally students at the 7th semester at Institute of Electronic
Systems have to write an article instead of a report. Different styles
have been suggested and they are all installed in the tetex
distribution found at Department of Communication Technology.
- Article Styles
- Writing an article instead requires you to
change the document class. Normally the document class is
report and for the general case you can change it to
article. Most scientific journals and conference
proceedings have their own LATEX document class which you must
use.
The different article document classes installed for wriring
articles are: elsart abd ifacmtg. Use these names
instead of article or report document
classes. Most people use just article in the beginning ana
later change to the specific document class that is needed.
Find more information about the LATEX article styles at
- Article Class elsart
- You begin an elsart article by using the instructions found in
ies-local-texmf/tex/latex/elsart
and with a document like this
\documentclass{elsart}
\usepackage{natbib}
\begin{document}
...
elsart specific latex commands
...
contents
...
\end{document}
You must take care when you prepare the article to put in the
correct information about the article, keywords, authors, addresses,
and the like. Please also take care to read the sections of their
documentation containing information how to insert Postscript
figures, show equations and creating normal sections like
bibliographies and table of contents.
- Article Class ifacmtg
- You begin an ifacmtg article by using the instructions found in
ies-local-texmf/tex/latex/ifacmtg
and with a document like this
\documentclass{ifacmtg}
\bibliographystyle{ifac}
\usepackage[dcucite]{harvard}
\begin{document}
...
ifacmtg specific latex commands
...
article contents
...
\end{document}
Since the ifacmtg is similar to elsart, the
guidelines and other documentation for authors, mentioned on the
Elsevier Science site, may be helpful.
- Article Example
- We provide you with a realistic example of how to
prepare an article using one of the available article styles. Lars
Christian Hausmann has donated an article to use as a reference
when you prepare your own article at the seventh semester, or when
you want to prepare one as a part of your Ph. D. studies.
You can find the article example under the ``Article Example Using
ifacmtg'' in the LATEX course area:
Unpack the article archive and run latex on the article
latex files inside, view the result and browse the files to find out
how you will create an article with LATEX yourself.
- Prosper Package
- For you to make slides using LATEX you have
to use the very advanced latex package called prosper. You
can find more information about prosper on the web
The prosper package have been installed in the current
tetex AFS installation at the Department of Communication Technology.
- Small Example
- This is a very small example that works and all you need to fill in
is the LATEX formatted contents you need for each slide.
\documentclass[final,a4paper,slidecolor,colorbg,%
pdf,total,contemporain]{prosper}
\title{Emacs 21}
\subtitle{Easy, Smart and Modern\ldots}
\author{Flemming Kjær Jensen}
\institution{Department of Communication Technology}
\email{fkj@kom.auc.dk}
\begin{document}
\maketitle
\begin{slide}{Slide Name}
\begin{itemize}
\item Item One
\item Item Two
\item Item Three
\end{itemize}
\end{slide}
\end{document}
- Generating Platform Independent PDF Slides
- The output of LATEX and the prosper package is platform
independent PDF files that you can bring whereever you go. You can
show them on the main platforms: Unix, Windows and Apple
Macintoshes.
The steps involved in generating the PDF slide documents are
latex slide-doc.tex
latex slide-doc.tex
dvips -o slide-doc.ps slide-doc.dvi
ps2pdf slide-doc.ps slide-doc.pdf
Later you can view the slides with the Acrobat Viewer
acroread slide-doc.pdf
If you choose to animate your slides then please use a PDF viewer
that supports the type of animation you need. Ie. check yourself for
support.
- Prosper Slide Basics
- A set of slides have been created as a
part of an employee course for creating conference slides using LATEX and prosper. Please look at these prosper introductionary slides:
It contains information on the basic layout on how to make slides,
how to animate itemized lists (bullets), and more. More advanced
information can be found in the seminar and
prosper package documentation.
In LATEX figures are inserted using the Encapsulated Postscript
(.eps) format. If you can convert your images or figures to EPS then
you can also use them in LATEX. Most modern day Windows programs can
export to EPS, or you can make a screenshot of the image and later
convert it to Postscript. Most Unix programs can output Postscript or
EPS format. See later how to convert to EPS format on Unix.
- The graphics Package
The graphics package is the standard package to include in
your reports or articles
\usepackage{graphics}
It supports basic inclusion of graphics into a LATEX document. It
has been superceded by the graphicx package. We will focus on
that.
- The graphicx Package
To use the extended or enhanced graphics package do
\usepackage{graphicx}
The graphicx supports the use of colors, scaling and rotation
of EPS files, and much more. The command options are very simple to
use compared to the standard graphics package. Examples follow.
- Graphics Package Documentation
For documentation on both the graphics and graphicx
packages do the following
alfred@lada> texdoc grfguide
- Insert Figure as a Float
To directly insert an EPS file into a document you have to use this
command
\includegraphics{file.eps}
To insert a figure as a ``float'' into a document (this is the correct
way of insert figures into a report) please
\begin{figure}[htbp]
\centering
\includegraphics{file.eps}
\caption{Example figure of a EPS file}
\label{fig:example}
\end{figure}
- Rotate and Scale Figure
If you need to rotate or scale an inserted figure use some of
the options available for the includegraphics command
\includegraphics[scale=.75,angle=45]{file.eps}
- Convert Image to EPS File
For Unix the ImageMagick software package contains advanced software
for image conversion. Please use the convert program to
convert your images to EPS before using them with LATEX.
alfred@lada> convert file.jpeg file.eps
For more information on the convert program issue this command
alfred@lada> man convert
KOM Datavaerksted
|