LaTeX
LaTeX is an extraordinarily useful and versatile typesetting program. Almost every recent thesis in this group is written in it, most journals in the Physical Sciences prefer submissions in it, many people write lecture foils in it. There are many good books describing how to use it, or there is the common method of starting with someone else's LaTeX file and making minor changes.
These pages are not intended to replace or repeat that which is presented elsewhere, but rather to give an overview of the concepts in LaTeX, and also of the peculiarities of the installation in TCM.
LaTeX: a history
TeX and Metafont were developed by Donald Knuth of Stanford University. Knuth is well known as a numerical methods expert, and TeX was specifically developed with typesetting mathematics in mind. The last significant revision of TeX was in 1983, so it forms a stable basis on which to build. Its version number is a truncation of pi, and thus converges to pi as bugs are fixed. The version in TCM's is 3.1415926.
LaTeX is a set of macros which exist on top of plain TeX. They greatly simplify sectioning, figure creation and all the other tricks that a reasonable document requires. LaTeX was created by Leslie Lamport in 1985, and had a version number of 2.09. A team led by Frank Mittelbach then created LaTeX 2e, which was released in 1994. LaTeX 3 will probably happen, but has not yet (2011).
Other packages exist which sit on top of LaTeX: RevTeX and FoilTeX are two well-known examples.
LaTeX is thus a relatively stable package, with no major version changes in the last seven years, and a considerable amount of backwards compatibility for old 2.09 documents.
LaTeX in TCM
The Linux PCs use whichever LaTeX distribution came with their operating system. There are some modifications to teTeX for TCM, mostly to include non-standard packages. The file /usr/local/share/texmf/README.TCM describes the changes, which are mostly the addition of the style files for APS, IoP and Elsevier journals, as well as a few other packages such as memoir and feynmf, and also a LaTeX University House style.
LaTeX: the concepts
Traditionally LaTeX converts a plain text input file into a typeset DeVice Independent .dvi file. It does this in a single pass though the source, so any forward references (e.g. a table of contents!) cannot possibly succeed. However, LaTeX also produces various auxillary files which will be read in by the next run of LaTeX, and, in this fashion, after two of three runs convergence is normally achieved with all references correct.
The .dvi file must then be converted into a viewable form. Two common converters are dvips, which converts to PostScript suitable for printing, and xdvi which will display on an X11 display. It is at this stage that any fonts used must be rasterised: the dvi file does not contain details of how to draw each character.
Metafont, the font rasteriser designed by TeX's author, in some ways does a similar job to TrueType or PostScript font rasterisers. In one respect it is rather different. Most rasterisers use a single parameter to specify font size (a 20 point font rasterised for a 300 dpi device is identical to a 10 point font rasterised for a 600 dpi device). With Metafont this is not so: both size and device resolution are considered when rasterising. Metafont is also (comparatively) slow, so it caches rasterised fonts to disk.
Dvips by default uses equivalent scalable `Type1' fonts in the PostScript it generates, and does not embed the `standard 35' PostScript fonts. Similarly dvipdfm, which, as configured in TCM, does not embed the `standard 14' PDF fonts, contrary to Adobe's recommendations. See the customisation section if this worries you.
Converting 2.09 to 2e
Class and Style
A LaTeX 2.09 document will start
\documentstyle[options,packages]{class}whereas a LaTeX 2e document will start
\documentclass[options]{class} \usepackage{packages}
LaTeX will switch into 2.09 compatibility mode on seeing a \documentstyle command, but this compatibility is not perfect and new documents should certainly not be written for 2.09: it was superceded in 1994!
Sometimes simply changing between the above two formats is sufficient to change a document from 2.09 to 2e. More often it is necessary to add latexsym as the first package. Quite often things simply don't work properly under 2e. Often the excuse for still using 2.09 is that certain backward publishers still insist on it: it took the APS until 2001 to update RevTeX to work in 2e.
LaTeX - Including Images
The recommended way of including graphics in LaTeX 2e is to use EPS files and include them with:
\usepackage{graphicx}in the headers, and then
\includegraphics[width=4in]{file.eps}Note this is not epsfig, and certainly not psfig!
Optional parameters include height, width, angle and origin, and are comma-separated. Lengths can be specified in any LaTeX unit (in, cm, pt, etc.). Rotations (angle) are in degrees, and origins (for rotations) are most commonly `c' (centre), if the default of `bl' (bottom left) is not wanted.
To include GIF, JPEG or TIFF images, first convert to EPS (using bmp2eps or convert), but before that ask yourself why you want a bitmapped image in an otherwise scalable document. Simple sketches are best done in xfig, which produces sane, compact eps output.
bmp2eps imagename > imagename.eps
If you have a problem converting a jpeg to eps then try:
jpegtran imagename.jpg | bmp2eps > imagename.eps
Added value
Since the original release of LaTeX 2e, and the publication of the 2nd edition of Lamport's LaTeX book, a few useful extra commands have been added. Herewith a selection:
- \texsuperscript{text} typeset in superscript without changing to a maths font
- \r{a} add a ring accent
- many characters previously requiring math mode are now available in text mode: \textbullet, \textbackslash, \textbar, \textless, \textgreater, \textasciicircum, \textasciitilde.
Converting to PDF
The traditional method involves two steps:
dvips -Ppdf file.dvi ps2pdf file.ps file.pdfIt works very badly if dvips choses bitmap, rather than Type1, fonts.
The alternative is to use the command 'dvipdfm' which writes
PDF directly, using the same fonts as the above method, but dvipdfm has
a version number which is worryingly less than one. On the other hand, it
seems to be rather more stable than the two step process. It supports eps, pdf,
png and jpeg images with \includegraphics, though formats other
than eps need a separate bounding box file. For more documentation in TCM
see
/usr/local/shared/tetex-3.0/texmf-dist/doc/programs/dvipdfm.pdf
dvipdfm handles eps files by converting them to pdf with ghostscript. However, as a TCM specific hack, if a file with the same name as the eps file, but with the extension .pdf exists, it will use the pdf directly. For this to work, the eps and pdf must have the same bounding-box. It can be convenient to use eps for all figures, so that xdvi and dvips work, but if the `master copy' of the image is not eps, it may be better to generate the pdf version by a route other than via eps and ghostscript. (E.g. bmp2eps will write both eps and pdf directly.)
bmp2eps foo.jpg > foo.eps bmp2eps -pdf foo.jpg > foo.pdf(This trick is particularly useful if there is a danger than resampling will occur when the eps is converted to pdf.)
Converting to EPS
It is sometimes useful to have LaTeX produce an equation as an EPS file for inclusion in another document. One way to do this is to create a trivial LaTeX document containing the equation. Remember not to number the equation, and do use
\thispagestyle{empty}to supress the page number. Then one can use modern versions of dvips to produce eps:
dvips -E -Ppdf -o foo.eps foo.dvi
Keep it simple!
It is generally a bad idea to include scores of packages and to do many automatic 'tricks' with PostScript. Such things have a habit of interacting badly: the simpler a document the more likely it is to be portable and to behave as expected!
Customisation
One can add local customisations to most TeX installations on a per-user basis. If you wish to experiment with a new package or font, there is no need to ask for it to be installed centrally first.
The simplest method is to place the relevant files in the same directory as your LaTeX source. This works fine for (small) packages.
More sophisticated tricks require creating your own TeX tree, which will be searched in preference to the system-wide one. This needs to reside in a directory called texmf in your home directory.
Suppose you believe that dvipdfm should embed all fonts
(as Adobe recommends), for you believe that the marginal increase in
portability is worth the size penalty of embedding the things. You
then need to create the tree texmf/fonts/map/dvipdfm in your
home directory, and at the bottom of that tree a file (or link) called
dvipdfm.map containing a copy of
/usr/local/shared/tetex-3.0/texmf-var/fonts/map/dvipdfm/updmap/dvipdfm_dl14.map
which will then be used in preference to the system-wide map file.
(Unlike the system TeX tree, your own TeX tree will always be searched explicitly, rather than simply consulting an 'ls-R' database file.)
More information
The two best-known LaTeX books are `LaTeX, A Document Preparation System, 2nd Ed', Lamport, and `The LaTeX Companion', Goossens, Mittelbach and Samarin.
- Local documentation
- TeX archive
- A Gentle Introduction to LaTeX (97 pages, somewhat dated)
- A Not So Short Introduction to LaTeX 2e (145 pages, subtitled "LaTeX2e in 131 minutes, much more up-to-date than the Gentle Intro)
- CUED's excellent LaTeX pages
- LaTeX: what the Introductory Guides don't tell you (more accurately, what people in TCM appeared not to know)