我正在使用 LaTeX 完成大学作业,我的教授有一些奇怪的格式规则:
有 7 个切片层,它们都必须出现在目录中。这比我可以用、、\section
和存档的要多。有没有办法定义新命令来添加新的切片层?\subsection
\subsubsection
\paragraph
\subparagraph
这些部分的计数也相当不寻常:
AI 1.a)aa)(1)(a)
因此,它是大写字母、罗马数字、数字、字母、双字母、括号中的数字和括号中的字母。
有人能帮助我吗?
答案1
一个选项是使用titlesec
包定义两个新单元;alphalph
包用于为计数器提供双字母字符。
两个新单元分别是\myunit
和\mysubunit
,级别分别为 6 和 7;我还为新单元添加了书签支持。当然,您可以根据需要更改标题和最终目录条目的设置:
\documentclass{article}
\usepackage{alphalph}
\usepackage{titlesec}
\usepackage{hyperref}
% declaration of the class for the new units
\titleclass{\myunit}{straight}[\subparagraph]
\titleclass{\mysubunit}{straight}[\myunit]
% counters for the new units
\newcounter{myunit}
\newcounter{mysubunit}
% all units numbered and in ToC
\setcounter{secnumdepth}{7}
\setcounter{tocdepth}{7}
% modification of heading format for section, subsection, subsubsection
% to add the period after the counter
\titleformat{\section}
{\normalfont\Large\bfseries}
{\thesection.}
{1em}
{}
\titleformat{\subsection}
{\normalfont\large\bfseries}
{\thesubsection.}
{1em}
{}
\titleformat{\subsubsection}
{\normalfont\normalsize\bfseries}
{\thesubsubsection.}
{1em}
{}
% heading format for the new units
\titleformat{\myunit}[runin]
{\normalsize\bfseries}
{\themyunit}
{1em}
{}
\titleformat{\mysubunit}[runin]
{\normalsize\bfseries}
{\themysubunit}
{1em}
{}
% spacing for the headings of subparagraph and the new units
\titlespacing*{\subparagraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1em}
\titlespacing*{\myunit}
{0pt}{3.25ex plus 1ex minus .2ex}{1em}
\titlespacing*{\mysubunit}
{0pt}{3.25ex plus 1ex minus .2ex}{1em}
% redefinitions for the counter representation for all units
\renewcommand\thesection{\Alph{section}}
\renewcommand\thesubsection{\Roman{subsection}}
\renewcommand\thesubsubsection{\arabic{subsubsection}}
\renewcommand\theparagraph{\alph{paragraph})}
\renewcommand\thesubparagraph{\alphalph{\value{subparagraph}})}
\renewcommand\themyunit{(\arabic{myunit})}
\renewcommand\themysubunit{(\alph{subsubsection})}
\makeatletter
% bookmark support for new units
\def\toclevel@myunit{6}
\def\toclevel@mysubunit{7}
% ToC entries format
\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{1.5em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{3em}{1.5em}}
\renewcommand*\l@paragraph{\@dottedtocline{4}{4.5em}{1.5em}}
\renewcommand*\l@subparagraph{\@dottedtocline{5}{6em}{2em}}
\newcommand*\l@myunit{\@dottedtocline{5}{8em}{1.5em}}
\newcommand*\l@mysubunit{\@dottedtocline{5}{9.5em}{1.5em}}
\makeatother
\begin{document}
\tableofcontents
\section{Test section}
Test text
\subsection{Test subsection}
Test text
\subsubsection{Test subsubsection}
Test text
\paragraph{Test paragraph}
Test text
\setcounter{subparagraph}{26}
\subparagraph{Test subparagraph}
Test text
\myunit{Test new unit}
Test text
\mysubunit{Test new subunit}
Test text
\end{document}
显示 ToC 中的所有单元的输出图像:
显示书签面板的图像: