I hope this is not too specific to be worth an answer, since there is a "simple" workaround. But I just noticed this problem and it seems really weird. Maybe someone has an explanation for me.

If I pdflatex this:



    \addcontentsline{toc}{chapter}{Chapter 1}




\addcontentsline{toc}{chapter}{Part A}



I get this table of contents:

Resulting TOC

where I would actually expect this table of contents:

Expected TOC

It seems the order of toc entries is switched in this combination. This only appears when using the \addtocontentsline command and when placing the second entry in an additional .aux file. If I use the \chapter command, or put both \addtocontentsline in the same file, or use \input instead of \include, everything works smoothly. If I leave out the \clearpage before the \include and therefore put the two toc-entries on different pages, they also appear in the correct order. It really is just this single combination that caused me problems.

Now, normally I would not post this since it can easily be fixed by switching out just one of these things. But it just took me almost a day to get to the bottom of the problem in a fairly complex document, and I thought it might help future visitors to see it broken down to a minimal working example. I am also curious as to what the explanation for this might be.

Thanks and greetings,