Computer Laboratory

(La)TeX under Unix

For the most part, the Lab installs the distribution’s (La)TeX distribution, so most people who come to the system from another Un*x environment should not be much surprised.

Basic system

Linux distributions now (all) base their (La)TeX system on the TeX live distribution; when last checked, the best on offer is a development of TeX live 2009.

We expect derivatives of TeX Live 2012 to be available with distributions, early in 2013.

Documentation

The system’s own documentation

Documentation is mostly provided through the texdoc command (there are a few man pages, but TeX packages tend not to be documented that way). To use texdoc, type

$ texdoc name of package

In older versions of TeX live, the name you quote is the name of the file that contains the documentation. A good proportion of likely packages have documentation whose name is the same as the package: for example, footmisc.sty’s documentation is read by

$ texdoc footmisc

However, there are painfully many whose documentation has some generic, or oddball, name; pre-2010 versions of TeX live deal with the problem patchily, if at all. TeX Live 2010 has a list of documentation files associated with each package, and its texdoc will (at worst) give you a list of alternatives.

Some help is offered by the CTAN Catalogue; if all else fails, texdoc may bring up a catalogue entry for the package you’re interested in — catalogue entries contain a package outline, at most, but they do list known documentation, and give links for it. Of course, you can go straight to the catalogue if you so wish: start from http://www.tex.ac.uk/search/ and use the box “search the catalogue for a keyword”; enter your package name in the box and it will give you a list potential matches. Select the most likely one and you’re shown a summary description with symbols at the bottom of the text area.

A good example is hyperref.sty; its entry in the catalogue shows a substantial set of links. Hover over them, and you find a README file, a manual in HTML and in PDF, and an article and a set of slides also in PDF. Since none of these files are called hyperref.<anything>, older versions of texdoc won’t find them, though they are in the TeX system’s documentation tree.

Tutorials, etc.

The system comes with a very good LaTeX tutorial, called “The not so short guide to LaTeX”. Read it via the command

$ texdoc lshort

The recommended Plain TeX tutorial (“A gentle introduction”) is to be found on the TeX archive.

The UK TeX FAQ lists lots of other reading matter, including several books whose print run has ended and which are now only available over the web.

Features, caveats and pitfalls

The Basic executable

Plain TeX (Knuth’s creation) remains “unadulterated” (they run an executable that is as Knuth wrote it, including the bug fixes he has approved, and with a Linux adaptation layer). By default all other “TeX-like” executables are based on pdf-e-Tex. For most ordinary purposes, the use of this e-TeX variant of pdfTeX should not bother anyone — LaTeX and other TeX systems still do what you ask them to do in the same way as they always did.

However, if you once wrote macros to decide whether you were using pdfTeX, it’s quite likely that you got them wrong (most people did): if so, this change will bite you.

If your document needs to know, the package ifpdf.sty defines a TeX conditional \ifpdf; use it with traditional TeX style coding:

\ifpdf <pdf(La)TeX action>else <nonpdf(La)TeX
    action> \fi

If you prefer the LaTeX conditional mechanism, load ifpdf.sty and ifthen.sty, and test using

  \ifthenelse{\boolean{pdf}}{<pdf(La)TeX action>}{<non-pdf(La)TeX action>}

Most packages, whose behaviour changes according to what engine you are using, already contain code to detect the engine; so, for example

  \usepackage{ifpdf}
  \ifthenelse{\boolean{pdf}}{\usepackage[pdftex]{graphicx}}%
                            {\usepackage[dvips]{graphhicx}}

is needlessly complicated. If you simply write:

  \usepackage{graphicx}

the package will achieve the same result.

The Latin Modern fonts

Modern distributions provide the “Latin Modern” font family developed in Poland as an Adobe Type 1 (“PostScript”) replacement for Knuth’s CM fonts. They provide coverage of all of the EC and TC fonts, and are also available in forms suitable for use in other languages (notably Polish, Russian and Vietnamese).

If you were told you couldn’t do proper hyphenation of European languages (French, German, etc.) in PDF documents, now’s the time to forget that.

Usage is:

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[<language name>]{babel}

In this setup,

  • You need to load fontenc.sty because the fonts don’t support Knuth’s old “standard” encoding, known in LaTeX as OT1), and
  • the language name selects hyphenation rules appropriate to the language you are using (if you are writing in English, there is no need for that); babel also selects typesetting specialities for the language (e.g., space before punctuation, in French).

The Latin Modern fonts also cover the “text symbols” that are defined in the package textcomp.sty.

Documents written in Unicode

TeX itself is firmly positioned in the pre-ASCII era, but LaTeX can now be made to work with many different character codes, including (to some extent) Unicode.

Unicode input (using UTF-8) may be enabled with the command:

\usepackage[utf8]{inputenc}

Everything in the file after that directive will be interpreted as UTF-8. This gives you neat coding (in so far as any TeX coding is neat) but it is limited to the eccentric set of languages for which there is a registered LaTeX font encoding (sic!); mostly, that means European languages expressed in Latin or Cyrillic alphabets. The truly tedious omission is Greek: apart from that, all current EU languages are (mostly) covered.

The old package ucs.sty may be loaded:

\usepackage[utf8x]{inputenc}

This setup gives a far wider range of languages (its criterion is that there is an identifiable mapping from a Unicode range to a font set up for use with TeX).

The ucs package, with its helper files, is part of the distribution; so you don’t need your own copy (and should delete any old copy). See the package documentation (texdoc ucs) for more detail; you may need help installing fonts to make things work — contact sys-admin if so.

The other alternative, for dealing with Unicode text, is to use XeTeX or LuaTeX, both of which work from UTF-8 Unicode input by default.

The geometry package’s defaults

The geometry package is a safe way of setting up consistent text block and margin sizes, in LaTeX. In many cases, you simply tell geometry what layout you’re after, and it gets on and does it: it’s a recommended way forward.

Unfortunately, in pursuit of some uniformity or other, the package’s defaults changed with the release of version 3 (in 2008). Users who don’t explicitly specify the size of their text area, or of their margins, may find that geometry gives them a different-sized text area from that which they’re used to.

Adding things to your system

It has never been easy to add things to a TeX system, but adding LaTeX packages isn’t too bad. An outline is given in the wiki.

Unfortunately, the rules for “personal” font installation are a maze of twisty little passages which take apparently illogical steps at several points; the UK FAQ describes the procedure, but you are advised not even to try — ask sys-admin for help.

XeTeX — a Unicode-compatible TeX-alike

XeTeX (not available on the very oldest (teTeX) distributions) is very attractive to anyone who is interested in using Unicode, notably those who need to use a non-Latin script. XeTeX input is, by default, in UTF-8, and it was the first generally available engine that can easily cope with TrueType and OpenType fonts, of which there are increasingly many available.

Unfortunately, there's next to no experience of using XeTeX, in the Lab’s support staff, so potential users have to find their own way. Simple use is pretty straightforward (apart from font selection: see the documentation of fontspec.sty package). Typesetting maths is more tricky; free Unicode maths fonts are (at last) available, but they, and the supporting unicode-math.sty, are only available in the very latest distributions. Some help is available via The SIL web site (the development of XeTeX was originally an SIL project).

LuaTeX — Unicode and built-in scripting

LuaTeX is an experimental system that has most of the advantages (UTF-8 input, OpenType fonts, etc) of XeTeX, and also has a lua interpreter built-in. The interpreter has access to the data structures of the TeX-alike engine, so that you can in principle perform typesetting actions within a lua script.

LuaTeX's disadvantage is its experimental nature; the latest version (not that in use in any of the Lab's Linux distributions, yet) is supposedly “feature stable” but there remains the danger of the system changing under users’ feet.

The LuaTeX project has set a target completion in 2012 (there is no sign of this, at the time of writing, and there will be a delay between completion and it appearing in distributions). If you choose to use it, you’re on your own (to a large extent). There is a LuaTeX mailing list and a web site, but the systems team can offer essentially no support.

Lab specials

University style

The University, in its wisdom, defined a “style” for printed matter a while back. It was not clear exactly what we should apply this style to, but its recommendations for official letters were more-or-less comprehensible, and its ambiguities and problems don’t bite us. Simon Moore’s lablet class implements a good-enough approximation to the style. Note that it ordinarily uses Sabon fonts (see below); it, and the font set, is available in the bundle CL-texlive-extras; install it, if necessary, using yum (on Fedora and Centos machines) or apt-get (on Ubuntu machines).

Note that a further revision of the University style has been available for some time; LaTeX macros to support this new style are not available.

Extra fonts

The department has some commercial fonts available, and we can in principal install a few non-standard free ones as well. By default, these fonts are not available, but they can be provided by the systems team. Note that the Sabon font is installed with the University style in the CL-texlive-extras bundle (see above).

Family type face access shapes
Adobe Sabon comm serif psb* roman&italic+bold
Adobe Utopia free serif put* roman&italic+bold
Fourier free maths fourier medium,semi&bold
LuxiMono free sans luximono fixed width medium,bold
URW Garamond free serif ugm* roman&italic+bold

Note 1: the “access” column contains either a package name, or a family code followed by an asterisk. So, to use LuxiMono for your fixed-width fonts, write \usepackage{luximono}; whereas to use Adobe Sabon, you need to write \renewcommand\rmdefault{psb}, before \begin{document}.

Note 2: the LuxiMono font is too big to match most other fonts, and is commonly used scaled down, with the command \usepackage[scaled]{luximono}.

Note 3: some of these fonts are only available, as text, for “T1” encoding; in this case you will need \usepackage[T1]{inputenc} to provide the necessary LaTeX mechanisms for processing your file.