# titletoc fails with custom titlecontents

I'm using titletoc for having a partial index going down to paragraphs.

I wrote a custom formatting for it using \titlecontents and \titlecontents*.

In some cases (some specific combination of subsections, paragraphs, and text), it fails with the error:

./MWE.ptc
! Missing number, treated as zero.
<to be read again>
\ttll@lsubsection
l.6 \contentsline {paragraph}{Bla}{1}


A minimum non-working example is this:

\documentclass{article}
\usepackage[english]{babel}

\usepackage{titletoc}

\titlecontents{lsubsection}[0pt]{}{}{}{}
\titlecontents*{lparagraph}[0pt]{}{}{}{}

\begin{document}

\startcontents[char]
\printcontents[char]{l}{1}{\setcounter{tocdepth}{4}}

\paragraph{Blo}

\subsection{Ciao}

\paragraph{Bla}
As seen in

\stopcontents[char]

\end{document}


and the file .ptc which seems to be involved in the error has the following content:

\babel@toc {english}{}
\ttl@starttoc {char@1}
\contentsline {paragraph}{Blo}{1}%
\contentsline {subsection}{\numberline {0.1}Ciao}{1}%
\contentsline {paragraph}{Bla}{1}%
\ttl@stoptoc {char@1}
\contentsfinish


Where does this error come from? Thanks!

• do you really have \paragraph before \subsection it seems that titletoc don't expect this. – touhami Jun 1 at 9:51
• I agree, that seems to be the problem. The sectioning of the MWE is weird as it is the minimal example I could find. If you add a "section" at the begin of the MWE, it still fails. If you add a "subsection" it works. – Ilario Gelmetti Jun 1 at 14:43
• The version in GitHub should work ( github.com/jbezos/titlesec ). I was working on it, and I'll upload it to CTAN in 1 or 2 weeks. – Javier Bezos Jun 2 at 6:51