Art of Computer Programming, Volume 4A

Slightly off-topic, but I think this will be of interest to some readers. After many long years in draft, I see that volume 4A of The Art of Computer Programming by Professor D. E. Knuth has appeared in print. The TUG link to this says that TUG members can get a discount even if you are not a member. Worth a look! (They seem to accept international registrations, not just US ones.)

LaTeX3 and document environments

There was a question on the {TeX} Q&A site recently about compiling a document reading

\documentclass{minimal}
\document
a
\enddocument

This doesn’t work: I’ve explained why as my answer to the question. I also mentioned that in LaTeX3 I’d expect this won’t work. Here, I want to look at that in a bit more detail.

First, the background. When LaTeX2e creates an environment foo, what actually happens is two macros called \foo and \endfoo are defined (hence the original question). When you do

\begin{foo}
...
\end{foo}

LaTeX looks for the \foo macro, and if it finds it starts a group and inserts \foo. At the end of the environment, LaTeX will use \endfoo if it exists, but this is not required.

There are some problems with this scheme. First, it’s possible to abuse the system, as something like

\begin{emph}
...
\end{emph}

will not raise an error even though \emph was never intended to be used as the start of an environment. (LaTeX2e does not require that \endemph exists here: it’s only the start of an environment which must be defined.) Secondly, due to this mixing it’s not possible to have a foo environment and independent \foo macro: the two are tied together. Finally, as \endfoo is ‘special’ \newcommand won’t let you create macros which start \end....

For LaTeX3, we want the approach to be different. Document commands and document environments should be independent of one another, and so xparse defines a pair of special internal macros when you use

\NewDocumentEnvironment{foo}...

This is totally independent of a macro called \foo, so the plan is that you’ll be able to have an environment called foo and a separate \foo command, or indeed one called \endfoo.

At present, most people will be using xparse with LaTeX2e. That means we still need to follow what LaTeX2e does. So at the moment you’re not going to see the change: messing with the LaTeX2e mechanism looks like a very bad idea. However, for a native LaTeX3 format the clash will disappear.

biblatex v1.1: dynamic reference sets

The latest version of biblatex, v1.1, appeared on CTAN yesterday. This is a feature release, not just bug fixes, and so there are lots of new things there. At the same time, Biber has been updated to v0.7. If you use TeX Live 2010, you’ll be able to get the new biblatex using tlmgr in a day or so, and can get the Biber update via TLcontrib already.

Many of the new features rely on Biber, and will not work with BibTeX. As Biber has lots of advantages anyway, including UTF-8 support and active development, this is no real hindrance.

I want to focus here on one new feature, as it’s one I requested. In chemistry and physics we tend numerical reference styles and to have lots of references. Often, several of these will be related, and so can be ‘compacted’ into a single number. With traditional BibTeX styles, this can be done using the mciteplus package and a suitable .bst file. biblatex has supported this using ‘reference sets’ for some time, but up to now this has required modification of the database entries. In v1.1, you can define a reference set in the preamble:

\defbibentryset{set1}{key1,key2,key3}

and then cite the set in the document. There is also support for mciteplus-like syntax, but I think it’s probably best to use the native biblatex approach here.

Compressing multiple citations in a dynamic way was really the only problem I had with using biblatex for all of my citations. Now that this is sorted, I’ll be sticking to biblatex all of the time, and I’d urge other physical scientists to do the same: biblatex is a much more flexible approach than the traditional BibTeX citation system.