![删除重复的空子节之间的间距](https://linux22.com/image/402016/%E5%88%A0%E9%99%A4%E9%87%8D%E5%A4%8D%E7%9A%84%E7%A9%BA%E5%AD%90%E8%8A%82%E4%B9%8B%E9%97%B4%E7%9A%84%E9%97%B4%E8%B7%9D.png)
我正在编写一份技术规范文档,每个部分都是规范的一部分。但在许多情况下,将规范的多个部分组合在一起并一起编写是有意义的。如下所示:
\subsubsection{Subsubsection A}
\subsubsection{Subsubsection B}
\subsubsection{Subsubsection C}
% This text concerns the subsubsections A, B and C
This is the subsubsection text.
\subsubsection{Subsubsection D}
% This text concerns the subsubsection D
This is the subsubsection text.
\subsubsection{Subsubsection F}
% This text concerns the subsubsection F
This is the subsubsection text.
我希望它的排版如下:
使用默认排版得到的结果是:
所以我希望将多个重复的空小节组合在一起,并且它们之间没有垂直空格。
答案1
只是为了好玩...
顺便说一句,1px 大约是 TeX 可以获得的最小值。0pt 会产生不同的结果。
\documentclass{article}
\makeatletter
\newenvironment{mygroup}{\par\vskip 3.25ex\@plus 1ex \@minus .2ex % normal skip at beginning
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{-1px}{1px}% for positive/negative tests
{\normalfont\normalsize\bfseries}}}%
{\vskip 1.5ex \@plus .2ex}% normal skip at end
\makeatother
\begin{document}
\section{Section A}
\subsection{Section A}
\begin{mygroup}
\subsubsection{Subsubsection A}
\subsubsection{Subsubsection B}
\subsubsection{Subsubsection C}
\end{mygroup}
This is the text.
\subsubsection{Subsubsection D}
This is the text.
\subsubsection{Subsubsection F}
This is the text.
\end{document}
答案2
找到了一个解决方案(使用\vspace
),它可以满足我的要求。
\documentclass{article}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{parskip}
\begin{document}
\section{Section A}
\subsection{Section A}
\subsubsection{Subsubsection A} \vspace{-1.0\parskip}
\subsubsection{Subsubsection B} \vspace{-1.0\parskip}
\subsubsection{Subsubsection C}
This is the text.
\subsubsection{Subsubsection D}
This is the text.
\subsubsection{Subsubsection F}
This is the text.
\end{document}