tquadrat.org

View on GitHub

References in a Document

To add a reference to another part of your document, add the following new commands to the preamble of your document source:

\usepackage{nameref}
\usepackage[colorlinks=true]{hyperref}

\newcommand*{\tqfullref}[1]{\hyperref[{#1}]{\ref*{#1} \nameref*{#1}}}
\newcommand*{\tqfullvref}[1]{\hyperref[{#1}]{\ref*{#1} \nameref*{#1}} on page \pageref{#1}}
\newcommand*{\tqref}[1]{\hyperref[{#1}]{\ref*{#1}}}
\newcommand*{\tqvref}[1]{\hyperref[{#1}]{\ref*{#1}} on page \pageref{#1}}

These are for a document in English language, for another language you have to adjust the commands accordingly; for the German language, the will look like this:

\usepackage{nameref}
\usepackage[colorlinks=true]{hyperref}

\newcommand*{\tqfullref}[1]{\hyperref[{#1}]{\ref*{#1} \nameref*{#1}}}
\newcommand*{\tqfullvref}[1]{\hyperref[{#1}]{\ref*{#1} \nameref*{#1}} auf Seite \pageref{#1}}
\newcommand*{\tqref}[1]{\hyperref[{#1}]{\ref*{#1}}}
\newcommand*{\tqvref}[1]{\hyperref[{#1}]{\ref*{#1}} auf Seite \pageref{#1}}

Because the hyperlink package redefines several other LaTex commands, it should be loaded always as the last package.

The destination for the reference will be marked with the \label command, like this:

\section{<headline>}\label{sec:<label>}
…
See chapter \tqfullref{sec:<label>}
See chapter \tqfullvref{sec:<label>}
See chapter \tqref{sec:<label>}
See chapter \tqvref{sec:<label>}

Both, the number/headline and the page number will be generated as hyperlinks. So the resulting output would look like this:

1.2.3 <headline>


See chapter “1.2.3 <headline>”
See chapter “1.2.3 <headline>” on page 42
See chapter 1.2.3
See chapter 1.2.3 on page 42

The hyperlink package provides also the commands \url and \href that allow to integrate references to websites or an email address into the generated document. The code:

Send me an email: \href{mailto:thomas.thrien@tquadrat.org}{thomas.thrien@tquadrat.org}
Or see my GitHub page: \url{https://tquadrat.github.io/}

results in:

Send me an email: thomas.thrien@tquadrat.org
Or see my GitHub page: https://tquadrat.github.io/