0

This question already has an answer here:

I have encountered a weird problem (in my eyes) to do with bibliographys in included chapters and the structure of a document and I just cannot find out whats the cause...

In the final document, I want to include a table of contents structured as follows:

Structure of the final document

I would like NOT to have the page for stating "PART 1 - Introduction", which I want to exclude using this command:

 \renewcommand{\part}[1]{\addcontentsline{toc}{part}{#1}}

However, if I include this into my document, I end up with the following TOC:

Weird structure after removing page

--> The "Introduction" part moves to the bottom of the TOC

I have already figured out using a MWE, that it has something to do with including the bibliography inside a chapter that I am including, as a MWE with the bibliography in the main file was fine as well as including a chapter without a bibliography was fine - but the combination of those somehow triggers this?

This works:

\documentclass{book}

\usepackage{lipsum}
\renewcommand{\part}[1]{\addcontentsline{toc}{part}{#1}} %removes pages with part headers

\begin{document}

\tableofcontents
\cleardoublepage

\part{Introduction}
%\include{MWE_Chapter}
\chapter{Wabbadabbadupdup} % (fold)
This is just a test and a citation \citep{Carmichael2008} - 

\section{Hey ho Lets go}
\lipsum

\bibliographystyle{jneurosci} %apalike, abbrv
\bibliography{library}

\end{document}

This doesn't:

\documentclass{book}

\usepackage{lipsum}
\renewcommand{\part}[1]{\addcontentsline{toc}{part}{#1}} %removes pages with part headers

\begin{document}

\tableofcontents
\cleardoublepage

\part{Introduction}
\include{MWE_Chapter}

\end{document}

with MWE_Chapter being:

\chapter{Wabbadabbadupdup} % (fold)
This is just a test and a citation \citep{Carmichael2008} - 

\section{Hey ho Lets go}
\lipsum

\bibliographystyle{jneurosci} %apalike, abbrv
\bibliography{library}

I would really like to know what causes this behavior and if someone can reproduce it? Or if there is another possibility to remove the pages created by the \part syntax without changing the TOC! Thanks!

The same by the way happens if I use

\addcontentsline{toc}{part}{<Header of the part>} 

instead of the renewcommand to remove the part page

marked as duplicate by barbara beeton, marmot, Henri Menke, Stefan Pinnow, Circumscribe Dec 23 '18 at 8:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • By your definition of \part you will not have any part page again. If you want to remove it from the ToC, you must use more sophisticated strategies – user31729 Jan 25 '18 at 20:16
  • Besides all, the document isn't compilable at all – user31729 Jan 25 '18 at 20:21
  • 1
    I don't recommend it really, but try \renewcommand{\part}[1]{\addcontentsline{toc}{part}{#1}\null}, because you're getting into troubles with \include here. The non - \include version works as expected, but \include has some issues with \addcontentsline – user31729 Jan 25 '18 at 20:25
  • I really do not understand what you want to achieve, but I'd not renew the \part comment. If you just want an entry in the toc, add \addcontentsline{toc}{part}{Introduction}, and if you want to increase the part number, put \stepcounter{part}. – marmot Jan 25 '18 at 20:28
  • @marmot What I want to achieve in the end is a common structure of the document including the part sections in the TOC, but not having a seperate page for each part, and then additionally have chapters with a bibliography each (natbib+chapterbib) - which is why I would like to include the chapters instead of having 1 big file. I already tried your suggested solution (and have included this in the question, see above) but get the same result. – Julia Jan 25 '18 at 23:08
0

So this problem I have seems to be linked to apparently one of the oldest bugs of Latex and I found an answer here (\immediate\write worked for me):

ToC numbering problem

  • while this does explain the problem, i would tend to call it a misfeature rather than a bug. the designer of latex had a good idea with \include, but clearly didn't think out the implications too well. would you consider closing this as a duplicate? it will still remain available for other users to find, who have a similar problem. – barbara beeton Oct 23 '18 at 23:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.