TeX Live 2011 released

Today sees the release of TeX Live 2011. As most readers will know, TeX Live is a cross-platform TeX system, and is the basis of the MacTeX distribution for Mac OS X. TeX Live 2011 is very much evolutionary, with only a small list of changes from earlier releases. Perhaps the most notable is that the Biber program is now available for major platforms: it was added to the on-line updates for TeX Live 2010, but this will be the first appearance on the DVD version. I guess that Karl Berrry will now be busy catching up on CTAN updates, so that on-line updating of TeX Live can resume.

Which siunitx options to set globally?

On the TeX.SX site recently, there was some discussion about locally over-riding the round-mode = places setting in my siunitx package. One thing this highlights for me is the need to think about which settings to apply globally.

Some siunitx settings are about consistency of appearance, and seem to apply naturally to entire documents. A classic example would be output-decimal-marker: if you are using , as a decimal marker, it should apply everywhere!

However, this is not so clear-cut for many of the options related to number-manipulation. The rounding options in particular are really intended for the case where you have some auto-generated data (say a long list from an instrument), and the real accuracy is not as great as the apparent precision. Instruments are great at providing lots of numbers, but it takes a bit of human thought to decide how many of these are really relevant. So for these cases, setting an appropriate rounding scheme is perfectly sensible.

On the other hand, for a number you’ve typed in yourself I’d hope that you’ve done the thinking part when the number is typed, so rounding by the computer is not needed. That suggests to me that most of the time rounding should not be set as a global option.

Of course, it will depend on the exact nature of the document in question. If all of the data in a document is in tables, all of which need rounding, then there is a performance gain from setting the rounding once globally. So the best I can say, guidance-wise, is ‘think about your document’!

Spaces in file names

Spaces in file names are a constant issue for LaTeX users. As many people will know, TeX is not really very happy with spaces, as they are used to delimit the end of input in a lot of low-level macros. This shows up particularly in two areas: graphics and shell escape. For graphics, the excellent grffile package will deal with many of the issues. When using shell escape, the issue is usually that \jobname may be slightly odd. For TeX Live users, that is not so much of a problem as the name is automatically quoted to protect the space. However, MiKTeX does things a bit differently, and uses a star in place of a space. So you end up with

\edef\example{\jobname}
\show\example
> \example=macro:
->test*file.
l.2 \show\example

which is not exactly helpful. However, it is possible to deal with this, as recently mentioned on TeX.SX. As * cannot normally appear in file names, and \jobname makes all characters have category code 12, a simple approach is to do a quick replacement

\edef\Jobname{\jobname}
\catcode`\*=\active
\def*{ }
\edef\Jobname{"\scantokens\expandafter{\Jobname\noexpand}"}
\catcode`\*=12 %
\show\Jobname

If you want to deal with both TeX Live and MiKTeX, you’d of course need first to test which system is in use (for example using \pdftexbanner).

Updating LaTeX3 support in MiKTeX

The LaTeX3 Project have recently updated the organisation of the various LaTeX3-based packages on CTAN. This means that the older expl3 and xpackages need to be replaced by l3kernel and l3packages. Unfortunately, this seems to confuse MiKTeX, which does not pick up the need to install the new material. So MiKTeX users will need to do this by hand in the MiKTeX Package Manager. This should be a passing problem, but does seem to be causing some confusion for MiKTeX users.

TeXprinter

The TeX Q&A site is attractive to many people not only because of the way it works as a website, but also because the site makes it’s data available for reuse. One thing that many people want to do with useful information is to print it. Now, you can simply print from your browser, but the layout won’t necessarily be ideal. Enter the data back-end, and  TeXprinter. TeXprinter takes the raw information from a question and formats it as a PDF or LaTeX file. That way, you can print something that is actually readable! All of this is done in Java, so there is nothing to install beyond the program itself: great stuff.

Expansion using \romannumeral

There was recent question on TeX.SX about expansion, where I suggested using \romannumeral for full expansion. This idea comes up quite often, so I thought it would be useful to look at how it works.

The \romannumeral primitive was intended to turn integers into roman numerals. As such, the input to \romannumeral should be an integer, in the same way that the input to \number is an integer. However, while \number produces output for both positive and negative integer input, \romannumeral produces no output at all for valid negative integer input. That is pretty clear with a simple case such as

\romannumeral -15

but becomes more powerful when used along with the ` syntax which TeX allows for including an integer

\romannumber -`0

Here, the `0 is converted into a integer which TeX treats as complete: `0 is 48, but `01 is the (terminated) integer 48 followed by a separate 1 and not the integer 481. The important thing for expansion, however, is that TeX always looks for an optional space to gobble after an integer, even in a case like `0 where the integer is automatically terminated.

How does this help with expansion? It’s all to do with how TeX terminate numbers. If we have the demonstration macro

\def\demo#1{%
  \detokenize\expandafter{\romannumeral-`0#1}%
}

the \romannumeral will produce no output (as the number it finds is -48). However, it will expand #1 until it finds an unexpandable token. That means that something like

\def\testa{\testb}
\def\testb{\testc}
\def\testc{abc}
\demo{\testa}

will be expanded to abc without needing to know in advance how many expansions are needed. In a real case, this is a great way to fully-expand \if... tests and so on, leaving only the result, but without needing to know how many expansions are needed (and having long \expandafter runs).

What you should notice here is that TeX will reinsert the expanded result, and will not complain if something non-expandable appears

\def\testa{\relax}
\demo{\testa}

will print \relax, as this is inserted with no errors or loss of unexpandable tokens.

The only proviso here is that TeX stops at the first non-expandable item. So something like

\def\testa{ \testb}
\def\testb{123}
\demo{\testa}

will stop at the space in \testa and not expand \testb. For real applications, that is not usually an issue as we are usually aiming to expand the beginning of the input.