Quick Search

# LaTeX packages

These are useful LaTeX packages. Examples here are just sketches, look at the package document for full usage.

## natbib

This is one of the most sophisticated and widely used packages for Harvard style referencing (ie, "(Surname, Year)" rather than "[1]" style references).

Inside your text use \citep for a reference in parentheses "(Surname, Year)", and \citet for a in-text reference "Surname (Year)". Important note, the plain \cite command is equivalent to \citet, which you may not expect.

You can use \citeauthor to get just "Surname" and \citeyear to get just "Year".

## bibentry

This is a useful add-on to natbib, which allows you to insert full bibliography entries into the body of your text. This is useful in the declaration portion.

Then later on if you want to insert a full bibliography entry into the middle of your text:

## rotating

If you have a big table or figure that should be rotated sideways onto its own page:

And then you can replace the table and figure commands with:

## dcolumn

The dcolumn package produces tabular columns that are perfectly aligned on a decimal point (ie all the decimal points in that column are exactly underneath each other), which is usually how you want to display decimal numbers.

Now that you have defined the column type, you can use d in the tabular environment, where the numeric argument is the number of figures to expect after the decimal point. You don't have to use exactly that number of figures in every entry, just that that's how much room it will leave.

One annoying aspect of this package is that for the headers of that column, which probably aren't numbers, you will need to use \multicolumn to get them to display nicely.

You can mix the d column type with the usual l, r and p column types.

## threeparttable

You can't use \footnote in a floating table. This is one of several packages that allow table footnotes in various ways.

threeparttable doesn't cause tables to float on its own, so you usually want to wrap in a table command:

Unfortunately you need to generate the a, b, c (or whatever) numbering manually.

The general \tnote entries are useful for things like "Bold entries are highest in the column", so that they don't need to go in the caption.

## hyperref

This package turns cross-references and bibliography references into clickable links in your output PDF (at least if you generate it with xelatex or pdflatex), without you having to do anything other than the \ref (or cleveref's \cref) and \cite and so on commands.

You will probably want to modify its choice of colours to something more subtle:

Use black if you want the links the same colour as your text.

One note with hyperref: generally it should be the last package you load. There are occasional exceptions, see Which packages should be loaded after hyperref instead of before?

## cleveref

cleveref is a LaTeX package that automatically remembers how you refer to things. So instead of:

you use the \cref command:

It handles multiple references nicely too:

will generate output along the lines of "see chapters 1 and 2".

Use

to generate capitalised text, eg "Chapter 1" rather than "chapter 1"

To use it:

It shortens the word "equation" to "eq." by default, if you don't like that, then:

For some packages that don't yet tell cleveref how to refer to their counters, you will get output like "see ?? 1" rather than "see example 1". You use the \crefname command in the preamble to tell it what word to use for each unknown counter, examples of \crefname are shown below for gb4e.

## gb4e

gb4e is a linguistic examples package.

Input looks like:

You can mark sentences with * and ? and so on:

You can do sub-examples:

A few things to do to make gb4e play really nicely. First, some cleveref config. gb4e doesn't yet automatically tell cleveref how to refer to examples, so you need to tell it that the term is "example", and second, if you want braces around the number ("example (1.1)" rather than "example 1.1" you need to tell it to use brackets:

Also, by default, the gb4e numbering does not reset in chapters. That is, your examples will be numbered (1), (2), (3) etc right through a thesis. You probably want more like (1.1), (1.2), (2.1), (2.2), ie chapter.number. Change to this with the following in your preamble:

You could also get it to reset in sections by replacing \chapter and \thechapter with \section and \thesection in the above.

• No labels