5. References, links and bibliographies¶
5.1 Cross-references¶
Give anything numbered a label, then refer to it. The number updates itself if things move.
\section{Method}\label{sec:method}
See Section~\ref{sec:method} and Equation~\eqref{eq:energy}.
The ~ is a non-breaking space, which keeps "Section" and its number on one line. A prefix such as sec:, eq:, tab: or fig: is a helpful habit. The cleveref package can add the word for you: \cref{sec:method}.
5.2 Citations¶
Keep references in a separate .bib file, and cite them by key:
refs.bib
@book{clarke2001,
author = {Clarke, Joseph A.},
title = {Energy Simulation in Building Design},
edition = {2},
publisher = {Butterworth-Heinemann},
address = {Oxford},
year = {2001}
}
\usepackage[round]{natbib}
...
As \citet{clarke2001} shows, this holds \citep{clarke2001}.
...
\bibliographystyle{plainnat}
\bibliography{refs}
The bibliography tool picks up only the items you cite. Zotero can export a .bib file, and its Better BibTeX add-on keeps that file updated. biblatex with the biber tool is a more flexible alternative, while journals often supply their own .bst style for BibTeX.
5.3 A complete small report¶
This pulls together everything so far: sections, equations, a table, a chart, cross-references, a bibliography and links.
main.tex
% A complete small report: sections, maths, a table, a figure, cross-references, a bibliography and links.
% Build: pdflatex main, bibtex main, pdflatex main, pdflatex main
\documentclass[11pt,a4paper]{article}
% Packages. hyperref goes last among these, because it changes how others work.
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage[round]{natbib}
\usepackage{xcolor}
\usepackage[colorlinks=true,linkcolor=teal,citecolor=teal,urlcolor=teal]{hyperref}
\pgfplotsset{compat=1.17}
% Your own command: change the look of every "term" from this one line.
\newcommand{\term}[1]{\textbf{#1}}
\title{Heat Loss Through a Wall}
\author{A Student}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\section{5.4 Introduction}\label{sec:intro}
A \term{U-value} measures heat flow through one square metre of a surface for each degree of
temperature difference \citep{clarke2001}. Section~? gives the equation, and
Table~? and Figure~? apply it.
\section{5.5 Method}\label{sec:method}
Heat loss $Q$ follows from the U-value $U$, the area $A$ and the temperature difference $\Delta T$:
Q = U A \, \Delta T.
\tag{?}
Equation~(?) is a steady-state estimate. Longer derivations line up at the equals sign:
\begin{align*}
Q &= 2.1 \times 10 \times 15 \\
&= 315 \text{ W}.
\end{align*}
\section{5.6 Results}\label{sec:results}
\begin{table}[ht]
\centering
\caption{Table . Heat loss through a 10 m$^2$ wall at a difference of 15 K.}
\begin{tabular}{lrr}
\toprule
Wall & $U$ (W/m$^2$K) & $Q$ (W) \\
\midrule
Solid brick & 2.10 & 315 \\
Unfilled cavity & 1.50 & 225 \\
Insulated & 0.45 & 68 \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[width=8cm, height=5cm, xlabel={U-value (W/m$^2$K)}, ylabel={Heat loss (W)}]
\addplot[teal, mark=*] coordinates {(0.45,68) (1.5,225) (2.1,315)};
\end{axis}
\end{tikzpicture}
\caption{Heat loss rises in proportion to the U-value.}
\label{fig:loss}
\end{figure}
\section{5.7 Conclusion}
Find this project's source at \url{https://ahmadammar.github.io/teaching/latex/}.
\bibliographystyle{plainnat}
\bibliography{refs}
\end{document}
It compiles to these two pages. The links are coloured teal, and every number comes from a label.

Page 1

Page 2