Some Useful Latex Packages

I am currently working (again) on a larger writing project in Latex. Doing so made me revisit the Latex ecosystem, and I discovered several useful packages that I had not known before.

vertbars

The first is vertbars. This is a simple package that defines a new environment, called vertbar (no trailing s!). All it does is to place a vertical bar into the margin: a useful indicator for sections that need more work.

Pretty much anything, including equations, can be wrapped in a vertbar environment; the package seems robust and is trivially easy to use. (In contrast to the fancier changebar, which I simply couldn’t get to work in the amount of time I was willing to spend on it.)

The package is very rudimentary: you get a vertical bar, of adjustable width, admittedly, but for instance no colors. The upside is its extreme simplicity.

booktabs and tabulary

Getting tables in Latex “just right” is always a pain — in particular the vertical spacing of horizontal lines is never quite right and requires painful manual fixing.

This is where booktabs comes in. If you include this package in your Latex source (using \usepackage{booktabs}), it changes the default table layout, without any further ado: you create your tables as you would have, and they look better.

The booktabs package prohibits the use of vertical lines. This may be a show-stopper for some, and certainly rules it out for some applications. But many tables in technical documents don’t actually need vertical bars; they will, in fact, look better without them.

The package defines some additional commands to draw horizontal lines, but is otherwise very bare-bones.

I should also mention tabulary, as a replacement for the venerable tabular environment. It creates a table of a desired width, distributing the space reasonably among columns.

Both packages taken together have made creating a table a much more pleasant process.

fancyverb and fvextra

The fancyverb and fvextra are larger packages providing “fancier” versions of verbatim environments of non-interpreted text — as needed for code listings and similar texts.

The packages provide many features to style the result, such as cute horizontal lines at the top and bottom, and a very nice and flexible way to generate and print line numbers. But what really convinced me was the ability of the package to transparently import text from an external file! Brilliant — finally it is possible to keep source code and a manuscript referring to it in sync, without any additional tooling. (It is also possible to include only parts of the input file. And the line numbers can be adjusted separately. It really works great.)

One oddity: if you also happen to use the fancybox package, then the \usepackage{fancybox} must precede \usepackage{fancyvrb} in your document’s preamble.

My own \soon{} macro

Having mentioned fancybox, I might also explain what I need that package for. I define the following command in the preamble of longer documents:

\newcommand{\soon}[1]{
\begin{center}
\cornersize*{2mm}
\setlength{\fboxsep}{3mm}
\ovalbox{\parbox{4.5in}{\textit{#1}}}
\end{center}
}

This allows me to add notes to myself into the document, like this:

\soon{Don't forget to revise this section!}

They will show up as a centered, boxed comment — impossible to miss! The comments are intentionally not placed in the margin, for two reasons:

  • No restriction on the length of the comment; it may be as verbose as convenient in the moment.
  • No chance to miss or overlook the comment, even during a most casual once-over.

It’s also easy to omit all comments from the generated document (for instance to share with reviewers): simply remove the body from the definition of the command, and run Latex again.

I know that there are (several) packages that provide similar functionality, but I have never encountered one that I found as practical and convenient to use.