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.

\fi
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...
\renewcommand*\sectionautorefname{\S}
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)...
\def\Snospace~{\S{}}
\renewcommand*\sectionautorefname{\Snospace}
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!

Wednesday, February 25, 2009

My Flowering Green Tea

Do I take it out after 3 minutes? I dunno. It seems a little strong... and strange.
It started out as a ball that looked a bit like an owl pellet.

Wednesday, January 28, 2009

Non-breaking Spaces in Word/OpenOffice Writer

I use LaTeX primarily for all of my printed document preparation, but I have to teach people how to write in Word/OpenOffice Writer, and so it still is interesting to me to find out how to do new things.

I've wondered how to make non-breaking spaces (NBSP) in Word for a long time, but I didn't force myself to actually look it up until recently. Evidently, if you type
Control+Shift+Space
in Word, you generate a NBSP. This same combination works in OpenOffice Writer, but I think only Control+Space is needed.

A non-breaking space tells the Word Processor to never break lines at that spot. That is, a non-breaking space can never end or begin an automatically wrapped line. You should use NBSP's to prevent
  • periods at the end of lines that do not terminate sentences
  • numbers or bullet-like symbols at the beginning of lines that do not initiate list items
For example,
  • Replace "Mr. Jones" with "Mr.(NBSP)Jones"
  • Replace "Figure 2" with "Figure(NBSP)2"
  • Replace "Table 3.1" with "Table(NBSP)3.1"
  • Replace "Equation (5)" with "Equation(NBSP)(5)"
  • Replace "over there – in the hallway" with "over there(NBSP)– in the hallway"
That's how the big publishers do it. However, you never notice it because it's so subtle; when it's done right, you won't notice it at all.

Sunday, January 25, 2009

Bookmarklets for OSU Library proxy

FYI, as of an e-mail sent to me on the morning of January 27, the OSU library system is happy with these bookmarklets and may plan to offer their own version of them in the near future. Thanks, again, for your support.
This message goes out to OSU faculty, staff, and students. Doesn't it make you mad when you're off campus and you want to read a paper and the research database that holds the paper doesn't let you view it because you're not a subscriber? I hate that.

Luckily, the OSU library system provides an "off-campus sign in" that can be used to make your off-campus connection look like an on-campus one so research databases will grant you OSU caliber access. Unfortunately, sometimes it's hard to figure out how to get from the off-campus sign-in to the paper you want. So I've come up with a shortcut, and I implemented it two ways.

Drag either one of the two following bookmarklets to your "bookmarks toolbar" (that strip of bookmarks that rides just below the "location bar" in your browser).
When you're on a page you'd like special access to (e.g., the official site of an academic paper of interest to you), click on the bookmarklet and you'll be transported to that site via OSU's "off-campus sign in." You may have to use your OSU username and password to login the first time you click on the bookmarklet, but after that you should be granted OSU-level access quickly.

(feel free to rename those bookmarklets as you wish; the name "OSU LOCSI" isn't important to their function)

I hope that helps.

Thursday, December 25, 2008

BibTeX Bibliography Style File (BST) for Engineering Applications of Artificial Intelligence (EAAI)

The Elsevier journal Engineering Applications of Artificial Intelligence suggests that authors use the elsart-harv.bst BibTeX bibliography style (BST) file to match its Harvard-style author-year reference format. However, elsart-harv.bst does not match the conventions used in EAAI proofs. In particular,
  • EAAI proofs use "Thesis" (instead of "thesis")
  • EAAI proofs surround the volume of an "in proceedings" entry with commas (instead of periods)
  • EAAI proofs use "vol." (instead of "Vol.")
  • EAAI proofs don't put any space between abbreviated parts of author names (but they do keep the hyphens in hyphenated abbreviations)
So I modified elsart-harv.bst to match EAAI conventions. My modified form is: To use it, just download it, place it in the same directory as your compuscript, and change your
\bibliographystyle{elsart-harv}
line to
\bibliographystyle{elsart-harv-EAAI}
Of course, elsart-harv-EAAI.bst is still natbib compatible.

[ NOTE: More-advanced users may prefer my elsart-harv-EAAI.patch. ]