KOMA Script tocstyle tocline,大条目的第二行无缩进

KOMA Script tocstyle tocline,大条目的第二行无缩进

tocstyle tocline如何使用KOMA Script 类取消目录中大条目的第二行缩进scrartcl?我在这里发现了同样的问题:ToC:如何使大型条目的第二行不缩进?但对于tocloft,答案似乎不起作用。

编辑:添加了 MWE。我正在使用此处描述的自定义分段命令:自定义文档结构

\documentclass{scrartcl}

\linespread{1.1}
\setlength{\parindent}{0.5cm}

\usepackage{lipsum}

\newcommand\entryprefix[2]{%
  #1\ #2
}

\DeclareNewSectionCommand[
  style=section,
  level=\subsubsectionnumdepth,
  beforeskip=3.25ex plus 1ex minus .2ex,
  afterskip= 1.5ex plus .2ex,
  indent=0pt,
  font=\mdseries\slshape,
  %tocstyle=gobble,
  tocstyle=default,
  toclevel=\subsubsectiontocdepth,
  tocindent=4em,
  tocnumwidth=2.3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{Article}
]{Article}
\renewcommand\Articleformat{Article~\theArticle\autodot\enskip}

\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{Article}
    {\raggedright\textbf{\upshape#3}#4.}
    {#3#4}%
}

\begin{document}

\tableofcontents

\lipsum[1-2]

\Article{Short title}

\lipsum[3]

\Article{Very long article title that (on the Table of Contents) should start on the beginning of the line instead of at the beginning of the word Article}

\lipsum[4]

\end{document}

答案1

更新

现在问题中有一个 MWE,我了解您需要更改(仅?)自定义分段命令\Article。您可以简单地从以下原始答案中调整解决方案:

\documentclass{scrartcl}
\linespread{1.1}
\setlength{\parindent}{0.5cm}
\usepackage{lipsum}% only for dummy text

\DeclareNewSectionCommand[
  style=section,
  level=\subsubsectionnumdepth,
  beforeskip=3.25ex plus 1ex minus .2ex,
  afterskip= 1.5ex plus .2ex,
  indent=0pt,
  font=\mdseries\slshape,
  %tocstyle=gobble,
  tocstyle=default,
  toclevel=\subsubsectiontocdepth,
  tocindent=4em,
  tocnumwidth=0pt% <- changed to 0pt, tocdynnumwidth and tocentrynumberformat are removed
]{Article}
\renewcommand\Articleformat{Article~\theArticle\autodot\enskip}

\renewcommand*\addArticletocentry[2]{%
  \addtocentrydefault{Article}{}
    {\IfArgIsEmpty{#1}{}{Article~\makebox[1.5em][l]{#1\protect\autodot}}#2}%
}% maybe you have to adjust the 1.5em -> run twice to see the change in TOC

\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{Article}
    {\raggedright\textbf{\upshape#3}#4.}
    {#3#4}%
}

\begin{document}
\tableofcontents
\lipsum[1-2]
\Article{Short title}
\lipsum[3]
\Article{Very long article title that (on the Table of Contents) should start on the beginning of the line instead of at the beginning of the word Article}
\lipsum[4]
\end{document}

结果:

在此处输入图片描述

但也许你想要:

在此处输入图片描述

\DeclareNewSectionCommand[
  style=section,
  level=\subsubsectionnumdepth,
  beforeskip=3.25ex plus 1ex minus .2ex,
  afterskip= 1.5ex plus .2ex,
  indent=0pt,
  font=\mdseries\slshape,
  %tocstyle=gobble,
  tocstyle=default,
  toclevel=\subsubsectiontocdepth,
  tocindent=0pt,% <- changed
  tocnumwidth=0pt% <- changed to 0pt, tocdynnumwidth and tocentrynumberformat are removed
]{Article}
\renewcommand\Articleformat{Article~\theArticle\autodot\enskip}

\renewcommand*\addArticletocentry[2]{% <- definition changed
  \addtocentrydefault{Article}{}
    {\IfArgIsEmpty{#1}{}{\hspace{4em}Article~\makebox[1.5em][l]{#1\protect\autodot}}#2}%
}% maybe you have to adjust the 1.5em -> run twice to see the change in TOC

或者:

在此处输入图片描述

\DeclareNewSectionCommand[
  style=section,
  level=\subsubsectionnumdepth,
  beforeskip=3.25ex plus 1ex minus .2ex,
  afterskip= 1.5ex plus .2ex,
  indent=0pt,
  font=\mdseries\slshape,
  %tocstyle=gobble,
  tocstyle=default,
  toclevel=\subsubsectiontocdepth,
  tocindent=0pt,
  tocnumwidth=0pt
]{Article}
\renewcommand\Articleformat{Article~\theArticle\autodot\enskip}

\renewcommand*\addArticletocentry[2]{% <-definition changed
  \addtocentrydefault{Article}{}
    {\IfArgIsEmpty{#1}{}{Article~\makebox[1.5em][l]{#1\protect\autodot}}#2}%
}% maybe you have to adjust the 1.5em -> run twice to see the change in TOC

原始答案

不幸的是,问题中没有 MWE,所以这只是一个猜测:

\documentclass{scrartcl}
\RedeclareSectionCommands[%
  tocnumwidth=0pt%
]{section,subsection,subsubsection,paragraph,subparagraph}

\renewcommand*\addsectiontocentry[2]{%
  \addtocentrydefault{section}{}
    {\IfArgIsEmpty{#1}{}{\makebox[1.5em][l]{#1\protect\autodot}}#2}%
}
\renewcommand*\addsubsectiontocentry[2]{%
  \addtocentrydefault{subsection}{}
    {\IfArgIsEmpty{#1}{}{\makebox[2.3em][l]{#1\protect\autodot}}#2}%
}
\renewcommand*\addsubsubsectiontocentry[2]{%
  \addtocentrydefault{subsubsection}{}
    {\IfArgIsEmpty{#1}{}{\makebox[3.8em][l]{#1\protect\autodot}}#2}%
}
\renewcommand*\addparagraphtocentry[2]{%
  \addtocentrydefault{paragraph}{}
    {\IfArgIsEmpty{#1}{}{\makebox[4.1em][l]{#1\protect\autodot}}#2}%
}
\renewcommand*\addsubparagraphtocentry[2]{%
  \addtocentrydefault{subparagraph}{}
    {\IfArgIsEmpty{#1}{}{\makebox[5em][l]{#1\protect\autodot}}#2}%
}

\usepackage{lipsum}% only for dummy text
\begin{document}
\tableofcontents
\clearpage
\addsec{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\lipsum[1-5]
\section{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\lipsum[6]
\subsection{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\lipsum[7-10]
\subsection{Lorem ipsum dolor sit amet, consectetuer adipiscing elit.}
\lipsum[11-15]
\end{document}

在此处输入图片描述

相关内容