Page LayoutManually adding REFERENCES to contents result in wrong page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

Manually adding REFERENCES to contents result in wrong page

Post by RiW »

Hi,

I wanted to include my REFERENCES section in the contents page so added it manually (see below code). The references section starts on a page 45.

Code: Select all

\addcontentsline{toc}{chapter}{References}
\begin{flushleft}
\renewcommand{\bibname}{References}
\bibliography{library}{}
\bibliographystyle{ieeetr}
\end{flushleft}
However, the page number shown in the contents is 44. If I move the 'add to TOC' command to after the \bibliography commands, then it shows as 46 (i.e. referencing the point when the references end). Is there a way I can correct the page number in the TOC please?
Last edited by RiW on Mon Sep 06, 2010 9:55 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Manually adding REFERENCES to contents result in wrong page

Post by frabjous »

Trying using \phantomsection right before \addcontentsline ; if it starts on its own page, put \clearpage before \phantomsection.
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

Manually adding REFERENCES to contents result in wrong page

Post by RiW »

frabjous wrote:Trying using \phantomsection right before \addcontentsline ; if it starts on its own page, put \clearpage before \phantomsection.
For reference, all tests were performed by clearing all .aux, .toc etc. files and running PDF latex 3 times to rebuild all links. My document class is also REPORT, so I tried using phantomchapter too and received an error.

Thanks for the ideas, but adding \phantomsection had no effect and \clearpage added a blank page before starting the references (which did increment the reference page number to 45 in the contents, even though it has now moved to 46!)

Any other ideas?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Manually adding REFERENCES to contents result in wrong page

Post by frabjous »

You'll need to provide a complete, compiliable minimal working example; I don't know why \phantomsection shouldn't have worked.
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

Manually adding REFERENCES to contents result in wrong page

Post by RiW »

Ok, I haven't done an MWE before but from that website link (Thanks!) I hope so shows my document structure:

Code: Select all

%
\documentclass[11pt,a4paper,oneside]{report}

%Preamble
\usepackage{amsmath, amsfonts, amssymb}
\usepackage{alphalph}
\usepackage[pagecontinue=true,alphMult=ab,AlphMulti=AB,fnsymbolmult=true,romanMult=true,RomanMulti=true]{pagesLTS}
\usepackage{graphicx,subfig}
\usepackage{fancyhdr}
\usepackage{parskip}
\usepackage{booktabs,multirow}
\usepackage{a4wide}
\usepackage{setspace}
%\usepackage[none]{hyphenat}
\usepackage{hyperref}

\hypersetup{
	pdfstartview={FitV},
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black,
}

\begin{document}
\pagenumbering{arabic}

%Custom Title Page
\input{./title.tex}

%Abstract
\begin{abstract}
Abstact
\end{abstract}

\tableofcontents

\chapter{Introduction}
\section{Overview}
Document Content

%REFERENCES
\renewcommand{\bibname}{References}
\phantomsection
\addcontentsline{toc}{chapter}{\bibname}
\begin{flushleft}
\bibliography{library}{}
\bibliographystyle{ieeetr}
\end{flushleft}


%Begin Appendix
\appendix

%CIRCUIT DESIGN APPENDIX
\chapter{Circuit Design}
%Appendix Data

\end{document}
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Manually adding REFERENCES to contents result in wrong page

Post by frabjous »

No, you must not have read that link very carefully. That's not a minimal working example. You are clearly loading packages unrelated to the problem, and you're using \input commands to documents that others do not have access to. (Not to mention a bibliography not present on your computers.) The point of a minimal working example is to allow us to reproduce the problem you're having without anything not having to do with the problem getting in the way. The example needs to be compiliable on its own, and not containing anything extra.

And for the record, this is all made clear by the Board Rules; see also the Post on Avoidable Mistakes.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Manually adding REFERENCES to contents result in wrong page

Post by frabjous »

Playing around with things on my own, I think it might be some interference from the flushleft environment. Try something like:

Code: Select all

    \begin{flushleft}
    \renewcommand{\bibname}{References}
    \clearpage
    \phantomsection
    \addcontentsline{toc}{chapter}{\bibname}
    \bibliographystyle{ieeetr}
    \bibliography{library}
    \end{flushleft}
RiW
Posts: 29
Joined: Wed Sep 01, 2010 12:11 am

Re: Manually adding REFERENCES to contents result in wrong p

Post by RiW »

Apologies for the poor MWE, but thanks for your suggestion as it fixed the problem completely. I'll be careful to include the sectioning within the flushleft/right environments in the future.

Thanks
Post Reply