BibTeX bleg

I have written a little standalone script in python that parses a LaTeX file with \cite{} commands and the relevant BibTeX file and produces:

  • formatted HTML suitable for dropping into your homepage
  • individual .bib files for each paper
  • linking to archival versions via a DOI reference or URL
  • linking to a local pdf via the local-url field

The point was to make updating the publications on your homepage just epsilon more difficult that updating a BibTeX file/your CV. Of course, this is moot for people who have other folks to update their pages, but for us plebes, it could save a little hassle.

Clearly you could customize the output format to your needs. However, at the moment it’s not very robust (or efficient, or pretty). I’d like to test it out on likely readers of this blog’s personal .bib files to make it useful before sticking it on github. A subset of readers of this blog are likely to be people who might use such a thing, I’d like to know what your .bib files look like. Because BibTeX has a fair bit of variability, I am pretty sure that I did not catch most of the corner cases in my regexps.

So if you are interested, please do send me a representative file to my TTIC address. Thanks a ton!


Updated perl script for merging TeX files for ArXiV

Manu Sridharan (blog) left a comment the other day on my old post on my script to merge multiple TeX files (and strip the comments) for posting to ArXiV. He’s created a git repository for it, which seem so much more official and stuff. It’s at:

Thanks a bunch, Manu!

As a side note, Péter Gács has a de-macro script to eliminate all of your private macros if you’re so inclined.

What are your favorite LaTeX macros?

I have quite a few collaborative writing projects going on in parallel now. One side-benefit of collaborating is that you learn neat LaTeX macros that your co-authors have developed that end up saving lots of time (or making the TeX equations more readable). Some people invent a whole set of macros for each paper (so that the macros stand for semantic concepts like “input variable”), but I do that mainly for small stuff, like different epsilons. What I do have are macros for are

  • font types and weights : using \mathrm{}, \mathcal{}, etc. is for the birds
  • functions : KL-divergence, mutual information, conditional mutual information etc. I get in trouble sometimes because I use the I(X \wedge Y) instead of I(X; Y) for mutual information, but we can change that in the macro!
  • norms, inner products : these are just functions anyway
  • epsilons : this helps keep different epsilons clearer, actually, and makes debugging proofs a little simpler.

I somehow never get around to making macros like \cX for \mathcal{X}, but maybe that would make my life easier. The nice thing about macros for functions is you can put in auto-sizing delimiters in the macro, saving some \left and \right‘s. What are your favorite things to make into macros?

PSA for Allerton authors who use TeXShop

The papercept website will throw an error if your final PDF is lower than version 1.4. If you use latex -> dvips -> ps2pdf then you will likely get PDF 1.3.

To fix this in TeXShop, go to Preferences and select Engine. Under “Tex + dvips + distiller” enter simpdftex tex --maxpfb --distiller ps2pdf14 and you should be good to go.

More posting about Allerton later!

Updated LaTeX Poster Package

I updated the poster package that I had written for doing large-format conference posters in LaTeX. The updated package uses PGF and TikZ, which is a way of making beautiful figures in LaTeX. I’ve been using pstricks to make figures for a while, and while it works for me, getting it to work with pdflatex is a pain. Luckily, TikZ works in both the PostScript-based workflow as well as the direct-to-pdf workflow. Many thanks are due to Massimo Canonico for his feedback and comments.

musical epigraphs

In my ongoing quest to learn more about LaTeX than I really wanted to know, I have figured out how to use lilypond together with a redefined \chapter command. Of course, it’s all worth it because I can do this:

Chapter 2 plus epigraph

In other news, I’ll finish writing about ITA when I get more than 20 minutes of contiguous time.

LaTeX instructions

To use \LaTeX on this blog, you first use a dollar sign and “latex” like this:

$latex x = \frac{ - b \pm \sqrt{b^2 - 4 a c} }{2 a}

then you can close it with another dollar sign:


Putting it all together, the renderer will give you:

x = \frac{ - b \pm \sqrt{b^2 - 4 a c} }{2 a}

Basically, it’s like writing latex, except that every time you have to go into math mode, you have to type “latex” right after the first dollar sign.

perl script for merging .tex files for ArXiV

I thought a good use of part of my Sunday would be to (re?)learn a little Perl and make my life a bit easier. Suppose you have a paper that’s split up into many files. This script will parse your main LaTeX file and generate a single LaTeX file for the whole paper. It searches recursively for “\input{}” commands and replaces them with the relevant file. It seems to be functional enough to use, but everyone has their own LaTeX usage conventions, so YMMV.

This is particularly handy for submitting papers to ArXiV, which requires a single .tex file, and cutting and pasting in 20 little files can become a bit of a pain. With the perl script for stripping comments, you can generate the .tex for your ArXiV submission on the fly.

I spent a little time searching for a script like this online, since I’m sure many people have written such a thing, but I didn’t turn anything up. Hopefully this will be of use to others looking for a similar hack. Sorry for the lines getting chopped off in the display — it should show up if you cut and paste the text.


# Script for merging tex files into a single monolithic file.  This
# script should make it easy to generate an ArXiV-friendly single
# .tex file from a paper that is broken into subfiles using LaTeX's
# \input{} command.
#     ./  [input]  [output]
#     ./  mypaper.tex  mypaperMerged.tex
# mergetex takes two arguments, the [input] file and the [output]
# file into which the merged files should go.  It recursively
# searches [input] and adds any file given by uncommented \input{}
# commands.
# v0.1 by Anand Sarwate ( with tips from Erin Rhode.

use IO::File;

if ( scalar(@ARGV) != 2) {
   die "Syntax Error : use ' [input] [output]'"
$infile = shift;
$outfile = shift;
print "Generating tex file from $infile and storing in $outfile.\n";
my $outputfh = new IO::File($outfile, "w") or die "Could not open $outfile: $!\n";
my $inputfh = new IO::File($infile, "r") or die "Could not open $infile: $!\n";

sub parsetex {
  my $fh = shift;
  my $file = shift;
  print "Found $file.  Merging into $outfile.\n";
  while () {
    # strip out comments
    $decom = $_;
    $decom =~ s/^\%.*$/\%/;
    $decom =~ s/([^\\])\%.*$/\1\%/g;
    # search for lines with "\input{}"
    if ($decom =~ /\\input{(.*?)}/) {
      #get new file name
      if ($1 =~ /.tex/) {
        my $newfile = $1;
      } else {
	$newfile = $1 . ".tex";
      # recurse to input new file
      my $newfh = new IO::File($newfile, "r") or die "Could not open $infile: $!\n";
    else {

Changing editor colors on TexShop

A Pair of TeXShop Applescript Macros gives two scripts that let you change the font highlighting on TeXShop’s editor so you can get light text on dark backgrounds (for example). This was surprisingly difficult to locate, but might be of use to those who eschew Emacs.

(This link comes to you via Galen Reeves.)

UPDATE : I’ve been informed that the script will not change the text color on the latest version of TexShop. I’m not sure why that is…