如何建立子段落和子子段落?

如何建立子段落和子子段落?

我正在嘗試創建一個子段落和子子段落。 Subsubsubparagraph 工作正常,但 subsubparagraph 在我的目錄中給出了奇怪的結果。

這是我的程式碼:

\documentclass[parskip=full]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{titlesec}

\makeatletter

\titleclass{\subsubparagraph}{straight}[\subparagraph]
\titleformat{\subsubparagraph}{\normalfont\normalsize\bfseries}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}.\arabic{subparagraph}.\arabic{subsubparagraph}}{1em}{}

\titlespacing{\subsubparagraph}{0pt}{-3.25ex plus-1ex minus-.2ex}{1.25ex plus .1ex}

\newcounter{subsubparagraph}[subparagraph]

\titlespacing{\subparagraph}{0pt}{-3.25ex plus-1ex minus-.2ex}{1.25ex plus .1ex}
\titleclass{\subsubsubparagraph}{straight}[\subparagraph]

\titleformat{\subsubsubparagraph}{\normalfont\normalsize\bfseries}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}.\arabic{subparagraph}.\arabic{subsubparagraph}.\arabic{subsubparagraph}}{1em}{}

\titlespacing{\subsubsubparagraph}{0pt}{3.25ex plus-1ex minus-.2ex}{1.25ex plus .1ex}

\newcounter{subsubsubparagraph}[subsubparagraph]

\renewcommand\thesubsubparagraph {\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}.\arabic{subparagraph}.\arabic{subsubparagraph}}% 

\setcounter{secnumdepth}{8}
\setcounter{tocdepth}{8}

\newcommand*\l@subsubparagraph{\@dottedtocline{7}{12em}{2em}}
\newcommand*\l@subsubsubparagraph{\@dottedtocline{8}{17em}{2em}}


\begin{document}

\setcounter{tocdepth}{10}
\setcounter{secnumdepth}{10}
\tableofcontents

\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph}
\subparagraph{Subparagraph}
\subsubparagraph{Subsubparagraph}
\subsubsubparagraph{Subsubparagraph}

\end{document}

該小段的標題與編號重疊。 在此輸入影像描述

我怎樣才能解決這個問題?

答案1

請注意,該套件titlesec破壞了一些 KOMA-Script 功能。所以不建議將此包與scrartcl.

您可以使用\DeclareNewSectionCommands\RedeclareSectionCommand

\documentclass[parskip=full]{scrartcl}[2016/05/10]
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\DeclareNewSectionCommands[
  style=section,
  level=\subparagraphnumdepth+1,
  beforeskip=-3.25ex plus -1ex minus -.2ex,
  afterskip=1.25ex plus .1ex,
  counterwithin=subparagraph,
  font={},
  indent=0pt,
  toclevel=\subparagraphtocdepth+1,
  tocnumwidth=6em
]{subsubparagraph,subsubsubparagraph}

\RedeclareSectionCommand[
  tocindent=12em
]{subsubparagraph}
\RedeclareSectionCommand[
  tocindent=14em
]{subsubsubparagraph}

\setcounter{secnumdepth}{\subsubsubparagraphnumdepth}
\setcounter{tocdepth}{\subsubsubparagraphtocdepth}

\begin{document}
\tableofcontents
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Text
\paragraph{Paragraph}
Text
\subparagraph{Subparagraph}
Text
\subsubparagraph{Subsubparagraph}
Text
\subsubsubparagraph{Subsubsubparagraph}
Text
\end{document}

結果:

在此輸入影像描述

正如您在圖片中看到的那樣paragraph,它們subparagraph是內聯標題。負值afterskip設定水平跳躍,導致內聯標題。因此,如果新定義層級的標題也應該是內聯標題,請使用afterskip=-1em.但是,如果後面應該有垂直空間paragraph,請將subparagraph其變更afterskip為正值,例如:

\RedeclareSectionCommands[
  afterskip=1.25ex plus .1ex
]{paragraph,subparagraph}

相關內容