# Useful LaTeX packages: within document references

This is part of a short series of entries on LaTeX packages I found useful while preparing the examination copy of my PhD thesis.

Today’s entry is packages relevant to preparing within document references. These are both fairly new to me, although not absolutely now.

## 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.

`usepackage{hyperref}`

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

```usepackage[citecolor=blue,%
filecolor=black,%
% Generates page numbers in your bibliography, ie will
% list all the pages where you referred to that entry.
pagebackref=true,%
urlcolor=blue]{hyperref}```

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:

`see chapter ref{chapref}`

you use the cref command:

`see cref{chapref}`

It handles multiple references nicely too:

`see cref{chapref,anotherchapref}`

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

Use

`Cref{refname}`

to generate capitalised text, eg “Chapter 1” rather than “chapter 1”

To use it:

`usepackage{cleveref}`

It shortens the word “equation” to “eq.” by default, if you don’t like that, then:

`usepackage[noabbrev]{cleveref}`

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 will be shown tomorrow for gb4e.