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.
\documentclass[a4paper,11pt,naustrian]{article}
\usepackage[margin=1.85cm]{geometry} % for margins on a A4paper
\usepackage[tracking=true,factor=1100,stretch=10,shrink=10,final]{microtype}
\usepackage{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{fontspec}
\setmainfont{Liberation Sans}
\usepackage{parskip}
\usepackage{keyval}
\definecolor{coi_gray}{RGB}{136,155,169}
\makeatletter
\newcommand\boxSection[2]{
\parbox{\linewidth}{%
\vspace{.5ex}%
\raggedright
#1 {\textls*[50]{#2}\endgraf}
\addvspace{.5ex}
\ifx\mosquito@subtitle\@empty\else
\endgraf{\sectionsubtitlefont\mosquito@subtitle\endgraf}
\fi
\addvspace{.5ex}
}%
}
\titleformat{\section}
{\normalsize\bfseries\color{gray}}{}{0em}
{\boxSection{\thesection}{#1}}
\titleformat{\subsection}
{\normalsize\bfseries\color{gray}}{}{0em}
{\boxSection{\thesubsection}{#1}}
\titleformat{\subsubsection}
{\normalsize\bfseries\color{gray}}{}{0em}
{\boxSection{\thesubsection}{#1}}
\newcommand\sectionsubtitlefont{\normalfont\sffamily}
\define@key{mosquito}{subtitle}{\def\mosquito@subtitle{#1}}
\newcommand\sectionLvl[3][]{%
\setkeys{mosquito}{subtitle={},#1}
\ifcase#2\relax\expandafter\chapter\or
\expandafter\section\or
\expandafter\subsection\or
\expandafter\subsubsection\else
\def\next{\@level{#2}}\expandafter\next
\fi {#3}
\ifx\mosquito@subtitle\@empty\else
\endgraf
\fi
}
\newcommand{\@level}[1]{%
\@startsection{level#1}
{#1}
{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{2.3ex \@plus .2ex}%
{\normalfont\normalsize\bfseries\color{coi_gray}}}
\newdimen\@leveldim
\newdimen\@dotsdim
{\normalfont\normalsize
\sbox\z@{0}\global\@leveldim=\wd\z@
\sbox\z@{.}\global\@dotsdim=\wd\z@
}
\def\l@subsubsection{\@dottedtocline{3}{3.8em}{3.1em}} % 3.8+3.1em=6.9em
\makeatother
\setcounter{secnumdepth}{10}
\setcounter{tocdepth}{10}
\usepackage{kantlipsum}
\begin{document}
\tableofcontents
\sectionLvl[subtitle={Test Subtitle}]{1}{abc}
\kant[1-2]
\sectionLvl[subtitle={Second level}]{2}{second section}
\kant[5-6]
\sectionLvl[subtitle={addtional}]{3}{third section}
% \sectionLvl{3}{third section}
% subtitle
\kant[8]
\end{document}
Is there an easy way to fix this problem?
\mosquito@subtitle
.