![如何创建 subsubparagraph 和 subsubsubparagraph?](https://linux22.com/image/358376/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%20subsubparagraph%20%E5%92%8C%20subsubsubparagraph%EF%BC%9F.png)
我正在尝试创建一个 subsubparagraph 和 subsubsubparagraph。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}