LaTeX related pages.

Endfloat is a LaTeX package for shifting your figures and tables onto seperate pages at the end of your article, a format requested by some journals. For example, adding


This includes endfloat, which adds to the end of your article

  • a list of figures and their captions followed by
  • the figures themselves on separate pages.

The bit setting the caption color to white hides the captions on the figure pages, since some journals don't like to have them. If you're using hyperref, and you have references from your captions (e.g. to equations, citations, etc.), those may get colored automatically, so they won't be "erased" by the CaptionFont redefinition. You can turn off hyperref's coloring with

\hypersetup{pdfborder=0 0 0}

which turns of the coloring of the link text, and disables the annoying boxes that hyperref likes to draw around links. Note that this will make links hard to find throughout your entire article, but just for the preprint with captionless figure pages, which isn't really a big deal. You can still find them by mousing around in places where you expect them to be.

Posted Wed May 18 16:15:29 2011 Tags: latex

Available in a git repository.
Repository: thesis
Author: W. Trevor King

The source for my Ph.D. thesis (in progress). A draft is compiled after each commit. I use the drexel-thesis class, which I also maintain.

Exciting features: SCons build; Asymptote/asyfig, PGF, and PyMOL figures.

Posted Wed Nov 17 07:26:28 2010 Tags: latex

Available in a git repository.
Repository: drexel-thesis
Author: W. Trevor King

Drexel, like every other academic institution, has very particular standards for the format of a Masters or Ph.D. Thesis. The library publishes a requirements manual. The LaTeX wisdom of generations of grad students has been assembled into the drexel-thesis class which you, dear reader, can use to easily format your thesis.

I'm the current maintainer, so besides the post in the department wiki, I'm including a page in this blog.

Your compiled thesis will look something like example.pdf (or, in draft mode, example-draft.pdf). Take a look at the manual to get started. You might also want to look at how I've used the class in my own thesis.

Posted Tue Nov 16 17:16:29 2010 Tags: latex

BibTeX is a bibliographic database format and processing tool often used with LaTeX.

Basic usage

At some point in your LaTeX document:

\bibliographystyle{prsty} % Phys. Rev. style

other syles include abbrv, alpha, plain, unsrt, ... In your LaTeX document where you want the bibliography:

\bibliography{wtk} % wtk.bib is the name of the database

compile (using latex for example) with:

$ latex example
$ bibtex example
$ latex example
$ latex example

There are many possible author name formats, but the least ambiguous is von Last, Jr., First Middle. If the von is capitalized (e.g. "Emanuela Di Cola"), use \uppercase:

@String{EDCola = "{\uppercase{d}}i Cola, Emanuela"}

See Tame the BeaST for details.


The Natbib package adds support for other citation styles & link formats.


Customize bibliography with Makebst (latex makebst, from custom-bib), makes .bst (bib-style) format files according to your specifications.


Pybtex is a bibtex processor written in Python. I've modified the trunk code a bit and use it to keep my BibTeX databases neat and tidy.


There are a number of good resources to get you going:

Posted Sat Oct 23 15:23:35 2010 Tags: latex

Available in a bzr repository.
Repository: pybtex
Author: W. Trevor King

I keep my BibTeX databases neat and tidy with my own branch of Pybtex. The actual command used to re-format the files is

$ python -c 'from pybtex.database.input.bibtex import Parser; from pybtex.database.output.clean_bibtex import Writer; p = Parser(); d = p.parse_file("path/to/db.bib"); w = Writer(); w.write_file(d, "path/to/db.bib", p.get_raw_macros())' 2> pybtex.log

Be sure to look over pybtex.log and git diff path/to/db.bib for anything suspicious before committing the new file (you are versioning it with Git right? ;). You may have to do some find-and-replacing to handle changed keys and consolidate or rename automatically generated macros.

You might also be interested in bibtool, but I'm more comfortable tweaking things in Python.

Posted Sat Oct 23 15:23:35 2010 Tags: latex

Available in a git repository.
Repository: problempack
Author: W. Trevor King

I've put together a LaTeX package problempack to make it easier to write up problem sets with solutions for the classes I TA.


The package takes care of a few details:

  • Make it easy to compile one pdf with only the problems and another pdf with problems and solutions.
  • Define nicely typeset environments for automatically or manually numbered problems.
  • Save retyping a few of the parameters (course title, class title, etc), that show up in the note title and also need to go out to pdftitle and pdfsubject.
  • Change the page layout to minimize margins (saves paper on printing).
  • Set the spacing between problems (e.g. to tweak output to a single page, versions >= 0.2).
  • Add section level entries to the table-of-contents and hyperref bookmarks (versions >= 0.3).

The basic idea is to make it easy to write up notes. Just install problempack.sty in your texmf tree, and then use it like I do in the example included in the package. The example produces a simple problem set (probs.pdf) and solution notes (sols.pdf).

For a real world example, look at my Phys 102 notes with and without solutions (source). Other notes produced in this fashion: Phys201 winter 2009, Phys201 spring 2009, and Phys102 summer 2009.


A related package that defines some useful physics macros (\U, \E, \dg, \vect, \ihat, ...) is my wtk_cmmds.sty. This used to be a part of problempack.sty, but the commands are less general, so I split them out into their own package.


The final package in the problempack repository is wtk_format.sty, which adjusts the default LaTeX margins to pack more content into a single page.

Posted Thu Oct 14 08:50:54 2010 Tags: latex

PGF (Portable Graphic Format) provides LaTeX-style graphics for LaTeX. Take a look at these examples. The manual is pretty readable (and pretty pretty ;), but sometimes lacking in detail. There's only so much you can fit into 500 odd pages ;). Don't get intimidated, the size is due to the quantity and quality of useful macros.

Posted Tue Oct 5 11:06:19 2010 Tags: latex

Asymptote is a C++ style graphics drawing package for LaTeX. I've written a few libraries to make it easier to draw pictures for physics problem sets (as part of my course website package). Here are a few teasers (rendered as SVGs).




To see the Circ library in full form, check out this writeup of a recent recitation problem.


Posted Tue Oct 5 11:01:01 2010 Tags: latex

Hate repeating yourself? Love macros? LaTeX lets you write `beautiful documents' (PDF, DVI, HTML, ...) with macros. It can be a bit tricky to get things just right, but once you figure it out, it's easy to reuse the code.

Take a look at my packages, the Drexel Liki page, the source for most of my papers (if you scroll to the bottom of a paper's HTML, there is a source files link), and my thesis.

If you're interested in LaTeX and graphics, you'll probably be interested in Asymptote and PGF.

Posted Tue Oct 5 11:01:01 2010 Tags: latex

Recently I've been writing up an article for one of the Elsevier journals using their elsarticle LaTeX package. Unfortunately, their BibTeX style file, elsarticle-num.bst (version 1.1, 2008-10-13), is a bit broken. With the help of Nicolas Markey's excellent Tame the BeaST, I've fixed it up so it runs without errors (!), works with natbib's \citet{}, and conforms with the examples posted in the International Journal of Biological Macromolecules' author guide.

Update: Oct. 6. Turns out the code linked from Elsevier is out of date. Rishi over at River-Valley (writers of the elsarticle package) pointed me to some more up to date documentation and source. Version 1.2 fixes most of my problems (with elsarticle-num-names.bst), but I'm still not sure why it doesn't replace elsarticle-num.bst entirely...

Posted Mon Oct 5 13:01:49 2009 Tags: latex