4

I'd like to add unnumbered subsections and subsubsections to my toc and my headers using addsec. How could I do that ? This is my MWE:

\documentclass[fontsize=11pt,%
               twoside=semi,%
               headings=small,%
               chapterprefix=true,%
               listof=flat]%
{scrbook}
\usepackage[utf8]{inputenc}% can be removed with an uptodate TeX distribution
\usepackage[T1]{fontenc}
\usepackage [french]{babel}
\usepackage{fontspec}
\setmainfont{Didot}
\usepackage{lipsum}
\usepackage[
  paperheight=21.5cm, paperwidth=15cm,
  left=2cm, right=2cm, top=1.5cm, bottom=2.5cm,
  bindingoffset=7mm,
  includehead,includefoot
  ]{geometry}


%%%%%%%%%%%%%%%%%%%%%%%%%%numéros page%%%%%%%%%%%%
\usepackage[automark]{scrlayer-scrpage}% See scrguien.pdf, chapter 5
\ihead{\headmark}% running head at the inner edge of the page head
\ohead*{\pagemark}% page number at the outer edge of the page head (plain pages too)
\ofoot*{}% no page number at the outer edge of the page footer (plain pages too)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\addtokomafont{pageheadfoot}{\scshape\small}%changed to small caps in headers
\addtokomafont{disposition}{\normalfont}
\addtokomafont{part}{\bfseries\scshape\LARGE}
\addtokomafont{chapter}{\bfseries\scshape\LARGE}
\addtokomafont{section}{\bfseries\scshape\large}
\addtokomafont{subsection}{\bfseries\itshape}
\addtokomafont{subsubsection}{\bfseries\itshape}
\addtokomafont{paragraph}{\scshape\small}
\addtokomafont{subparagraph}{\scshape\small}
%\let\bfseries\mdseries



\renewcommand*{\chapterformat}{%
  \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter%\autodot
  \IfUsePrefixLine{}{\enskip}}%
}




\begin{document}

\tableofcontents

\mainmatter
\addchap{A chapter}
\lipsum
\addsec{A section}
\lipsum
\end{document}
2
  • KOMA-Script does not provide something like \addsubsec and \addsubsubsec. Should all subsections and subsubsections be unnumbered?
    – esdd
    Jul 2, 2019 at 10:48
  • Regarding the header entries: what is the desired result? Only subsections and subsubsections in header or additional entries to the default section and chapter entries or ...
    – esdd
    Jul 2, 2019 at 10:50

2 Answers 2

8

KOMA-Script version 3.27 has introduced an option nonumber=true for all section levels:

\documentclass[
  headings=optiontoheadandtoc% activates the advanced functionality of the optional argument of the sectioning commands
]{scrbook}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter[nonumber=true]{Chapter without number}
\section[nonumber=true]{Section without number}
\subsection[nonumber=true]{Subsection without number}
\Blindtext[10]
\blinddocument
\end{document}

Result:

enter image description here

enter image description here

2

Unnumbered (sub)subsections can be added to the toc with \addxcontentsline{toc}{subsection}{A Subsection}.

To make subsubsections visible there, also add \setcounter{tocdepth}{4}

In principle one could also add them to the header, but where should they be, the header is already occupied by the section and chapter for odd and even pages. There is no third or forth type of page for them.

\documentclass[fontsize=11pt,%
               twoside=semi,%
               headings=small,%
               chapterprefix=true,%
               listof=flat]%
{scrbook}
\usepackage[utf8]{inputenc}% can be removed with an uptodate TeX distribution
\usepackage[T1]{fontenc}
\usepackage [french]{babel}
%\usepackage{fontspec}
%\setmainfont{Didot}
\usepackage{lipsum}
\usepackage[
  paperheight=21.5cm, paperwidth=15cm,
  left=2cm, right=2cm, top=1.5cm, bottom=2.5cm,
  bindingoffset=7mm,
  includehead,includefoot
  ]{geometry}


%%%%%%%%%%%%%%%%%%%%%%%%%%numéros page%%%%%%%%%%%%
\usepackage[automark]{scrlayer-scrpage}% See scrguien.pdf, chapter 5
\ihead{\headmark}% running head at the inner edge of the page head
\ohead*{\pagemark}% page number at the outer edge of the page head (plain pages too)
\ofoot*{}% no page number at the outer edge of the page footer (plain pages too)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\addtokomafont{pageheadfoot}{\scshape\small}%changed to small caps in headers
\addtokomafont{disposition}{\normalfont}
\addtokomafont{part}{\bfseries\scshape\LARGE}
\addtokomafont{chapter}{\bfseries\scshape\LARGE}
\addtokomafont{section}{\bfseries\scshape\large}
\addtokomafont{subsection}{\bfseries\itshape}
\addtokomafont{subsubsection}{\bfseries\itshape}
\addtokomafont{paragraph}{\scshape\small}
\addtokomafont{subparagraph}{\scshape\small}
%\let\bfseries\mdseries



\renewcommand*{\chapterformat}{%
  \mbox{\chapappifchapterprefix{\nobreakspace}\thechapter%\autodot
  \IfUsePrefixLine{}{\enskip}}%
}

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}


\begin{document}

\tableofcontents

\mainmatter
\addchap{A chapter}
\lipsum
\addsec{A section}
\lipsum


\subsection*{A subsection}
\addxcontentsline{toc}{subsection}{A Subsection}
\subsection*{A subsubsection}
\addxcontentsline{toc}{subsubsection}{A subsubsection}

\end{document}
4
  • Thanks. I knew that way and thought there was a trick to use add... function.
    – domi
    Jul 2, 2019 at 10:49
  • @esdd Thanks! What is the difference?
    – Åke
    Jul 2, 2019 at 10:56
  • See the KOMA-Script documentation (scrguien.pdf). With \addxcontentsline option toc=numberline and possible redefinitions of \addsubsectiontocentry etc. would be respected.
    – esdd
    Jul 2, 2019 at 11:08
  • @esdd Thanks a lot for the explanation!
    – Åke
    Jul 2, 2019 at 11:08

You must log in to answer this question.

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