I followed the sample of Heiko with very excellent explanation about his approach of my request. Since my main idea is to have as well a subtitle I'm little bit stuck why the ˋsubtitleˋ is not set - or better said: I have no idea how to access it properly for a printout.
\documentclass{article}
\usepackage{keyval}
\usepackage{kvoptions}
\SetupKeyvalOptions{
family=mosquito,
prefix=mosquito@,
}
\makeatletter
\DeclareBoolOption{hideInToC}
\DeclareStringOption{subtitle}
\newcommand\sectionLvl[3][]{%
\begingroup
\setkeys{mosquito}{#1}%
\ifcase#2\relax % 0 = chapter
\def\tmp@mosquito{\chapter}%
\or % 1 = section
\ifmosquito@hideInToC
\def\tmp@mosquito{\section*}%
\else
\def\tmp@mosquito{\section}%
\fi
\else % subsection
\def\tmp@mosquito{\subsection}%
\fi
\expandafter\endgroup
\tmp@mosquito{#3}{
{sub: \mosquito@subtitle}
}
}%
\makeatother
\begin{document}
\tableofcontents
\bigskip
\hrule
\sectionLvl[subtitle={Test Subtitle}]{1}{Title 1 (shown)}
\sectionLvl[hideInToC]{1}{Title 2 (hideInToC)}
\sectionLvl[subtitle={Test Subtitle2}]{1}{Title 3 (shown)}
\sectionLvl{2}{SubTitle 4 (shown)}
\end{document}
Since I switch from ˋkeyvalˋ to ˋkvoptionsˋ I wonder what are the major differences. I'm aware that the syntax is different but has the one or other benefits in sense of performance (when using via LuaHBTex) or better robustness?
\sectionLvl[subtitle={Test Subtitle},level=chapter,toc=false,number=false]{Title 1 (shown)}. – Ulrike Fischer Jan 18 '21 at 19:42levelstill as numeric but I appreciate the idea for thetocalthough I thinknumberis not really required. – LeO Jan 18 '21 at 20:11