我想使用 addsec 将未编号的子节和子子节添加到目录和标题中。我该怎么做?这是我的 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}
答案1
nonumber=true
KOMA-Script 3.27 版本为所有部分级别引入了一个选项:
\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}
结果:
答案2
可以使用 将未编号的(子)小节添加到目录中\addxcontentsline{toc}{subsection}{A Subsection}
。
为了使子部分可见,还添加\setcounter{tocdepth}{4}
原则上也可以将它们添加到页眉中,但它们应该放在哪里呢?页眉已经被奇数页和偶数页的节和章占据了。没有第三或第四种类型的页面。
\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}