Here is my MWE:
\documentclass[11pt,letterpaper,oneside,notitlepage]{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage[loose]{units}
\usepackage{url}
\usepackage{pgf,tikz}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{multirow}
\usepackage{dcolumn}
\newcolumntype{.}{D{.}{.}{-1}}
\usepackage{booktabs}
\usepackage{alltt}
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}
\usepackage[margin=1in]{geometry}
% these commands use the fancyhdr package to get "x of y" style
% page numbering. The headrulewidth command gets rid of a decorative
% horizontal rule that is default with "fancy" pagestyle.
\pagestyle{fancy}
\cfoot{\thepage\ of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\cfoot{{Cyclic triaxial test report \ \ \ \ \ \ \ Page \thepage\ of \pageref{{LastPage}} \ \ \ \ \ \ \ Test ID: {testid} \\ {{\bf PRELIMINARY REPORT - NOT FOR ENGINEERING USE!}}}}
\subsection*{1}
\subsection*{2}
\subsection*{3}
\clearpage
\subsection*{a}
\clearpage
\subsection*{b}
\clearpage
\subsection*{c}
\clearpage
\subsection*{d}
\clearpage
\clearpage
\end{document}
Can anyone offer advice? As the title says, even after multiple compiles, I can't get LastPage
to work. I'm using pdfLaTeX
.
Best Answer
Suppress the extra pair of braces in the argument of
\pageref
; you haveand it should be
The extra pair of braces causes LaTeX to look for the wrong string
{LastPage}
to produce the cross-reference (the right string isLastPage
). Your code produces some warnings about this:The code with some modifications explained before:
I changed
\cfoot{...}
to the most modern\fancyfoot[C]{...}
interfaz. I also fixed theheadheight
length; your MWE produces a warningso I used the
geometry
settings to increase the length as suggested by he message. Notice also thet\bf
is an old TeX command that shouldn't be used in modern documents; you should use\bfseries
instead,Perhaps you should conside other method for getting your spacing in the footer; you can use
\qquad
(as I did in my example code) or\hspace{<length>}
instead of all those single spaces together.