# Yet another “perhaps a missing \item” error

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

\documentclass[11pt,openany]{memoir}
\usepackage{titletoc}
\usepackage{lipsum}

%%%%%% Problem code is here
\titlecontents{section}
[10em] %  left margin
{}% font formatting
{\contentslabel{3em}} % section label and offset
{}
{\color{black}\titlerule*[1pc]{.}\contentspage}
%%%%%%%%  end of problem code

\usepackage{color,calc}
\definecolor{ChapRed}{rgb}{.600,.100,.100}

% coloured chapter font in toc
\let\oldcftchapterfont=\cftchapterfont
\renewcommand{\cftchapterfont}{\color{ChapRed}\oldcftchapterfont}

%% adapted from BlueBox style, pp:43-44
% http://mirror.csclub.uwaterloo.ca/CTAN/info/latex-samples/MemoirChapStyles/MemoirChapStyles.pdf
\newcommand{\RedBarLength}{5em}

\newsavebox{\ChpNumBox}
\makeatletter
\newcommand*{\thickhrulefill}{%
\leavevmode\leaders\hrule height 1\p@ \hfill \kern \z@}
\newcommand*\BuildChpNum[2]{%
\begin{tabular}[t]{@{}c@{}}
\makebox[0pt][c]{#1\strut} \\[.5ex]
\colorbox{ChapRed}{%
\rule[-\RedBarLength]{0pt}{0pt}%
\rule{1ex}{0pt}\color{white}#2\strut
\rule{1ex}{0pt}}%
\end{tabular}}
\makechapterstyle{RedBox}{%
\renewcommand{\chapnamefont}{\large\scshape}
\setlength{\beforechapskip}{-30pt}
\setlength{\midchapskip}{10pt}
\setlength{\afterchapskip}{30pt}
\renewcommand{\printchaptername}{}
\renewcommand{\printchapternum}{%
\sbox{\ChpNumBox}{%
\BuildChpNum{\chapnamefont\@chapapp}%
{\chapnumfont\thechapter}}}
\renewcommand{\printchapternonum}{%
\sbox{\ChpNumBox}{%
\BuildChpNum{\chapnamefont\vphantom{\@chapapp}}%
{\chapnumfont\hphantom{\thechapter}}}}
\renewcommand{\afterchapternum}{}
\renewcommand{\printchaptertitle}[1]{%
\usebox{\ChpNumBox}\hfill
\parbox[t]{\hsize-\wd\ChpNumBox-1em}{%
\vspace{\midchapskip}%
\thickhrulefill\\[10pt]
{\chaptitlefont \textcolor{ChapRed}{##1}}\\
\startcontents[chapters]
\printcontents[chapters]{}{1}{\color{ChapRed}}
}}%
}
\chapterstyle{RedBox}

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

\renewcommand{\RedBarLength}{10em}

\chapter{Second chapter}
\section{Section}
\lipsum[1]
\section{Another section}
\lipsum[1]
\section{Another section}
\section{Another section}
\section{Another section}
\section{Another section}

\end{document}
-
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... –  tohecz Mar 29 '12 at 7:43
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}}\\