Skip to main content

Help me work out what's wrong with this LaTeX (now solved!)

One of my jobs at work is to help lecturers to get their LaTeX documents working with Chirun.

Doing this, I've learnt a lot more about LaTeX than I ever wanted to. I've spent hours debugging errors.

Usually, I delete sections of the code until I get to the smallest document that has the error, then I spend a while working out what's wrong and how to resolve it.

Well, today I've spent hours doing that, and I've got to a point where I'm completely stuck.

The notes that the lecturer sent me do a lot of complicated layout stuff in PDF LaTeX. Almost all of that is omitted when we run it through Chirun.

However, when we tried to compile it on the Chirun server, it wouldn't work.

After a while, I worked out that they're doing something funny with a "mini table of contents" at the start of each chapter, and if you don't have a .ptc file from a successful previous compilation you get a weird error message.

So I've boiled it all down to these two files:

2025/04/main.tex (Source)

\documentclass{book}

\usepackage{titletoc}

\makeatletter
\renewcommand{\@seccntformat}[1]{}                    

% Numbered chapters with mini tableofcontents
\def\@makechapterhead#1{
    \startcontents
    {\flushleft \printcontents{l}{1}{}}
}

\begin{document}

\chapter{title}

\include{extra}

\end{document}

2025/04/extra.tex (Source)

\begin{itemize}
    \item hey
\end{itemize}

When I compile main.tex, I get the following error:

(./extra.tex

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.1 \begin{itemize}

That only happens when the itemize environment from extra.tex is included with \include. If I put it in the main document or insert it with \input, then it compiles OK.

All that \include does is put a \clearpage before the included code and start a new .aux file, so the shenanigans to make the mini TOC must be getting confused by that.

The original code from the lecturer had the itemize environment halfway down a very long chapter, so it's not to do with the list's position, I don't think.

At this point I might just give up! If you can see what's going wrong, please tell me!