自定义子部分标签

自定义子部分标签

我目前正在使用命令

\renewcommand{\thesubsection}{\thesection.\alph{subsection}} 

要使我的文档章节和小节显示为:

1
1.a
1.b
2 ...

但是,对于我的文档的第四部分,我想要(合并子部分 ab 和 c):

4
4.abc
4.d

我该如何做到这一点,同时保持其他部分标签不变?谢谢您的帮助!

答案1

就像@Ivan 评论的那样:

\begingroup
\renewcommand{\thesubsection}{\thesection.a b c}
\subsection{Subsection}
\endgroup 
\addtocounter{subsection}{2}

将把b和添加c到小节中,下一小节是4.d

答案2

为了得到超出你想要的东西——记住,这样的多个小节可能需要在以后合并——让我们采取更一般宏用于整理尽可能多的子部分...使用包\foreach中定义的循环pgffor,并在这个帖子

\documentclass{scrartcl}
\usepackage{pgffor, amsmath}

\renewcommand{\thesubsection}{\thesection.\alph{subsection}}
\newcommand{\multisubsection}[2]{
                \subsection*{%
                   \thesection.%
                     \foreach \c in {1, ..., #1}%
                        {\addtocounter{subsection}{1}%
                         \alph{subsection}\,}\!. 
                             #2}}
\begin{document}

\section{The first section}
We have some questions answered in the following subsections.

\multisubsection{3}{A long answer, this should be}
When answering this question, we must consider the fact that
a complicated question expects a long and complicated, but clear answer.

\subsection{Answer to the second problem}
An easy answer, let's say.

\multisubsection{2}{Another, not-so-difficult problem}
Should have a moderately long answer, but as much to-the-point as possible.

\subsection{The next answer}
This should be evident from the above.

\end{document}

这应该会产生如下输出-- 多小节

相关内容