pages" but this text is a light shade of grey. I disabled colour boxes but I don't seem to be able to modify the colour of this text. Any ideas? It is too. Aug 17, 2004 corresponding \cite appear (there is also the alternative pagebackref, with links leading to the page of the \cite's). In any case, it is always good to indicate the driver for hyperref, for example pdftex or dvipdfm, as an option to this package. In fact, when such an option is given to pittetd, all that is done by the. Note that the citeref package (for adding citation page numbers in the bibliography) must be loaded after natbib. (The hyperref package with the option pagebackref also provides this feature, but with hyperlinks.) The natbib package therefore acts as a single, flexible interface for most of the available bibliographic styles. 1.">

Bibliography Pagebackref

LaTeX enables typesetting of hyperlinks, useful when the resulting format is PDF, and the hyperlinks can be followed. It does so using the package hyperref.

Hyperref[edit]

The package hyperref[1] provides LaTeX the ability to create hyperlinks within the document. It works with pdflatex and also with standard "latex" used with dvips and ghostscript or dvipdfm to build a PDF file. If you load it, you will have the possibility to include interactive external links and all your internal references will be turned to hyperlinks. The compiler pdflatex makes it possible to create PDF files directly from the LaTeX source, and PDF supports more features than DVI. In particular PDF supports hyperlinks. Moreover, PDF can contain other information about a document such as the title, the author, etc., which can be edited using this same package.

Usage[edit]

The basic usage with the standard settings is straightforward. Just load the package in the preamble:

This will automatically turn all your internal references into hyperlinks. It won't affect the way to write your documents: just keep on using the standard - system (discussed in the chapter on Labels and Cross-referencing); with hyperref those "connections" will become links and you will be able to click on them to be redirected to the right page. Moreover the table of contents, list of figures/tables and index will be made of hyperlinks, too. The hyperlinks will not show up if you are working in draft mode.

Commands[edit]

The package provides some useful commands for inserting links pointing outside the document.

\hyperref[edit]

Usage:

\hyperref[label_name]{''link text''}

This will have the same effect as but will make the text link text a full link, instead. The two can be combined. If the lemma labelled as mainlemma was number 4.1.1 the following example would result in

We use \hyperref[mainlemma]{lemma \ref*{mainlemma}}.

We use lemma 4.1.1.

with the hyperlink as expected. Note the "*" after for avoiding nested hyperlinks.

\url[edit]

Usage:

It will show the URL using a mono-spaced font and, if you click on it, your browser will be opened pointing at it.

\href[edit]

Usage:

\href{<my_url>}{<description>}

It will show the string description using standard document font but, if you click on it, your browser will be opened pointing at my_url. Here is an example:

\url{https://www.wikibooks.org}\href{https://www.wikibooks.org}{Wikibooks home}

Both point at the same page, but in the first case the URL will be shown, while in the second case the URL will be hidden. Note that, if you print your document, the link stored using will not be shown anywhere in the document.

Other possibilities[edit]

Apart from linking to websites discussed above, hyperref can be used to provide mailto links, links to local files, and links to anywhere within the PDF output file.

E-mail address[edit]

A possible way to insert email links is by

\href{mailto:my_address@wikibooks.org}{my\_address@wikibooks.org}

It just shows your email address (so people can know it even if the document is printed on paper) but, if the reader clicks on it, (s)he can easily send you an email. Or, to incorporate the url package's formatting and line breaking abilities into the displayed text, use[2]

\href{mailto:my_address@wikibooks.org}{\nolinkurl{my_address@wikibooks.org}}

When using this form, note that the command is fragile and if the hyperlink is inside of a moving argument, it must be preceeded by a command.

Local file[edit]

Files can also be linked using the url or the href commands. You simply have to add the string run: at the beginning of the link string:

\url{run:/path/to/my/file.ext}\href{run:/path/to/my/file.ext}{text displayed}

Following http://tex.stackexchange.com/questions/46488/link-to-local-pdf-file the version with does not always work, but does.

It is possible to use relative paths to link documents near the location of your current document; in order to do so, use the standard Unix-like notation ( is the current directory, is the previous directory, etc.)

Hyperlink and Hypertarget[edit]

It is also possible to create an anchor anywhere in the document (with or without caption) and to link to it. To create an anchor, use:

\hypertarget{label}{target caption}

and to link to it, use:

\hyperlink{label}{link caption}

where the target caption and link caption are the text that is displayed at the target location and link location respectively.

Note also that if you put a hypertarget, when clicking a link to that hypertarget, it may actually direct to the line after the hypertarget, which is not desirable. Therefore if this occurs, you can report the bug and refer to here for a solution.

Viewing in a browser[edit]

You can also get an external URL to the hypertarget by appending #label to the URL for the file, or right clicking one of the hyperlinks to the target and copying the URL, or getting the link from the headings in the sidebar of the PDF, or through a process of deduction from viewing (e.g. subsubsection 11.5.1 would have the label subsubsection.11.5.1). This can be useful e.g. for academic and pedagogical purposes. The URL will then direct to the target if you enable a PDF viewer that is compatible with PDF 1.5 in a browser, such as PDF Viewer for Chrome or Chromium browsers, and No PDF Download for Firefox; and on Android the Xodo app works best with links as it renders them with the correct border as with PDF desktop programs, followed by the Foxit PDF app which renders links highlighted in grey (while in other apps links may also work but without any special rendering, such as the Dropbox PDF viewer app; and yet others do not work with links, e.g Drive PDF viewer, PDF reader and Google PDF viewer). You may need to open the URL to the PDF in a new tab, otherwise it may prompt to download it (i.e. if you are clicking on the URL, don't left click, right click and select to open it in a new tab).

Customization[edit]

The standard settings should be fine for most users, but if you want to change something, that is also possible. There are several variables and two methods to pass those to the package. Options can be passed as an argument of the package when it is loaded (the standard way packages work), or the command can be used as follows:

\hypersetup{<option1> [, ...]}

you can pass as many options as you want; separate them with a comma. Options have to be in the form:

exactly the same format has to be used if you pass those options to the package while loading it, like this:

\usepackage[<option1, option2>]{hyperref}

Here is a list of the possible variables you can change (for the complete list, see the official documentation). The default values are written in an upright font:

Checkout 3.8 Big list at hyperref-manual at tug.org

variablevaluescomment
show or hide the bookmarks bar when displaying the document
allows to use characters of non-Latin based languages in Acrobat’s bookmarks
set the style of the border around a link. The first two parameters (RadiusH, RadiusV) have no effect in most pdf viewers. Width defines the thickness of the border. Dash-Pattern is a series of numbers separated by space and enclosed by box-brackets. It is an optional parameter to specify the length of each line & gap in the dash pattern. For example, {0 0 0.5 [3 3]} is supposed to draw a square box (no rounded corners) of width 0.5 and a dash pattern with a dash of length 3 followed by a gap of length 3. There is no uniformity in whether/how different pdf viewers render the dash pattern.
show or hide Acrobat’s toolbar
show or hide Acrobat’s menu
resize document window to fit document size
fit the width of the page to the window
define the title that gets displayed in the "Document Info" window of Acrobat
the name of the PDF’s author, it works like the one above
subject of the document, it works like the one above
creator of the document, it works like the one above
producer of the document, it works like the one above
list of keywords, separated by commas, example below
define if a new PDF window should get opened when a link leads out of the current document. NB: This option is ignored if the link leads to an http/https address.
activate back references inside bibliography. Must be specified as part of the \usepackage{} statement.
surround the links by color frames () or colors the text of the links (). The color of these links can be configured using the following options (default colors are shown):
hide links (removing color and border)
color of internal links (sections, pages, etc.)
defines which part of an entry in the table of contents is made into a link
color of citation links (bibliography)
color of file links
color of URL links (mail, web)
color of frame around internal links (if )
color of frame around citations
color of frame around URL links

Please note, that explicit RGB specification is only allowed for the border colors (like linkbordercolor etc.), while the others may only assigned to named colors (which you can define your own, see Colors). In order to speed up your customization process, here is a list with the variables with their default value. Copy it in your document and make the changes you want. Next to the variables, there is a short explanations of their meaning:

\hypersetup{ bookmarks=true, % show bookmarks bar? unicode=false, % non-Latin characters in Acrobat’s bookmarks pdftoolbar=true, % show Acrobat’s toolbar? pdfmenubar=true, % show Acrobat’s menu? pdffitwindow=false, % window fit to page when opened pdfstartview={FitH}, % fits the width of the page to the window pdftitle={My title}, % title pdfauthor={Author}, % author pdfsubject={Subject}, % subject of the document pdfcreator={Creator}, % creator of the document pdfproducer={Producer}, % producer of the document pdfkeywords={keyword1, key2, key3}, % list of keywords pdfnewwindow=true, % links in new PDF window colorlinks=false, % false: boxed links; true: colored links linkcolor=red, % color of internal links (change box color with linkbordercolor) citecolor=green, % color of links to bibliography filecolor=magenta, % color of file links urlcolor=cyan % color of external links}

If you don't need such a high customization, here are some smaller but useful examples. When creating PDFs destined for printing, colored links are not a good thing as they end up in gray in the final output, making it difficult to read. You can use color frames, which are not printed:

\usepackage{hyperref}\hypersetup{colorlinks=false}

or make links black:

\usepackage[hidelinks]{hyperref}

or use \usepackage{hyperref} \hypersetup{hidelinks}

When you just want to provide information for the Document Info section of the PDF file, as well as enabling back references inside bibliography:

\usepackage[pdfauthor={Author's name},% pdftitle={Document Title},% pagebackref=true,% pdftex]{hyperref}

By default, URLs are printed using mono-spaced fonts. If you don't like it and you want them to be printed with the same style of the rest of the text, you can use this:

Troubleshooting[edit]

Problems with Links and Equations 1[edit]

Messages like the following

! pdfTeX warning (ext4): destination with the same identifier (name{ equation.1.7.7.30}) has been already used, duplicate ignored

appear, when you have made something like

\begin{eqnarray}a=b\nonumber\end{eqnarray}

The error disappears, if you use instead this form:

\begin{eqnarray*}a=b\end{eqnarray*}

Beware that the shown line number is often completely different from the erroneous line.

Possible solution: Place the amsmath package before the hyperref package.

Problems with Links and Equations 2[edit]

Messages like the following

! Runaway argument? {\@firstoffive }\fi ), Some text from your document here (\ref {re\ETC. Latex Error: Paragraph ended before \Hy@setref@link was complete.

appear when you use inside an environment.

Possible solution: Add the following to your preamble:

\AtBeginDocument{\let\textlabel\label}

Note: The same error appears if you use a colon "" as part of a label, i.e. . Replacing that will help.

Problems with Links and Pages[edit]

Messages like the following:

! pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignored

appear when a counter gets reinitialized, for example by using the command provided by the book document class. It resets the page number counter to 1 prior to the first chapter of the book. But as the preface of the book also has a page number 1 all links to "page 1" would not be unique anymore, hence the notice that "duplicate has been ignored." The counter measure consists of putting into the hyperref options. This unfortunately only helps with the page counter. An even more radical solution is to use the option , but this will cause the page links in the index to stop working.

The best solution is to give each page a unique name by using the command:

\pagenumbering{alph}% a, b, c, ... ... titlepage, other front matter ... \pagenumbering{roman}% i, ii, iii, iv, ... ... table of contents, table of figures, ... \pagenumbering{arabic}% 1, 2, 3, 4, ... ... beginning of the main matter (chapter 1) ...

Another solution is to use before the command , which will give the title page the label page.a. Since the page number is suppressed, it won't make a difference to the output.

By changing the page numbering every time before the counter is reset, each page gets a unique name. In this case, the pages would be numbered a, b, c, i, ii, iii, iv, v, 1, 2, 3, 4, 5, ...

If you don't want the page numbers to be visible (for example, during the front matter part), use . The important point is that although the numbers are not visible, each page will have a unique name.

Another more flexible approach is to set the counter to something negative:

\setcounter{page}{-100} ... titlepage, other front matter ... \pagenumbering{roman}% i, ii, iii, iv, ... ... table of contents, table of figures, ... \pagenumbering{arabic}% 1, 2, 3, 4, ... ... beginning of the main matter (chapter 1) ...

which will give the first pages a unique negative number.

The problem can also occur with the package: because each algorithm uses the same line-numbering scheme, the line identifiers for the second and follow-on algorithms will be duplicates of the first.

The problem occurs with equation identifiers if you use on every line of an eqnarray environment. In this case, use the *'ed form instead, e.g. (which is an unnumbered equation array), and remove the now unnecessary commands.

If your url's are too long and running off of the page, try using the package to split the url over multiple lines. This is especially important in a multicolumn environment where the line width is greatly shortened.

Problems with bookmarks[edit]

The text displayed by bookmarks does not always look like you expect it to look. Because bookmarks are "just text", much fewer characters are available for bookmarks than for normal LaTeX text. Hyperref will normally notice such problems and put up a warning:

Package hyperref Warning: Token not allowed in a PDFDocEncoded string:

You can now work around this problem by providing a text string for the bookmarks, which replaces the offending text:

\texorpdfstring{''TEX text''}{''Bookmark Text''}

Math expressions are a prime candidate for this kind of problem:

\section{\texorpdfstring{$E=mc^2$}{E=mc2}}

which turns to in the bookmark area. Color changes also do not travel well into bookmarks:

\section{\textcolor{red}{Red !}}

produces the string "redRed!". The command gets ignored but its argument (red) gets printed. If you use:

\section{\texorpdfstring{\textcolor{red}{Red !}}{Red\ !}}

the result will be much more legible.

If you write your document in unicode and use the unicode option for the hyperref package you can use unicode characters in bookmarks. This will give you a much larger selection of characters to pick from when using .

Problems with tables and figures[edit]

The links created by hyperref point to the label created within the float environment, which, as previously described, must always be set after the caption. Since the caption is usually below a figure or table, the figure or table itself will not be visible upon clicking the link[4]. A workaround exists by using the package hypcap[2] with:

Be sure to call this package after loading hyperref.

If you use the wrapfig package[5] mentioned in the "Wrapping text around figures" section of the "Floats, Figures and Captions" chapter, or other similar packages that define their own environments, you will need to manually include in those environments, e.g.:

\begin{wrapfigure}{R}{0.5\textwidth}\capstart\begin{center}\includegraphics[width=0.48\textwidth]{filename}\end{center}\caption{\label{labelname}a figure}\end{wrapfigure}

Problems with long caption and \listoffigures or long title[edit]

There is an issue when using with hyperref for long captions or long titles. This happens when the captions (or the titles) are longer than the page width (about 7-9 words depending on your settings). To fix this, you need to use the option breaklinks when first declaring:

\usepackage[breaklinks]{hyperref}

This will then cause the links in the to word wrap properly.

Problems with already existing .toc, .lof and similar files[edit]

The format of some of the auxilliary files generated by latex changes when you include the hyperref package. One can therefore encounter errors like

! Argument of \Hy@setref@link has an extra }.

when the document is typeset with hyperref for the first time and these files already exist. The solution to the problem is to delete all the files that latex uses to get references right and typeset again.

Problems with footnotes and special characters[edit]

See the relevant section.

Problems with Beamer[edit]

Using the command

\hyperref[some_label]{some text}

is broken when pointed at a label. Instead of sending the user to the desired label, upon clicking the user will be sent to the first frame. A simple work around exists; instead of using

\phantomsection\label{some_label}

to label your frames, use

\hypertarget{some_label}{}

and reference it with

\hyperlink{some_label}{some text}

Problems with draft mode[edit]

WARNING! Please note that if you have activated the "draft"-option in your \documentclass declaration the hyperlinks will not show up in the table of contents, or anywhere else for that matter!!!

The hyperlinks can be re-enabled by using the "final=true" option in the following initialization of the hyperref package, just after the package was included:

\usepackage{hyperref}\hypersetup{final=true}

A good source of further options for the hyperref package can be found here [6].

Notes and References[edit]

download example:

Bibliography

A typical scientific document contains a number of references, and this leads to the problem of organizing and presentation of the references in the document. The problem can be subdivided into several parts: store of the reference information, later retrieval of this information while preparing the document, and presentation (formatting) of the reference information in the document and in the bibliography according to a particular format.

A widely-used approach to deal with references in LaTeX documents is to employ BibTeX reference management software. In BibTeX reference information is stored in format-independent plain text file(s) (usually with .bib extension), which can be modified with almost any text editor. Such a text file contains BibTeX entries, and each entry, formed by several text lines, has

  • unique ID or key, needed to identify and refer to the particular entry, for instance Author2001;
  • entry type, which can be article, book, thesis, etc.;
  • entry fields (such as year, publisher, journal, etc.), corresponding to the particular type.

Here is an example of the article type entry from the .bib file I used while typesetting thesis:

@article{Khirevich2010,author= {Khirevich, S. and Daneyko, A. and H\"{o}ltzel, A. and Seidel-Morgenstern, A. and Tallarek, U.},doi= {10.1016/j.chroma.2010.05.019},journal= {Journal of Chromatography A},shortjournal= {J. Chromatogr. A},pages= {4713--4722},title= {Statistical analysis of packed beds, the origin of short-range disorder, and its impact on eddy dispersion},volume= {1217},year= {2010}}

The command \bibliography{reference_list} placed before \begin{document} is used to specify a plain text input file (reference_list.bib here) containing information on references.

References can be "cited" during editing the LaTeX document using, for example, \cite{key} command, and later at the document compilation step LaTeX input files must be processed with LaTeX and BibTeX.

The most popular approaches to indicate a reference appearing in the text can be classified as "numeric" and "author–year". The former uses sequential number of a reference in the document

while "author–year" is based on the extended reference information and may appear like this:

Each indication has particular advantages and drawbacks. For example, numeric is more compact (i.e., require less space in a text line), and a group of references can be "compressed" into a range in the case they have sequential numbering (i.e., [1,2,3,5] will be shown as [1–3,5]). On the other hand, author–year indication shows more information on the cited document (typically, first one or two author names, and a year of a publication), but requires more space compared to the numeric one. The space consumed by reference may become important if your document has high density of references (and you care about in-line space "wasted" by references :).

and each number has associated script-sized text at the bottom of the page (where the reference appeared) containing extended information on the cited reference:

Biblatex

To create citations in my thesis, I employed the biblatex package, which is one of the most notable packages I have used with LaTeX. The package provides a highly customizable interface for the creation and edit of the presentation of bibliographic data in the document. Compared to the plain BibTeX, biblatex enables relatively easy customization of the appearance of bibliographic data. Below I provide customizations I used to modify the default biblatex output. The detailed description of the biblatex commands is available in the package documentation.

The two basic commands to enable biblatex and output citation list are

\usepackage{biblatex}% place in the document preamble\printbibliography% place in the document body where list of citations has to appear

While preparing the thesis I activated biblatex with the following optionscompiling the document using biblatex with the options
below will need and
files (see next
sections, "Biblatex customization" and "Footnote
citation"):

\usepackage[hyperref=true, url=false, isbn=false, backref=true, style=custom-numeric-comp, citereset=chapter, maxcitenames=3, maxbibnames=100, block=none]{biblatex}

Option hyperref=true was specified to transform various citation elements (like citation number, page number where citation appears, hyperlink to the web page where cited document can be found, etc.) into clickable hyperlinks. This option requires hyperref package (see also notes on hyperref).

With options url=false,isbn=false I disabled printing the URLs and ISBNs in the bibliography.

Back references

Option backref=true enables generation of the back references to the citation, which are usually number(s) of the page where citation appears:

% backref=true
% backref=false

The back reference text preceding the page number ("see p.") can be modified using the following command:

\DefineBibliographyStrings{english}{%backrefpage= {see p.}, % for single page numberbackrefpages= {see pp.}% for multiple page numbers}

Just a note on the back references. When you are reading a .pdf document, encounter a reference, and click on it, .pdf viewer will change view to the record of this reference in the bibliography. Now, if you want to return to the main text and continue reading, you may find it difficult to do using back reference when the reference was cited on several pages (back reference will contain several page numbers and you have to bear in mind the original page number you came to the bibliography), and a good solution here is to use "Alt + ←" instead of the back reference itself. On the other hand, back references are useful to indicate how often and where a particular reference was cited in the document.

Citation style

Option style=custom-numeric-comp determines the citation style. As seen from its name, the chosen citation style uses numbers (numeric) to indicate citations in text, and consequent numbers are compressed (comp) into a range: [1,2,3,5] is printed as [1–3,5]. Above it was mentioned that I used footnote version of the standard biblatexnumeric-comp style — as a result, each citation has i) its number typeset as superscript, and ii) short and extended reference information located at the bottom of the page ("footnote text") and in the bibliography, respectively:

Option citereset=chapter defines biblatex behavior for the reference footnote text in a typical situation when a citation appears several times in the document: footnote text for the particular citation is printed only once per document chapter (citereset=chapter), where chapter is defined according to the LaTeX sectioning commands. In my thesis a typical chapter includes about 20 pages, and I assumed citereset=chapter to be quite acceptable. However, one of my colleagues was confused by such a rule for printing the footnote text (i.e., he did not get the logic behind the rule until I have explained it). I was thinking about resetting footnote text as "once-per-page" (not "once-per-chapter") but decided to avoid this due to high density of the references in my thesis. If you are interested in such a behavior some useful information can be found here.

Amount of displayed author names

Options maxcitenames=3 and maxbibnames=100 limit amount of authors of the cited document to be printed in the document body and in the bibliography, respectively. If the number of authors exceeds maxcite(bib)names, the author list is truncated according to biblatex settings, and usually printed as "Author1 et al." In my case I have very short authors lists in the footnote text (document body) to reduce space occupied by footnote citations,

and virtually all authors are displayed in the bibliography:

I note that I have prepared my thesis with biblatex v. 0.9a (19.03.2010), while this on-line document was prepared and tested on biblatex v. 1.6 (29.07.2011). Options maxcitenames and maxbibnames were not available in v. 0.9a, and the described biblatex behavior (with maxcitenames=3 and maxbibnames=100) was obtained using maxnames=3 while loading the biblatex package, and maxnames=100 while printing the bibliography, i.e.

\usepackage[..., maxnames=3]{biblatex}% in the document preamble\printbibliography[..., maxnames=100]% in the document body

The next section continues the discussion of the biblatex customization.

If you likeI hope you came to the bottom of this
page not just by fast scrolling the information presented on this web site, and would like to support development of this project you may consider buying me a coffee.

Leave a Comment

(0 Comments)

Your email address will not be published. Required fields are marked *