0

In my book I have two starred sections into a starred chapter. When I include the chapter in ToC with

\addcontentsline{toc}{chapter}{Chapter title}

the displayed pagenumber is correct. When I do the same for the first section of that chapter everything is ok (because the are in the same page)

\addcontentsline{toc}{section}{First Section title}

but when I do it for the second starred section

\addcontentsline{toc}{section}{Second Section title}

its pagenumber in the Toc is displayed wrong (it's displayed the same page as the chapter and first section).

How can I correct the pagenumber of that second starred secion in the ToC?

I'm using the book class.

Thanks for your help.

EDIT:

This a MWE

\documentclass[letterpaper]{book}
\usepackage[spanish]{babel}
\usepackage{tocloft}

\begin{document}
\tableofcontents
\chapter{First chapter}
\section{Section Zero}
\addcontentsline{toc}{chapter}{Second Chapter}
\chapter*{Second Chapter}
\addcontentsline{toc}{section}{First Section}
\section*{First Section}
\newpage
\addcontentsline{toc}{section}{Second Section}
\section*{Second Section}

\end{document}

And it works!!!!! The problem is that it doesn't work if I add the chapters by \include instead of \chapter

  • Put the lines directly after the \section* they belong to. – Johannes_B Sep 21 '17 at 14:53
  • 1
    Then at least i have to wait until my crystal ball is back from the shop. It is currently broken. – Johannes_B Sep 21 '17 at 15:25
  • 3
    The \addcontentsline macro should be after \section*, not before... – user31729 Sep 21 '17 at 15:52
  • 3
    @Fabio: Placing \addcontentsline before \chapter* or \section* does not make sense. It will have to be after. – Werner Sep 21 '17 at 16:28
  • 2
    @Fabio -- if you use \include, it will always start a new page. that is why, when \addcontentsline is in the \included file the page number for a chapter will be correct. even so, the \addcontentsline should always come after the \chapter (or \section, etc.) line so that it can't be separated by a page break from the heading that is to appear in the toc. – barbara beeton Sep 22 '17 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.