2

So I have both arabic and roman page numbering for a report I am writing. The arabic displays correctly with no issues but the roman numerals display only the last page number they are used on before the TOC.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[nottoc]{tocbibind}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{float}
\usepackage{bm}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{gobble}

\title{
    {\includegraphics[scale=0.7]{Logo.png}}
    \\\vspace{\baselineskip}\textbf{Project name}
}
\author{Me\\\\by\\\\Me\\\\xxxx}
\date{\vspace{5cm}Word Count: xxxx}

\pagenumbering{roman}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[R]{\thepage}
\fancyhead[L]{Class}
\fancyfoot{}
\fancyfoot[L]{Me}

\begin{document}

\maketitle
\pagenumbering{}

\pagebreak


\pagenumbering{roman}

\fancyhead{}
\fancyhead[L]{Class}
\fancyhead[R]{\thepage}
\section*{Originality Statement}
Stuff

\section*{Acknowledgements}
More stuff

\newpage
\section*{Abstract}
Insert abstract here

\newpage
\fancyfoot{}
\tableofcontents
\addcontentsline{toc}{section}{\protect\numberline{}Originality Statement}
\addcontentsline{toc}{section}{\protect\numberline{}Acknowledgements}
\addcontentsline{toc}{section}{\protect\numberline{}Abstract}

\newpage
\listoffigures{}

\newpage

\pagenumbering{arabic}
\fancyhead{}
\fancyhead[L]{Introduction}
\fancyfoot{}
\fancyfoot[L]{Me}
\fancyfoot[R]{\thepage}
\section{Introduction}

To be more specific, the first page is not numbered as it is a title page, then from there they are numbered with roman numerals up to the TOC where the TOC only shows iv for all pages on the TOC even through they have been newpaged and have different page numbers displayed.

1
  • 1
    Welcome to TeX.SE. You should place the \addcontentsline statements immediately after the corresponding \section* statements rather than as a big group after \tableofcontents.
    – Mico
    May 12, 2019 at 8:15

2 Answers 2

1

The \addcontentsline commands should go where the section starts, so that LaTeX is able to provide the correct page number. I'd omit \protect\numberline{} that would push the titles to the right.

Also, I'd define some page styles, rather than resetting the parameters in the body of the document. The styles are frontmatter for the abstract and the other unnumbered sections, toclof for the table of contents and list of figures, mainmatter for the document body.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage[nottoc]{tocbibind}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{float}
\usepackage{bm}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{fancyhdr}
%\usepackage{gobble} % do you really need it?

\usepackage{lipsum} % just for the example

%% define some page styles
\fancypagestyle{frontmatter}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}%
  \fancyhead[L]{Class}%
  \fancyfoot[L]{Me}%
}
\fancypagestyle{toclof}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}%
  \fancyhead[L]{Class}%
}
\fancypagestyle{mainmatter}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}%
  \fancyhead[L]{\leftmark}%
}

\title{%
  \includegraphics[width=4cm]{example-image}\\[\baselineskip]\textbf{Project name}%
}
\author{Me\\[\baselineskip] by\\[\baselineskip] Me\\[\baselineskip] xxxx}
%\date{\vspace{5cm}Word Count: xxxx}

\begin{document}

\maketitle
\thispagestyle{empty}
\clearpage

\pagenumbering{roman}
\pagestyle{frontmatter}

\section*{Originality Statement}
\addcontentsline{toc}{section}{Originality Statement}
Stuff

\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}
More stuff

\clearpage

\section*{Abstract}
\addcontentsline{toc}{section}{Abstract}
Insert abstract here

\clearpage
\pagestyle{toclof}

\tableofcontents

\clearpage

\listoffigures

\clearpage

\pagenumbering{arabic}
\pagestyle{mainmatter}

\section{Introduction}

\lipsum[1-20]

\end{document}

enter image description here

1
  • Sweet this fixed it! I did not realise the addcontents where supposed to go under the different sections not in the actual TOC. Thank you heaps!
    – Kzxo500
    May 12, 2019 at 23:36
1

Some comments and observations:

  • Your document has several unnumbered section-level headers in the frontmatter. However, because the corresponding \addcontentsline instructions are inserted only later, i.e., after \tableofcontents, the page numbers shown in the ToC for the three unnumbered section headers cannot be correct. The obvious fix: Insert the \addcontentsline{toc}{section}{...} statements immediately after the \section* directives rather than after \tableofcontents.

  • Your document contains too many (and, moreover, poorly placed) \pagenumbering instructions. Please fix that. And, do note that the argument of \pagenumbering should not be empty.

  • \listoffigures does not take an argument.

  • Even though the title page shouldn't show an explicit page number, it should still be numbered, so that the second page has page number ii rather than i. Use \thispagestyle{empty} immediately after \maketitle to suppress the display of the page number.

  • Optional: Load the tocloft package to suppress the bold-facing of page numbers in the ToC.

enter image description here

\documentclass[a4paper,demo]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[nottoc]{tocbibind}
\usepackage{mathtools,amssymb,float,bm}
\usepackage{graphicx,enumitem,titlesec,fancyhdr}
%%%\usepackage{gobble}

\title{%
    \includegraphics[scale=0.7]{Logo.png}
    \\ \vspace{\baselineskip}
    \textbf{Project name}}
\author{Me\\\\by\\\\Me\\\\xxxx}
\date{\vspace{5cm}Word Count: xxxx}

\pagestyle{fancy}
\fancyhead{}
\fancyhead[R]{\thepage}
\fancyhead[L]{Class}
\fancyfoot{}
\fancyfoot[L]{Me}

%% Optional: use 'tocloft' package to un-bold page numbers
\usepackage[titles]{tocloft}
\renewcommand{\cftsecpagefont}{\mdseries} % default is '\bfseries'

\begin{document}
\pagenumbering{roman}

\maketitle
\thispagestyle{empty}  % optional

\newpage

\fancyhead{}
\fancyhead[L]{Class}
\fancyhead[R]{\thepage}

\section*{Originality Statement}
\addcontentsline{toc}{section}{Originality Statement}
Stuff

\section*{Acknowledgments}
\addcontentsline{toc}{section}{Acknowledgments}
More stuff

\newpage

\section*{Abstract}
\addcontentsline{toc}{section}{Abstract}
Insert abstract here

\newpage
\fancyfoot{}
\tableofcontents

\newpage
\listoffigures

\newpage

\pagenumbering{arabic} 

\fancyhead{}
\fancyhead[L]{Introduction}
\fancyfoot{}
\fancyfoot[L]{Me}
\fancyfoot[R]{\thepage}

\section{Introduction}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .