5

Is there a way to insert a subtitle right underneath a subsection heading in the scrbook class?

I found this question/solution - , basically exactly what I try to achieve, but I coulnd't make it work with the scrbook class..

Further, I found this solution, however I need the subtitle to be formatted slightly differently than the subsection heading, meaning not bold and sans-serif.

One reason why I need to have the subtitled treated as sort of a 'heading/title' is because I need the first line of the following subsection to appear with no indent.

Finally, I wish the subsection plus the subtitle not to be numbered (I'm currently using the starred version for subsections) and I do not wish the subtitle to appear in the TOC. I imagine something like this:

Subsection with subtitle

MWE:

\documentclass[
    11pt,
    ngerman,
    a4paper,
    open=any,
    headings=big,
    captions=tableheading,
    parskip=false,
    captions=nooneline,
    toc=listofnumbered,
    toc=bibliography,
    numbers=noenddot,
    bibliography=leveldown]{scrbook}
\usepackage[inner=2.5cm, outer=2.5cm,tmargin=3cm, bmargin=4cm]{geometry}
\setcounter{tocdepth}{3}
\usepackage{scrlayer-scrpage}
\usepackage[ngerman]{babel}
\usepackage{lipsum}

\begin{document}
\tableofcontents

\part{Part I}
\chapter{Chapter 1}
\section{Section 1}
\subsection*{Subsection}
Subtitle\\
First line of subsection with no indent.

\end{document}
7
  • To clarify: You "do not wish the subtitle to appear in the TOC", but the (unnumbered) subsection should appear in the TOC, right? See my answer, where I worked under this assumption.
    – marquinho
    Commented Mar 3, 2022 at 11:14
  • No, I'm sorry for not being clear on that. I don't want the subsection nor the subtitle to appear in the TOC.
    – Daniela
    Commented Mar 3, 2022 at 15:00
  • Great, then only the first part of my answer applies; for the rest, you are good with \subsection*.
    – marquinho
    Commented Mar 3, 2022 at 15:04
  • Many thanks @marquinho for your efforts, plus the added explanation of your code. It's perfect. It works just exactly how I imagined it. You made my day, a big thank you!
    – Daniela
    Commented Mar 3, 2022 at 15:05
  • 1
    One detail I just realised: the \newcommand{\subsecsubvskip}{\vspace{1ex}} adjusts the space between the subtitle and the subsection text and not the space btw title and subtitle. However, I could adjust the latter with \RedeclareSectionCommand[beforeskip=-10pt,afterskip=1pt]{subsection}
    – Daniela
    Commented Mar 3, 2022 at 15:32

2 Answers 2

4

You can declare a new section command \subsecsubtitle

\RedeclareSectionCommand[
  afterskip=.5ex
]{subsection}

\DeclareNewSectionCommand[
  style=section,
  level=\subsectionnumdepth,
  afterskip=1.5ex plus .2ex,
  beforeskip=-.5ex,
  indent=0pt,
  font=\mdseries\small,
  tocstyle=gobble% no TOC entry
]{subsecsubtitle}

Then you can use

\subsection*{Subsection}
\subsecsubtitle*{Subtitle}

to get an unnumbered subsection followed by the unnumbered subtitle. This also avoids a page break between the subtitle and the following text.

Note that beforeskip of the subtitle is ignored if \subsecsubtitle is next to another section command.

Example:

\documentclass[
    %11pt,% default
    ngerman,
    %a4paper,% default
    open=any,
    %headings=big,% default
    captions=tableheading,
    %parskip=false,% default
    captions=nooneline,
    toc=listofnumbered,
    toc=bibliography,
    numbers=noenddot,
    bibliography=leveldown]{scrbook}
\usepackage[inner=2.5cm, outer=2.5cm,tmargin=3cm, bmargin=4cm]{geometry}
\usepackage{scrlayer-scrpage}
\usepackage{babel}
\usepackage{lipsum}% only for dummy text

\setcounter{tocdepth}{\subsubsectiontocdepth}

\RedeclareSectionCommand[
  afterskip=.5ex
]{subsection}

\DeclareNewSectionCommand[
  style=section,
  level=\subsectionnumdepth,
  afterskip=1.5ex plus .2ex,
  beforeskip=-1pt,
  indent=0pt,
  font=\mdseries\small,
  tocstyle=gobble
]{subsecsubtitle}

\begin{document}
\tableofcontents

\part{Part I}
\chapter{Chapter 1}
\section{Section 1}
\subsection*{Subsection}
\subsecsubtitle*{Subtitle}
First line of subsection with no indent.

\end{document}

enter image description here

2
  • +1 for the organic, comprehensive solution and (among other things) for taking care of avoiding page breaks.
    – marquinho
    Commented Mar 3, 2022 at 17:37
  • 1
    Many thanks @esdd! I adopted your code one to one. It works and it looks just wonderful! Thank you very much indeed.
    – Daniela
    Commented Mar 7, 2022 at 9:40
3

EDIT: I included a setting to adjust the vertical spacing between title and subtitle, which was missing, as indicated by OP.


Subtitle

The best approach, I think, would be to follow this answer and define a custom command \subsecsubtitle for exactly this purpose.

The command includes the desired font specifications and the direction \noindent. Note that this is only a mock sectioning command: it has all the visual trappings of a title, but it does not send anything to your TOC or to the running headers.

\newkomafont{subsecsubtitle}{\small\mdseries\sffamily} 
% subtitle font: smaller than \subsection; not bold; sans-serif
\newcommand{\subsecsubvskip}{\vspace{1ex}}
% adjust the vertical space between subtitle and text

\newcommand{\subsecsubtitle}[1]{%
\vspace{-1ex}% % adjust the vertical space between title and subtitle
\begingroup\usekomafont{disposition}\usekomafont{subsecsubtitle}#1\par\endgroup%
\subsecsubvskip\noindent\ignorespaces}

You can then employ this command right after \subsection:

\subsection{Subsection}
\subsecsubtitle{Subtitle}
First line of subsection with no indent.

Numbering and starred commands

You would like the \subsection to remain unnumbered, which is why you are using the starred version. But I also gather from your question that, while the subtitle shouldn't go to the TOC, the subsection ought to do so. However, your starred command \subsection* doesn't send anything to the TOC.

If I understand you correctly, then this is one way to do it:

\subsection*{Subsection title} % unnumbered section
\addxcontentsline{toc}{subsection}{Subsection title} % manually create TOC entry

This sends the specified title to TOC. However, you have to do it manually for every subsection. A better way is to generalize the operation, by creating a new command that does just that (argument #1 is the desired title):

\newcommand*{\subsectnonum}[1]{%
\subsection*{#1}
\addxcontentsline{toc}{subsection}{#1}}
...
\begin{document}
...
\subsectnonum{Subsection}

(Another option would be to use the nonumber switch when invoking the section: \subsection[nonumber=true]{Subsection}. This requires to activate the package option headings=optiontoheadandtoc in the preamble. You can read more about this powerful option and about "the advanced functionality of the optional argument of the sectioning commands" in the documentation.)

Example

\documentclass{scrbook}
\setcounter{tocdepth}{3}

\newkomafont{subsecsubtitle}{\small\mdseries\sffamily}
\newcommand{\subsecsubvskip}{\vspace{1ex}}

\newcommand{\subsecsubtitle}[1]{%
\vspace{-1ex}%
\begingroup\usekomafont{disposition}\usekomafont{subsecsubtitle}#1\par\endgroup%
\subsecsubvskip\noindent\ignorespaces}

\newcommand*{\subsectnonum}[1]{%
\subsection*{#1}
\addxcontentsline{toc}{subsection}{#1}}

\begin{document}
\tableofcontents

\section{Section 1}
\subsection*{Normal subsection (no TOC!)} % normal subsection, no number, no TOC
\subsecsubtitle{Subtitle}
First line of subsection with no indent.

\section{Section 1}
\subsectnonum{Custom subsection}    % custom subsection w/o number
\subsecsubtitle{Subtitle}
First line of subsection with no indent.

\end{document}

TOC and section titles

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .