tocstyle: Wort „Kapitel 1“ im Inhaltsverzeichnis fett darstellen, aber nicht den Kapiteltitel

tocstyle: Wort „Kapitel 1“ im Inhaltsverzeichnis fett darstellen, aber nicht den Kapiteltitel

In der Klasse scrreprt möchte ich mithilfe des Pakets tocstyle, dass im Inhaltsverzeichnis das Wort „Kapitel 1“ fett dargestellt wird, der Kapiteltitel jedoch nicht (siehe Bild). Wie erreiche ich das? Standardmäßig ist alles fett dargestellt. Mit \addtokomafont{chapterentry}{\mdseries}ändert sich die Schriftart der gesamten Inhaltsverzeichniseintragszeile.

Bildbeschreibung hier eingeben

MWE:

\documentclass[twoside, openright, BCOR=1cm, headsepline,chapterprefix=true]{scrreprt}

%%---header/footer
\usepackage[manualmark]{scrlayer-scrpage}

\automark{chapter}
%%--"Chapter #" in lehead, chapter name in rohead
\renewcommand*\chaptermark[1]{%
    \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

\AfterTOCHead[toc]{\markboth{}{\contentsname}}


\usepackage{lipsum}

%%---add "Chapter #" in TOC before chapter title, only for numbered chapters
\let\oldaddchaptertocentry\addchaptertocentry
\renewcommand{\addchaptertocentry}[2]{%
    \ifstr{#1}{}{%
        \oldaddchaptertocentry{#1}{#2}}{%
        \oldaddchaptertocentry{\chapapp{} #1}{#2}%
}}


\usepackage[toctextentriesindented]{tocstyle}
\usetocstyle{KOMAlike}
\settocstylefeature{spaceafternumber}{16pt}

\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{0}

\begin{document}

\tableofcontents

\chapter{An interesting title}
\thispagestyle{empty}

\newpage

\section{A slightly less interesting title}
\lipsum[1-5]

\addchap{Unnumbered chapter}
\thispagestyle{empty}

\newpage

\section{Section title}
\lipsum[6-15]

\end{document}

Antwort1

Beachten Sie, dass das Paket tocstylenicht mehr weiterentwickelt wird. Sie erhalten daher Warnungen.

Ich würde vorschlagen, Befehle, Optionen usw. des Pakets zu verwenden tocbasic. Dieses Paket ist auch Teil des KOMA-Script-Pakets und die KOMA-Script-Klasse wird tocbasicautomatisch geladen.

Vorschlag ohne tocstyle:

\documentclass[twoside, openright, BCOR=1cm, headsepline,chapterprefix=true,
  toc=indentunnumbered% <- added
]{scrreprt}
\usepackage{lipsum}% only for dummy text

%%---header/footer
\usepackage[manualmark]{scrlayer-scrpage}

\automark{chapter}
%%--"Chapter #" in lehead, chapter name in rohead
\renewcommand*\chaptermark[1]{%
    \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

\AfterTOCHead[toc]{\markboth{}{\contentsname}}

\addtokomafont{chapterentry}{\mdseries}
\DeclareTOCStyleEntry[
  entrynumberformat=\textbf,
  numsep=16pt,
  dynnumwidth
]{chapter}{chapter}

%%---add "Chapter #" in TOC before chapter title, only for numbered chapters
\let\oldaddchaptertocentry\addchaptertocentry
\renewcommand{\addchaptertocentry}[2]{%
    \ifstr{#1}{}{%
        \oldaddchaptertocentry{#1}{#2}}{%
        \oldaddchaptertocentry{\chapapp{} #1}{#2}%
}}

\setcounter{secnumdepth}{\chapternumdepth}
\setcounter{tocdepth}{\chaptertocdepth}

\renewcommand\chapterpagestyle{empty}% if all chapter pages should use page style empty
\begin{document}

\tableofcontents
\chapter{An interesting title}
\newpage
\section{A slightly less interesting title}
\lipsum[1-5]

\addchap{Unnumbered chapter}
\newpage
\section{Section title}
\lipsum[6-15]
\end{document}

Führen Sie den Lauf dreimal aus, um Folgendes zu erhalten:

Bildbeschreibung hier eingeben


Wenn die Seitenzahl des Kapiteleintrags ebenfalls fett dargestellt werden soll, können Sie hinzufügen

pagenumberformat=\usekomafont{chapterentry}\textbf

zu den Optionen \DeclareTOCStyleEntryfür Kapitel.

Beispiel:

\documentclass[twoside, openright, BCOR=1cm, headsepline,chapterprefix=true,
  toc=indentunnumbered% <- added
]{scrreprt}
\usepackage{lipsum}% only for dummy text

%%---header/footer
\usepackage[manualmark]{scrlayer-scrpage}

\automark{chapter}
%%--"Chapter #" in lehead, chapter name in rohead
\renewcommand*\chaptermark[1]{%
    \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

\AfterTOCHead[toc]{\markboth{}{\contentsname}}

\addtokomafont{chapterentry}{\mdseries}
\DeclareTOCStyleEntry[
  entrynumberformat=\textbf,
  pagenumberformat=\usekomafont{chapterentry}\textbf,
  dynnumwidth
]{chapter}{chapter}

%%---add "Chapter #" in TOC before chapter title, only for numbered chapters
\let\oldaddchaptertocentry\addchaptertocentry
\renewcommand{\addchaptertocentry}[2]{%
    \ifstr{#1}{}{%
        \oldaddchaptertocentry{#1}{#2}}{%
        \oldaddchaptertocentry{\chapapp{} #1}{#2}%
}}

\setcounter{secnumdepth}{\chapternumdepth}
\setcounter{tocdepth}{\chaptertocdepth}

\renewcommand\chapterpagestyle{empty}% if all chapter pages should use page style empty
\begin{document}

\tableofcontents
\chapter{An interesting title}
\newpage
\section{A slightly less interesting title}
\lipsum[1-5]

\addchap{Unnumbered chapter}
\newpage
\section{Section title}
\lipsum[6-15]
\end{document}

Führen Sie den Lauf dreimal aus, um Folgendes zu erhalten:

Bildbeschreibung hier eingeben

Antwort2

So geht's: Fügen Sie in \textnormaldas zweite Argument Ihres definierten Befehls Folgendes ein:

\documentclass[twoside, openright, BCOR=1cm, headsepline,chapterprefix=true]{scrreprt}

%%---header/footer
\usepackage[manualmark]{scrlayer-scrpage}

\automark{chapter}
%%--"Chapter #" in lehead, chapter name in rohead
\renewcommand*\chaptermark[1]{%
    \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

\AfterTOCHead[toc]{\markboth{}{\contentsname}}


\usepackage{lipsum}

%%---add "Chapter #" in TOC before chapter title, only for numbered chapters
\let\oldaddchaptertocentry\addchaptertocentry
\renewcommand{\addchaptertocentry}[2]{%
    \ifstr{#1}{}{%
        \oldaddchaptertocentry{#1}{\textnormal{#2}}}{%
        \oldaddchaptertocentry{\chapapp{} #1}{\textnormal{#2}}%
}}


\usepackage[toctextentriesindented]{tocstyle}
\usetocstyle{KOMAlike}
\settocstylefeature{spaceafternumber}{16pt}

\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{0}

\begin{document}

\tableofcontents

\chapter{An interesting title}
\thispagestyle{empty}

\newpage

\section{A slightly less interesting title}
\lipsum[1-5]

\addchap{Unnumbered chapter}
\thispagestyle{empty}

\newpage

\section{Section title}
\lipsum[6-15]

\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen