Saturday, March 21, 2009

rspublic.cls fixed to get rid of nasty Incomplete \if errors

Depending on how updated your LaTeX distribution is, if you try to use the Royal Society's rspublic.cls to build your compuscript, you may get nasty incomprehensible errors like:
! Incomplete \if; all text was ignored after line 7.

I didn't get these errors on my home system (which has TeX Live 2007 installed), but I got them on Manuscript Central for Proc. R. Soc. B, and that's a major problem.

After two days of binary searching through possible sources of the problem, I found it. Jonathan Wainwright (the author of the document class) used a \phantom in both the \@oddhead and \@evenhead without preceding it by a \protect. The \phantom macro is fragile, which means that it can cause major problems when put in contexts that move around (like headers). So it needs to be protected.

I added \protect in front of each of the two \phantom calls, and all was well in the world.

I've posted a fixed version of the document class at:Give it a shot. That version also allows for 11pt and 12pt fonts, and it defines \@ptsize, which setspace needs to exist in order to work (i.e., for double spacing).

Friday, March 20, 2009

natbib-compatible BST file for Royal Socety journals

I just whipped up rspublicnat.bst, which is a natbib-compatible BibTeX style file (BST) for the Royal Society journals (e.g., Proceedings of the Royal Society A and B and others).

FYI, the BST can be regenerated by applying LaTeX (i.e., docstrip) to rspublicnat.dbj and then applying rspublicnatbst.patch (with patch) to the resulting BST file. The patched result should closely match the Royal Society's bibliographic conventions for both in-line and listed references.

Thursday, March 19, 2009

Removing hyperref's space inside \autoref

Many journals (e.g., any of the Royal Society journals) prefer sections to be identified with the section symbol (§) rather than the word "section" followed by a space. If you use \auotref, one of the wonderful macros provided by the hyperref package, then you'll want to do something like...
Unfortunately, \autoref will still insert a space between the section symbol (\S, which renders as §) and the section number. So, as discussed in a comp.text.tex posting, you'll need to be more clever and do something like (the ~ character is the "tilde", which is on the upper-left of most keyboards; it's a LaTeX "tie"—a non-breaking space)...
instead. That will eat the space that \autoref inserts after the section. Voila!

Tuesday, March 17, 2009

Perl script that generates CSV and BerkeleyDB versions of LTWA list

UPDATE: If you're wondering why I just didn't save the LTWA database and search it every time I needed to abbreviate a journal, it's because I wanted to optimize for speed downstream. That is, I did all the possible processing now to speed things up later. I've also augmented the script to do the opposite (and save the results in other smaller files) so that I can tell the downstream process to take longer (and possibly have better results with less spurious entries in the hash table). I've also updated the downstream script to save any successful lookups locally to speed up successive runs. Again, contact me if you want more details.
I'm sick of looking up ISO 4 standard journal abbreviations from the List of Title Word Abbreviations (LTWA) hosted at ISSN's LTWA online. The most annoying thing about LTWA online is that you can't get one big list unless you have them mail you a paper copy (for a price). So you have to resort to clicking each letter and waiting for the list for that letter to come up.

So I wrote a Perl script that automatically cURLs each LTWA online page down, processes it, and generates both CSV and BerkeleyDB (BDB) hash files containing a list of words and their associated official LTWA abbreviation. I use the BDB file in another script to automatically generate BibTeX database files for each of my journal papers (that script first checks a list of known-good journal abbreviations before trying to generate the abbreviation itself).

There were several challenges to such a task, and the list isn't perfect. I focused on one-word entries. For more complicated abbreviations, I figured I'd lean on my list of known-good journal abbreviations. That still left LTWA entries like "psycholog-" and "bulletin-" which use "-" to imply "and any other character." So I used a typical /usr/share/dict/words list to generate a list of English words that matched each pattern. Because such lists don't usually include plurals, I used Lingua::EN::Inflect to generate plurals and then took all of the plurals that included the singular (i.e., that would also match the LTWA pattern).

So that works well for me. Someday I might put the script and/or the files it produces on-line. For the moment, if you want any of these, contact me and let me know. I'll share.

Wednesday, March 11, 2009

"Interference" seems like an appropriate name

I got a request from a marketer that I link to his product from this blog:From him:
Inference is a Microsoft Office add-in that has a point-and-click interface for adding MATLAB code, .m files, and structured data to Word and Excel documents. If you use Microsoft Office, Inference is an alternative to EX Builder and Notebook for generating reports, reproducible research, and Office applications. And regardless of whether you use Office, Inference has an integrated development environment (Inference Studio) with an intelligent editor that features breakpoints and edit-and-continue.
I have no idea why you would possibly need such a thing. I view software like this as predatory—it preys on people who think they're helpless. They end up overlooking existing easy solutions (like using the debugging features of MATLAB's own editor) and get distracted from finding truly good solutions.

Perhaps I'm being a little too harsh. Interference's own website gives a better description of its features:
Inference for MATLAB allows you to:
  • Execute MATLAB code directly inside of Microsoft Word to create formatted reports that contain explanatory text and graphical/code output.
  • Execute MATLAB code directly inside of Microsoft Excel to create dynamic spreadsheets that leverage existing Excel functionality.
  • Store all of your MATLAB code, data, and M-Files inside a single Microsoft Word and Excel document.
If you have use for such a thing... Give it a whirl, but don't come to me for help.

(by the way, my LaTeX build environment does the equivalent of "Interference for MATLAB" for LaTeX users. Among other things, if you \includegraphics{image_name} and the build environment finds an image_name.m file, it will automatically generate an image_name.eps (or image_name.pdf) whenever the MATLAB script gets updated)

Vatican: Washing machine liberated women

I first heard this on NPR this morning:
The Vatican has figured out women's liberation. The Vatican newspaper says the washing machine did more to liberate women in the 20th century than the pill or the right to work. The article is entitled: "The Washing Machine and the Liberation of Women - Put in the Detergent, Close the Lid and Relax."
Some related links from Google news:Pretty funny. Sounds like something that should have originated on The Onion, but it's real. Go Catholics!