## achemso installation

One question that crops up from time to time is “How do I install achemso?” For most people, I tend to point out that the latest MiKTeX and TeX Live distributions include both achemso and everything it needs to work. So on a stand-alone system, installing an up-to-date distribution is the easiest way.

Manually installing achemso itself is not too hard, the main problem being that people miss out the BibTeX files (achemso.bst and biochem.bst), then get odd effects with bibliographies. On CTAN, the file achemso.tds.zip contains everything laid out ready for installation, and that includes the BibTeX files. So my advice for those who can’t or don’t want to do a full update is to use the TDS zip. For those who want to extract from the source and do everything themselves, as I say the main thing is not to forget the BibTeX styles.

One problem that comes up is the need for a reasonably recent copy of xkeyval. If I was writing the code again from scratch, I probably would not use xkeyval, but that is not the situation. I’ve worked quite hard to reduce the problems, and the latest version of achemso uses only the most basic functions in xkyeval. One of the reasons that life is a bit complex is because xkeyval requires installation of items in both tex/generic/xkeyval and tex/latex/xkeyval: not ideal. At the moment, there is no TDS zip on CTAN for xkeyval, but I’m always happy to send anyone who needs one a suitable zip by e-mail.

## siunitx: Revising the units

Working on siunitx version 2, I’ve been carefully back over the SI units. So the core code now defines everything that is listed in the various tables, plus \percent (seems pretty sensible) and the US spellings \meter and \liter (realism). Most of the units are easy enough to give a macro name to, but the speed of light (\clight) and reduced Planck constant (\planckbar) are possibly a bit odd. The minutes and seconds of arcs (\arcminute and \arcsecond) obviously need different names from the same units for time, and I hope make sense.

More awkward are the things beyond the SI units. I’m revising the abbreviations and so on, to bring more order to how everything is done. The real problems are the more specialist units that need to be defined (realism again), but that are clear non-SI. In my own area (chemistry) we tend to use “molar” (moles per cubic decimetre) a lot, and so that is in. In the same way, there are some other areas that I’ve had good feedback on and know what is needed. However, there are also some odds and ends that I’m less sure on. High-energy physics seems to have a lot of units in the hepunits package, but I don’t know how many are really needed. Similarly, there are some older units for radiation does (roentgen’s and rad’s) that I don’t really know what to do with.

I’m keen to get any ideas about the current direction. There will probably be another snapshot of the code and documentation in a couple of weeks, which will add a lot more of these awkward units. So take a look and make suggestions, either at the snapshots or at the development code.

## siunitx version 2: snapshot 3

It’s been a while since I gave an update on progress with siunitx version 2. I’ve had other things on the go, but am trying to make some progress with the code as I have lots of bugs which are fixed in the new version. Since the last snapshot, I’ve gone back over everything and moved internally to expl3 syntax. That makes my life a lot easier, as there are lots of tools available without needing to write them all for myself. It does mean that users/testers will need to have expl3 installed: you will need the most recent release, which should appear in TeX Live and MiKTeX soon for online installation, or can be downloaded from CTAN (look for expl3.tds.zip).

There are some notes and outstanding questions with the current snapshot: it is still some way from being finished. Things to be aware of or to think about:

• Places where units should be repeated are not working properly at the moment. That is the next thing I need to sort out: I’d hope it will be done soon (perhaps another snapshot in a couple of weeks)
• I’d set the defaults to use text mode for units and maths mode for numbers. This may not stay that way, see for example the results for \SI{1.23}{J.mol^{-1}.K^{-1}}. This is because printing units literally has to do the powers in the same font as the units.
• The options system is now using the LaTeX3 l3keys module. Following the pattern that looks likely for LaTeX3 work, I’ve given the options names divided into words using hyphens. I hope that they make sense.
• At present, complex numbers are always printed with the complex root (i) after the number. I need an option to reverse this, but can’t think of a good name.
• I’ve tried to simplify the various ‘trapambig…’ options into a single one (use-brackets). I’m not sure if this will work for everyone: do people need the ability to turn bracketing on and off in a more granulated way?

For those who want to test things out, you can get:

## LuaTeX 0.45.0

I see from the LuaTeX mailing list that version 0.45.0 has been released. There is the usual long list of new things and bug fixes, but some that caught my eye:

• \input and \openin now accept braced filenames;
• The new primitives \aligntab and \alignmark are aliases for the use of & and # in alignments;
• LuaTeX can now optionally use kpathsea to find lua require() files.

## siunitx: Default mode for printing

A while ago, someone e-mailed me about siunitx and the current choice of fonts for printing. At the moment, the package uses the current maths font for both numbers and units. It was suggested that a better standard setting would be maths font for numbers, text font for units. I’m not going to alter this for version 1, but as I work on version 2 this is something worth considering. In most documents, the difference should not show up. However, I wonder what people think: I can see the logic to the request, but don’t fancy getting lots of complaints either. Comments welcome!

## TeX counts and LaTeX counters

When answering questions about storing and manipulating numbers, there is often a choice between using a TeX count and a LaTeX counter. For new users, the difference between the two is not necessarily clear, so I thought it would be worth summarising how things work.

At the LaTeX level, a counter is created using

\newcounter{mycounter}

This creates a counter initialised at zero which can then be set using

\setcounter{mycounter}{4} % Or whatever

or manipulated using \stepcounter and \addtocounter

\setcounter{mycounter}{0}    % Value is 0
\stepcounter{mycounter}      % Value is 1
\stepcounter{mycounter}      % Value is 2
\addtocounter{mycounter}{3}  % Value is 5

There are then some methods to get the counter value back out. LaTeX creates a \the… function for each counter, which will print the current value. In places where TeX expects a number, there is also the \value function:

\themycounter % Prints the current value
\ifnum\value{mycounter} > \value{myothercounter}%
% Do stuff!
\fi

This covers a lot of what you might want to do, so the need to use the lower-level TeX system is not obvious. Perhaps the most important thing to notice is that LaTeX’s counters are set globally. That makes them good for tracking something that covers the entire document, but not as good for localised calculations.

How about at the TeX level? A count is created using

\newcount\mycount

where the name is a name including a backslash. Setting a count is done very simply: there is no set function

\mycount 4\relax

Notice the \relax here. Without it, TeX will continue to look for the number in the next thing it finds. This can have some odd effects, and is best avoided. Altering the value can then be carried out using \advance

\mycount 0\relax         % Value is 0
\advance\mycount 1\relax % Value is 1
\advance\mycount 1\relax % value is 2
\advance\mycount 3\relax % Value is 5

The value of a count register can be recovered using \the or \number, and the name itself can be used where TeX expects a number.

\the\mycount   % Prints the current value
\number\mycount % The same result
\ifnum\mycount > \myothercount
% Do stuff!
\fi

The big difference is that TeX sets count registers locally. So to do a global assignment you have to do it deliberately

\global\mycount 3\relax

As LaTeX is built on TeX, you might guess that LaTeX’s counters are an interface to TeX’s count registers, but it’s not immediately obvious how this is done. The way it works is that LaTeX prefixes all of the counter names with c@, so that if I did

\newcount\c@mycounter
\newcounter{mycounter}

LaTeX would issue an error message: the counter is already defined. The other LaTeX functions then build on this, so that they manipulate the internal counters. This is all done globally and with some error checking. For example, the definition of \addtocounter is

\def\addtocounter#1#2{%
\@ifundefined{c@#1}%
{\@nocounterr{#1}}%
{\global\advance\csname c@#1\endcsname #2\relax}}

This checks the counter exists, and if it does globally advances it.

Why choice one or other method? Well, LaTeX does error checking and also adds some refinements (such as resetting one counter based on another). It also ensures you always include the appropriate \relax statements to avoid TeX picking up “extra” material for numbers. On the other hand, if you want to do local assignments then you have to use TeX’s count registers: LaTeX always does global assignments. I tend to find that for document-level things counters are best (anything I actually want to print), whereas count registers are more flexible for programming.

I was at the UK-TUG AGM at the weekend, and amongst other things there was a workshop on “LaTeX Documentation and Support”. One of the topics that came up was how questions are answered in different forums (comp.text.tex, the texhax list, the LaTeX Community, Stack Overflow, etc.). How to answer questions was a topic of some discussion, the essential question being how far to go down the educational route when answering a question. Do you just give an answer that works, or do you give the background and help the questioner to learn about (La)TeX in a wider sense?

There is no right answer to this, of course. If the question is about plain TeX, then I tend to aim for the “full explanation” approach. On the other hand, you see questions which start “My professor says I have to use LaTeX, …”, where getting things done tends to be the main point. Of course, a lot of questions fall in the middle somewhere. Then you have to hope that you can judge the answer about right: some explanation, but not too much!

There’s also a cultural aspect. Questions asked on c.t.t. tend to get more involved answers than those on the LaTeX Community, for example. That reflects the type of questions asked and also the spread of “regulars”.

## Background colouring in TeXworks

The current experimental builds of TeXworks now include the ability to alter the background colour of text, as well as the foreground. At the moment, you can’t do this in an additive fashion (varying the two independently). However, it does make it easy to have something a bit nicer than the default bright red for comments. I’ve altered my syntax-patterns.txt file for LaTeX to read

[LaTeX]
# special characters
darkred		N	[\$#^_{}&]

# LaTeX environments
darkgreen	N	\\(?:begin|end)\s*\{[^}]*\}

# LaTeX packages
darkblue	N	\\usepackage\s*(?:$[^]]*$\s*)?\{[^}]*\}

# control sequences
blue		N	\\(?:[A-Za-z@]+|.)

black/lightgrey			Y	%.*

You’ll see that the last line includes two colours, so I get black on light grey for comments.

## TeX Live 2009 released

A quick note to say that TeX Live 2009 has been released. The MacTeX web pages will probably get updated over the next few days, and I’d expect we’ll also hear about the DVD. Testing TeX Live 2009, everything has worked very well, so I’d not expect any problems.

## Windows TeX Users: MiKTeX or TeX Live

I was talking to someone at work recently, and the topic of whether to choose MiKTeX or TeX Live on Windows came up. With MiKTeX 2.8 released and TeX Live 2009 due out any day, I thought I’d make a few comments.

First, both systems are very capable, so there is not really a “wrong” decision. However, when installing you do have to pick one. In the past, MiKTeX was the best choice for Windows by a distance, but recent work on TeX Live has altered this. So I’d say there are some factors to balance against each other.

• If you work on Windows and on Unix, then TeX Live is the system to favour. It preforms essentially in the same way across platforms, whereas you’ll get some minor differences if you use MiKTeX on Windows and TeX Live on Unix.
• If you want to only install what you use, go for MiKTeX. TeX Live doesn’t have anything to match the auto-installation system in MiKTeX.
• On the other hand, if your happiest installing everything in one go, go for TeX Live. It does this by default, and includes any new packages when you do an update. For MiKTeX, a full installation is something you have to do deliberately.

As you’ll see, there is not much in it! I’m mainly using TeX Live, but still have MiKTeX around as well.