如何阻止目录中出现新的子段落条目

如何阻止目录中出现新的子段落条目

我使用 titlesec 包添加了一个新的 subsubparagraph 节级别,并得到了如何在 \subsubsection 下添加带有标题的额外层级https://tex.stackexchange.com/a/94404/98753

文内标题没问题,但新标签已添加到目录中,并带有页码。我可以通过向调用添加星号来删除它:\subsubparagraph*{New label}。但有没有办法将其构建到标题格式中?

一位 MWE 表示:

\documentclass{article}
\usepackage[raggedright]{titlesec}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\titleformat{\paragraph}[hang]
  {\bfseries\small}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}

\titleformat{\subparagraph}[hang]
  {\bfseries\small}{\thesubparagraph}{1em}{}
\titlespacing{\subparagraph}{32pt}{0.5em}{0em}

\titleclass{\subsubparagraph}{straight}[\subparagraph]
\newcounter{subsubparagraph}
\renewcommand{\thesubsubparagraph}{\arabic{subsubparagraph}}
\titleformat{\subsubparagraph}[runin]
  {\normalfont\normalsize\bfseries}{\thesubsubparagraph}{1em}{}
\titlespacing*{\subsubparagraph}{32pt}{3.25ex plus 1ex minus .2ex}{1em}

\begin{document}
\tableofcontents
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph} 
  \subparagraph{Subparagraph 1} 
  \subparagraph{Subparagraph 2}
    \subsubparagraph{New label}
      Finally, some ordinary text. I don't want a whole Lorem ipsum paragraph, so I'll just manually add a couple of lines.
\subsubsection{Subsubsection 2}
\end{document}

所生成文档的屏幕截图

答案1

你必须定义\l@subsubparagraph,例如

\makeatletter
\newcommand\l@subsubparagraph{\@dottedtocline{6}{14em}{7em}}
\makeatother

的第一个参数\@dottedtocline定义了的 toclevel \subsubparagraph

在此处输入图片描述

代码:

\documentclass{article}
\usepackage[raggedright]{titlesec}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\titleformat{\paragraph}[hang]
  {\bfseries\small}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}

\titleformat{\subparagraph}[hang]
  {\bfseries\small}{\thesubparagraph}{1em}{}
\titlespacing{\subparagraph}{32pt}{0.5em}{0em}

\titleclass{\subsubparagraph}{straight}[\subparagraph]
\newcounter{subsubparagraph}
\renewcommand{\thesubsubparagraph}{\arabic{subsubparagraph}}
\titleformat{\subsubparagraph}[runin]
  {\normalfont\normalsize\bfseries}{\thesubsubparagraph}{1em}{}
\titlespacing*{\subsubparagraph}{32pt}{3.25ex plus 1ex minus .2ex}{1em}

\makeatletter
\newcommand\l@subsubparagraph{\@dottedtocline{6}{14em}{7em}}
\makeatother

\begin{document}
\tableofcontents
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph} 
  \subparagraph{Subparagraph 1} 
  \subparagraph{Subparagraph 2}
    \subsubparagraph{New label}
      Finally, some ordinary text. I don't want a whole Lorem ipsum paragraph, so I'll just manually add a couple of lines.
\subsubsection{Subsubsection 2}
\end{document}

相关内容