I stitched several examples together and got a more or less working sample. My final problem is the message

Undefined control sequence. \tableofcontents

which appears when I try to compile the following code.

\usepackage[margin=1.85cm]{geometry} % for margins on a A4paper
\setmainfont{Liberation Sans}


    #1 {\textls*[50]{#2}\endgraf}





    \fi {#3}
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {2.3ex \@plus .2ex}%

\def\l@subsubsection{\@dottedtocline{3}{3.8em}{3.1em}} % 3.8+3.1em=6.9em



    \sectionLvl[subtitle={Test Subtitle}]{1}{abc}
    \sectionLvl[subtitle={Second level}]{2}{second section}
    \sectionLvl[subtitle={addtional}]{3}{third section}
%       \sectionLvl{3}{third section}
%       subtitle

Is there an easy way to fix this problem?

  • The undefined macro is \mosquito@subtitle.
    – campa
    Jan 14 '21 at 13:59
  • uhu.... but how to fix it? Its for the subtitle which shoudn't appear in the title.
    – LeO
    Jan 14 '21 at 14:01

The exact error code is

! Undefined control sequence.
<argument> ...tionsubtitlefont \mosquito@subtitle 
                                                  \endgraf } \fi \addvspace ...
l.82     \tableofcontents

and is not \tableofcontents but rather \mosquito@subtitle.

The trouble is that \tableofcontents starts with a \section*, and by your definitions this executes \boxSection, which involves the (still undefined) control sequence. Just add


somewhere in your preamble (ideally just before \define@key).

Unrelated: don't load fontenc if you are using a Unicode engine.

  • Thx for the solution. I didn't see the output since I'm working with TeXStudio. I think need to make a follow up since the command structure of LaTeX seems (little bit) strange.
    – LeO
    Jan 14 '21 at 15:36
  • Yeah, editors tend to mask error messages; in doubt always compile from the command line.
    – campa
    Jan 14 '21 at 15:38

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.