PDF LaTeX by exampleCTJ Dodson |
Free pdf viewers (see below) are usually already associated with a browser so it is convenient to use pdf output format and then you can include also hyperlinks, coloured text, graphics and even movies in your documents, electronic books, and CD/DVD media. Acrobat Reader can rotate graphics, it has an automatic slideshow mode and the LaTeX beamer package (cf. below) provides good looking conference slides for computer projection.
In the case of a collection of course documents or a connected series of articles---possibly including some on remote computers, it is convenient to use web-based access to the archived resources, as is in operation with the page you are now reading. Accordingly, the working example of this page is an easily understood template that you can modify to provide access to your own archived materials; it has been designed using elementary raw HTML so it is easily portable. On the other hand, whereas professional web editing facilities are very powerful, they use many hidden or at best obscure procedures and may bury in file libraries necessary items, so it is hard to create a stand-alone webpage. Creating simple raw HTML in a plain text editor like Notepad is sufficient for most purposes, like creating and updating a course homepage or carrying a connected set of documents for discussions and presentations at another institution.
The result of pdflatex will create from artex.tex several files of which two are immediately important: artex.log, which contains information on any errors and artex.pdf which is the output. If artex.pdf is not how you want it, then resume editing artex.tex before again processing it with pdflatex. In WinEdt or or TeXstudio the errors will be highlighted for you.
Resolving errors in LaTeX code
If pdflatex
finds errors in the commands used in artex.tex, then it will write information
on these in artex.log but additionally it will give feedback in the DOS window
and this can help corrections. You can ask for more help about an error message
by entering h or you can ask pdflatex to do the best
it can by entering s after an error message. This
help is often cryptic but together with the output you can usually decide what
has gone wrong. Typical beginners' errors are omission of the preamble commands
\documentclass{article} one of the packages required
eg \usepackage{amsmath,amssymb,amsfonts}, or one of
the essential beginning \begin{document} and end
commands \end{document}. Other common errors are
omission of $ around mathematics or failure to end an
environment after once beginning it: \begin{eqnarray}
must eventually be followed by \end{eqnarray}. The
example artex.tex contains a selection of commonly used environments.
If you want to be adventurous, you can
include movies in pdf documents using the \includemovie command.
In the source file bookex.tex there are some options, the line:
\usepackage[colorlinks,citecolor=blue,linkcolor=blue]{hyperref}
includes hyperlinks and chooses colours for them.
Also, the following lines just before
\begin{document}
will put a watermark on every page:
\usepackage{draftwatermark}
\SetWatermarkText{Draft not for circulation}
\SetWatermarkScale{3}
\SetWatermarkColor[rgb]{0.9,0,0}
Just omit them or comment them out with % if you do not want a watermark.
Each Chapter, Appendix and the Index is made as a *.tex file and is called in by the include command---thus ch1.tex is the name here of the file containing Chapter 1. The inclusion of any particular file can be suppressed by prefixing the line by a percent sign. Do not put an end{document} command at the end of chapter files; just one such command is needed at the end of the book. Note the tag used to make an index entry. You may need to consult Lamport's book for details of the procedure to make the index input file; LaTeX will create a pre-index by listing in the file bookex.idx all the tagged items in your input *.tex files, then you edit this into a theindex environment, as index.tex.
When you view bookex.pdf using Acrobat Reader, from the toolbar View choose Single Page and select Bookmarks; then just pressing Enter or via a remote control you display the book one page at a time. For use from a CDROM, the Bookmarks navigation bar at the left is convenient; note that the List of Contents is automatically hyperlinked.
See the TeX User Group for more information on LaTeX and available augmentations.
To use the example here you can download the necessary files:
Source:
pdfbyex.htm, graphic for
inclusion: viviani.gif
When you open the file in Notepad and compare the text with what the browser presents from it, you will see how simple it is to write raw HTML code. It is important to use the plain text editing, not rich text and not Word or Wordpad, because the latter think they know what you want and slip in their own controls!
The HTML control commands are all wrapped in braces < > and are often natural abbreviations of the operations: eg HR is `horizontal rule' which gives a dividing line, Hn for n=1,2,3,4 gives headings of descending importance. B means bold and /B means end bold, I and /I begin and end italic, UL begins a list environment, LI precedes each item and /UL ends the list, BR gives a line break and P gives a new paragraph, HREF precedes a hyperlinked reference and a graphic file of a travelling triad on Viviani's curve was included at the top of this page using IMG SRC="viviani.gif".
The only oddly obscure part of HTML is the code for colours, for example #FFFF00 means yellow; so you may have to look up special colours in an HTML manual or go to the sourcecode of a document containing the colour you want and experiment---another way is to view a little text in your web browser Composer, use its editor to colour the text, then open the source file in Notepad and note the code used. It will be of the form: font color="#FF6666" for wrapping round red text and of the form: font color="black" for green text. From the top of this file you can deduce html code for the symbol © ; similar detective work on other html source files, which you can read through your browser toolbar `View' `Source' , can yield useful tricks.