如何使用 tocbasic 缩进没有数字的目录条目(作为索引)?

如何使用 tocbasic 缩进没有数字的目录条目(作为索引)?

如同这个问题,我怎样才能将chapter*类似条目缩进到与编号章节相同的缩进量? section*使用\KOMAoptions{toc=indentunnumbered}

与无编号章节缩进的其他问题的主要区别在于索引:索引的缩进不适用于\addchap/\addsec等。

在此处输入图片描述

\documentclass[ngerman,twoside=false,listof=totoc,listof=leveldown]{scrbook}
\usepackage{imakeidx}
\usepackage[style=archaeologie]{biblatex}
\addbibresource{archaeologie-examples.bib}
\usepackage{babel}
\newcommand\tocgobble[1]{}% <- added
\newcommand\tocpageseparator{\footnotesize\,\mbox{---}\,}
\newcommand\tocpagenumberbox[1]{\mbox{#1}}
\KOMAoptions{toc=indentunnumbered}%indent only for section* !?

\RedeclareSectionCommands[
  tocraggedpagenumber,
  toclinefill=\tocpageseparator,
  tocindent=0em,
  tocnumwidth=4em,
  tocpagenumberbox=\tocpagenumberbox
]{chapter,section,subsection,subsubsection,paragraph}

\RedeclareSectionCommand[
  tocentryformat=\large\scshape,
  tocindent=0em,
  tocnumwidth=4em,
  tocpagenumberbox=\tocgobble
]{part}

\RedeclareSectionCommand[%
  tocentryformat=\textbf%
]{chapter}

\makeindex[
  intoc,
  name=loc, 
  title={Locations},
  columns=3,
  ]
\indexsetup{%
  level=\section*,
  toclevel=section,
  noclearpage,
  firstpagestyle=scrheadings,
  headers={\indexname}{\indexname},
    }
\begin{document}
  \nocite{*}
  \frontmatter
  \tableofcontents
  \mainmatter
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \setcounter{page}{100}
  \part{part}
  \chapter{chapter chapter}
  \section{section section section}  \section{section section section}  \section{section section section}
  \backmatter

  \part{part}
\index[loc]{A location}
  \chapter*{Abbildungs-, Tabellen-, Tafelverzeichnis}
  \addcontentsline{toc}{chapter}{Abbildungs-, Tabellen-, Tafelverzeichnis}
  \listoffigures
  \chapter*{\bibname}
  \addcontentsline{toc}{chapter}{\bibname}
  \printbiblist[%
      heading=subbibintoc,%
    title={Zeitschriftenabkürzungen}]{shortjournal}
  \printbiblist[%
    heading=subbibintoc,%
    title={Reihenabkürzungen}]{shortseries}
  \printbibliography[heading=subbibintoc]
\chapter*{Indizes}
\addcontentsline{toc}{chapter}{Indizes}
\printindex[loc]
\end{document}

答案1

你的主张是错误的。你只是使用了错误的命令。

lukasKomaIndentunnumbered

\documentclass[ngerman,twoside=false,listof=totoc,listof=leveldown]{scrbook}
\usepackage{imakeidx}
\KOMAoptions{toc=indentunnumbered}%indent only for section* !?
\makeindex[
  name=loc, 
  title={Locations},
  columns=3,
  ]
\indexsetup{%
  level=\addsec,
  noclearpage,
  headers={\indexname}{\indexname},
    }
\begin{document}
  \tableofcontents
\chapter{Wombat}
\index[loc]{A location}
\section{Walter}
\addchap{Capybara}
\addsec{Carl}
\chapter*{Lion}
\addcontentsline{toc}{chapter}{Lion}% Not the KOMA way
\section*{Laura}
\addcontentsline{toc}{section}{Laura}% Not the KOMA way
\addchap{Indizes}
\printindex[loc]
\end{document}

请注意,这些命令仅针对、和级别\add<level>定义。partchaptersection

所有 KOMA-Script 类的部分命令都使用命令\addxcontentsline(由包提供tocbasic)而不是\addcontentsline。宏\addxcontentsline知道一个额外的可选参数:

\addxcontentsline{<extension>}{<level>}[<number>]{<text>}

选项toc=indentunnumbered需要使用\addxcontentsline

\documentclass{scrbook}
\KOMAoptions{toc=indentunnumbered}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{A section}
\subsection{A subsection}

\addchap{Unnumbered chapter}
\addsec{Unnumbered section}
\subsection*{Unnumbered subsection%
  \addxcontentsline{toc}{subsection}{Unnumbered section}%
}

\end{document}

在此处输入图片描述

相关内容