目录中没有目录阁楼时的水平线和间距

目录中没有目录阁楼时的水平线和间距

我在其他关于目录的问题中搜索了有关水平线和间距的信息,但无法重现我想要的内容。此外,我还收到一些 badbox 调整目录中的水平间距。

当使用 tocnumwidth 为子部分插入水平空间时,我得到的是未满的 \hbox。有人知道如何摆脱 badboxes 吗?

\RedeclareSectionCommands[tocnumwidth=10pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin]{subsection,subsubsection}

此外,我想知道如何在章节、节和小节下插入水平线来设置目录样式?

以下是我的完整 MWE。提前致谢!

\documentclass{scrreprt}

\usepackage[
includemp,
                  showframe,
                  reversemp,
            paperwidth=20.1cm,
            paperheight=25.80cm,
            top=2.30cm,
            bottom=3.4cm,
            inner=2.7cm,
            outer=2.7cm,
            marginparwidth=1.6cm, % Fixed for now
            marginparsep=0.4cm
            ]{geometry}

\usepackage{etoolbox} %control vspave in ToC
\usepackage{lipsum}
\usepackage[footwidth=textwithmarginpar]{scrlayer-scrpage}
% \usepackage{tocstyle}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother

%-------------------- CHAPTER HEADINGS and TOC -----------

\renewcommand*{\chapterformat}{\intoleftmargin{\chapappifchapterprefix{\ 
}\thechapter\autodot}}%
\renewcommand*{\sectionformat}{\intoleftmargin{\thesection\autodot}}
\renewcommand*{\subsectionformat}{\intoleftmargin{\thesubsection\autodot}}
\renewcommand*{\subsubsectionformat}
{\intoleftmargin{\thesubsubsection\autodot}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}
\RedeclareSectionCommands[tocnumwidth=0pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin]{chapter,section}
\RedeclareSectionCommands[tocnumwidth=10pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin]{subsection,subsubsection}
\newcommand*{\intoleftmargin}[1]{\makebox[0pt][r]{#1\hskip\marginparsep}}

\makeatletter
\renewcommand{\@dotsep}{10000} 
\makeatother

\makeatletter
\pretocmd{\chapter}{\addtocontents{toc}{\protect\addvspace{15\p@}}}{}{}
\pretocmd{\section}{\addtocontents{toc}{\protect\addvspace{5\p@}}}{}{}
\pretocmd{\subsection}{\addtocontents{toc}{\protect\addvspace{2\p@}}}{}{}
\makeatother

%---------------------------------------------------------

%---------------------------PAGE STYLE--------------------

\clearpairofpagestyles
\automark{chapter}
\ifoot{%
  \makebox[0pt][r]{\pagemark\autodot\hskip\marginparsep}%
  \ifodd \value{page}%
    Quantifying goodness of morphodynamic field predictions
  \else
    \headmark %
  \fi
}
\setkomafont{pageheadfoot}{\normalfont}
\renewcommand\chaptermarkformat{}

\renewcommand*\chapterpagestyle{scrheadings}

%---------------------------------------------------------

\begin{document}


\tableofcontents


\chapter{chapter}
\section{section}
\section{section}
\section{section}
\subsection{subsection}

\chapter{chapter}
\section{section}
\subsection{subsection}

\chapter{chapter}
\section{section}
\subsection{subsection}

\chapter*{section}
\addcontentsline{toc}{section}{section}

\end{document}

在此处输入图片描述

答案1

下面的操作按照你的要求进行(但我不知道这是否是正确的方法,也不知道这是否是正确的做法):

\documentclass{scrreprt}

% packages>>>
\usepackage[%>>>geometry
includemp,
                  showframe,
                  reversemp,
            paperwidth=20.1cm,
            paperheight=25.80cm,
            top=2.30cm,
            bottom=3.4cm,
            inner=2.7cm,
            outer=2.7cm,
            marginparwidth=1.6cm, % Fixed for now
            marginparsep=0.4cm
            ]{geometry}%<<<
\usepackage{etoolbox} %control vspave in ToC
\usepackage{lipsum}
\usepackage[footwidth=textwithmarginpar]{scrlayer-scrpage}
% \usepackage{tocstyle}
%<<<

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother

%-------------------- CHAPTER HEADINGS and TOC ----------->>>

\renewcommand*{\chapterformat}{\intoleftmargin{\chapappifchapterprefix{\ 
}\thechapter\autodot}}%
\renewcommand*{\sectionformat}{\intoleftmargin{\thesection\autodot}}
\renewcommand*{\subsectionformat}{\intoleftmargin{\thesubsection\autodot}}
\renewcommand*{\subsubsectionformat}
{\intoleftmargin{\thesubsubsection\autodot}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}
\RedeclareSectionCommands[tocnumwidth=0pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin,tocentryformat=\lineundertocchap]{chapter}
\RedeclareSectionCommands[tocnumwidth=0pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin,tocentryformat=\lineundertocsec]{section}
\RedeclareSectionCommands[tocnumwidth=10pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin,tocentryformat=\lineundertocsec]{subsection,subsubsection}
\newcommand*{\intoleftmargin}[1]{\makebox[0pt][r]{#1\hskip\marginparsep}\hfill}
\newcommand*{\lineundertocsec}[1]{%
    \ifunderlinetoc%
        \raisebox{-4pt}{\makebox[0pt][l]{\rule{\linewidth}{0.5pt}}}%
    \fi#1}
\newcommand*{\lineundertocchap}[1]{%
    \ifunderlinetoc%
        \raisebox{-4pt}{\makebox[0pt][l]{\rule{\linewidth}{1pt}}}%
    \fi\sffamily\bfseries#1}
\newif\ifunderlinetoc\underlinetoctrue

\makeatletter
\renewcommand{\@dotsep}{10000} 
\makeatother

\makeatletter
\pretocmd{\chapter}{\addtocontents{toc}{\protect\addvspace{15\p@}}}{}{}
\pretocmd{\section}{\addtocontents{toc}{\protect\addvspace{5\p@}}}{}{}
\pretocmd{\subsection}{\addtocontents{toc}{\protect\addvspace{2\p@}}}{}{}
\makeatother

%---------------------------------------------------------<<<

%---------------------------PAGE STYLE-------------------->>>

\clearpairofpagestyles
\automark{chapter}
\ifoot{%
  \makebox[0pt][r]{\pagemark\autodot\hskip\marginparsep}%
  \ifodd \value{page}%
    Quantifying goodness of morphodynamic field predictions
  \else
    \headmark %
  \fi
}
\setkomafont{pageheadfoot}{\normalfont}
\renewcommand\chaptermarkformat{}

\renewcommand*\chapterpagestyle{scrheadings}

%---------------------------------------------------------<<<

\begin{document}


\tableofcontents

\addtocontents{toc}{\protect\underlinetocfalse}
\chapter{chapter}
\addtocontents{toc}{\protect\underlinetoctrue}
\section{section}
\section{section}
\section{section}
\subsection{subsection}
\subsubsection{subsection}

\chapter{chapter}
\section{section}
\subsection{subsection}
\subsubsection{subsection}

\chapter{chapter}
\section{section}
\subsection{subsection}
\subsubsection{subsection}

\chapter*{section}
\addcontentsline{toc}{section}{section}

\end{document}

在此处输入图片描述

相关内容