In the following, I get a perhaps a missing \item error each time a chapter is processed. This occurred only after the second compilation, once the table of contents information is built. Below I have a MWE where the offending code is near the top. That code is to ensure that the "leading dots" and page number for the "mini table of contents" inserted below the chapter title are printed in black instead of the default color. The result looks the way I want it, in spite of the errors. I have included a little bit more code below than that strictly required for a MWE as I want to avoid solutions that would mess up other important parts (for instance the full table of contents).

How could I fix this to avoid these error messages --- while still getting error messages if truly missing \items elsewhere.


%%%%%% Problem code is here
[10em] %  left margin
{}% font formatting
{\contentslabel{3em}} % section label and offset
%%%%%%%%  end of problem code


% coloured chapter font in toc

%% adapted from BlueBox style, pp:43-44
% http://mirror.csclub.uwaterloo.ca/CTAN/info/latex-samples/MemoirChapStyles/MemoirChapStyles.pdf

\leavevmode\leaders\hrule height 1\p@ \hfill \kern \z@}
\makebox[0pt][c]{#1\strut} \\[.5ex]
{\chaptitlefont \textcolor{ChapRed}{##1}}\\

\chapter{A chapter}
\section[Short title for this section]{Section 2 with a very, very long title which probably takes more than one line}


\chapter{Second chapter}
\section{Another section}
\section{Another section}
\section{Another section}
\section{Another section}
\section{Another section}

  • Could you please try to remove from your heading what can be removed in such way that the error still occurs? I think that this way you might even find and solve the problem yourself... – yo' Mar 29 '12 at 7:43
  • 3
    To quote the LaTeX Companion: The error message is produced by an \addvspace command when encountered in horizontal mode. The follow-up remark about "perhaps a missing \item is unfortunately seldom correct. The problematic code is imho not in the \titlecontents: It only clashes with something you are doing in the long chapter redefinitions. – Ulrike Fischer Mar 29 '12 at 9:08

Don't do this

{\chaptitlefont \textcolor{ChapRed}{##1}}\\

do this instead

 {\chaptitlefont \textcolor{ChapRed}{##1}}\par

The contents that you are placing after the chapter opening are essentially a list and lists like starting in good places not after \\ which is mid-paragraph even if the visual effect is similar.

  • 2
    david, would you agree that the "missing item" is an unfortunate error message in this circumstance, as in an awful lot of cases where it occurs? (yes, i know it's leslie's message, and all that jazz, but...) – wasteofspace Mar 29 '12 at 9:21
  • 14
    @wasteofspace, It is rumored that in the 25 year history of LaTeX there have been occasions when this error has been caused by a missing item, but that's only a rumor that has not been officially confirmed. – David Carlisle Mar 29 '12 at 9:46
  • Does the missing item error have something to do with the fact that a lot of latex's environments are defined in terms of the list and trivlist environment? – cmhughes Apr 1 '12 at 19:40
  • @cmhughes, hard to say really. You get the error if something tries to execute \addvspace in horizontal (LR) mode. \addvspace is latex's normal way of combining vertical space between display constructs, list items but also headings and more or less anything else really. I suppose especially in latex 2.09 without any extra packages, a messed up list construct was at least a plausible guess as to why latex was in this state, but the more constructs you define that are adding space with \addvspace the less likely it is that \item (or lack of \item) is the cause. – David Carlisle Apr 1 '12 at 20:34
  • @DavidCarlisle thanks for the follow-up :) – cmhughes Apr 2 '12 at 9:53

Your Answer

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

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