A First Set of LATEX Packages

Jim Hefferon

If you are a LATEX beginner and ask, “How do I … ?” then often you will be told that there is a package for that. You may well next ask, “How would I know that? And if there is more than one package then which should I use?”

This list covers most of what beginners want to do. Its goal is to cite one package in each area that is capable and reliable, and that is in MacTEX, MiKTEX, and TEX Live. (There are some extra comments in parentheses that often come up along with the recommendations.)

Introduction

For LATEX users, the canonical archive is the Comprehensive TEX Archive Network, CTAN. It has the latest official versions of the packages in the distributions, with documentation. And, searching by topic is very handy.

You can also see the package documentation installed on your computer by typing texdoc <packagename> in a terminal window.

Before the list, one more note. If you are writing for a journal or institution that has its own package then of course you should use that. Look on their web page and on CTAN.

Every document

To change page size, margins, and orientation, use geometry. Get multiple columns with multicol.

Any document containing signicant amounts of mathematics should use the American Mathematical Society's packages amsmath and amssymb. I also use amsthm for producing theorem environments. Notes: (1) amssymb inputs amsfonts so you don't need to load the latter, (2) many authors also use the caligraphic characters in rfsf, (3) get bold math symbols with bm, (4) load amsthm after amsmath, and (5) don't load amsmath directly, instead get it by loading mathtools for some useful improvements.

You can toss in microtype. My eye can't spot the improvements but I appreciate that it means there are fewer awkward lines.

Inside a document

To tweak lists, use enumitem.

Enhance captions with caption and control floating environments with float. (In particular, this package provides the option ‘H’ to override automatic float placement and put something exactly where you ask.)

Get hyperlinks and turn references into links with hyperref (this should be the last or next to last package that you load). Make cross-references say ‘Theorem 1.2’ instead of just ‘1.2’ with the one-r-ed cleveref (load it after hyperref). Have URL's and file paths that can linebreak with url. (If you use hyperref then note that it has its own commands for the cleveref and url functions.)

I do code listings with listings, although minted is also great. Make single quotes inside verbatim text come out correctly with upquote.

(A tangent: copy and paste for computer code listings would be especially convenient. This is a start for the listings package.

\lstset{basicstyle = \ttfamily, 
        keepspaces=true, 
        columns=fullflexible}

But it is not a full solution. The results depend on the PDF viewer and worse, if your code line begins with blank spaces then after copy and paste those spaces are gone.)

If you use Python, pythontex will show code listings, but it also allows you to execute Python and put the results in your output. Do the same for the Sage mathematics software with sagetex, and similar systems exist for R, Haskell, and Scheme.

There are many package that add table capabilities such as multirow entries and breaking across pages. I most often use array, which lets you define your own column types. To handle units, use siunitx (which also has a table column type for aligning on a decimal point).

Make boxes that are colored or framed, such as boxes for theorems, with tcolorbox.

Graphics and color

To include graphics and do simple manipulations such as resizing, use graphicx. Use the JPG format for photos, PNG for other kinds of raster graphics, and PDF for vector graphics. If your graphic is in another format then convert it to one of these three. (Usually you give the file name without the extension, as with \includegraphics{graph}.) Include parts of a PDF document with pdfpages. Include video or sound using media9.

For colors, use xcolor (although the documentation can be hard to make out).

To make plots and graphics, I use Asymptote, a development of METAPOST with three dimensional constructs. However, many people instead draw graphics inside the document with TikZ.

Front and back matter, headers, footers

To style chapter and section titles, use titlesec. For page headers and footers, reach for fancyhdr. You can tweak the format of tables of contents, lists of figures, etc., with tocloft.

Write exercise answers to an external file so that you can read them in later with answers. I like footnotes at the page bottom so I use footmisc (but I had to hack to change the space between a footnote mark and the footnote). Make an index with makeindex.

Bibliographies are a thorny area. Often you have strict requirements, such as from the MLA. CTAN is a big help here; check out the many styles for both BibTEX and BibLATEX.

Special documents

Make exams and problem sets with the exam class.

There are many, many resume and CV packages. Start with CTAN's cv topic.

To make presentations, use the beamer class. (But with this package you are entering another world, where many of the packages discussed here do not work. For example, section title styling happens via a completely different mechanism.)

Fonts and engines

To see options besides the default Computer Modern fonts, visit the LATEX Font Catalogue, which includes copy and paste code to make each one work.

Beyond that list, you can also use any font that your computer has (which usually works well only if your document does not have much mathematics). To convert LATEX source to PDF there are three programs, called engines. Most people use pdfLATEX. The XELATEX engine and the LuaLATEX engine can leverage the fontspec package to use your system's fonts. (A word about the preprint site arXiv.org. If your document was produced with XELATEX or LuaLATEX then you can only submit a PDF, not the document source.)

LATEX now defaults to UTF-8 encoded input on all three engines. Use babel for internationalization, such as changing the the title of the abstract or the bibliography.

____________________________________________________________________________________

Feedback?

Contact me via hefferon.net. (This version is from 2020-Nov-11.)