Saturday, April 18, 2009

Helvetica, the Swiss font.

I just watched Helvetica. It's a surprisingly interesting documentary. For some reason, I find typesetting more and more interesting as I write my dissertation. Once I put together my first LaTeX document, I was hooked.

Despite all of its quirks, LaTeX produces some pretty slick results. For virtually every problem, somebody has found a solution and posted a package for it. One really neat package is chemscheme. It works in conjunction with the chemcompounds (or bpchem) package to automatically number compounds in the text and schemes. The result is that I can draw a scheme in ChemDraw with temporary labels, include it in my document as an EPS file, and chemscheme will automatically replace the placeholders with the correct compound numbers. Neato!

Customarily, text is set in Times and figures are set in Helvetica while compound numbers are set in bold. In my document, numbers are set as text figures (old-style or lowercase numbers), while math and compound numbers are set as title figures (regular or lining numbers). This causes a problem. In order to switch between the two, I have to switch between the old-style and lining versions of the fonts. chemcompounds provides the \printcompound{} command, which can be redefined to change the formatting, and chemscheme provides the \schemerefformat{} command, which can also be redefined. However, \schemerefformat{} calls \printcompound{}. Therefore, if I change the font in \schemerefformat{} to get Helvetica, it is overridden by the font chosen in \printcompound{} to get lining figures.

Initially, I tried redefining the sans-serif math font to be Helvetica bold and switching to math mode within figures, but this produced strange results whenever the chemcompounds output was used. The final workaround, was to redefine \printcompound{} each time \chemrefformat is called, print the number in the figure and then set \printcompound{} back. It's a bit of a kludge, but it should work with other font combinations as well. The code for use with the kpfonts and helvet packages follows.


No comments: