我的问题最好用下面给出的示例来表述。我尝试过topsep
,但这似乎会修改列表前后的空间。我只需要修改列表后面的空间。
\documentclass{article}
\usepackage{setspace, enumitem,titlesec}
\singlespacing
\titleformat{\section}{\normalfont\large\bfseries}{\thesection.}{.5em}{}
\titlespacing*{\section}{0pt}{3ex}{1ex}
\begin{document}
\section*{My first section}
This is the first paragraph of the first subsection in my first section.
This is the second paragraph.\\
\noindent Now this will be the first paragraph of the second subsection in my first section.
And this the second paragraph. You get the idea now.
\section*{My second section}
The first paragraph of the first subsection. This paragraph contains a list.
\begin{itemize}[noitemsep]
\item The first item
\item The second item
\end{itemize}
\noindent The first paragraph continues here. Or you might call it the second paragraph -- makes no difference to me.\\
\noindent This, however, is the second subsection. This will also contain a list. But this time the list will end the subsection.
\begin{itemize}[noitemsep]
\item The first item
\item The second item
\end{itemize}
\noindent This is the third subsection. How do I get the space between the list above and this subsection to be \emph{exactly} the same as between two subsections elsewhere in my letter? As it is now, the space it too small -- it looks like another paragraph rather than another subsection.
\end{document}
答案1
尝试此代码(需要calc
包)。无论如何,我不确定正确的长度是否是\baselineskip-\topsep
...
\documentclass{article}
\usepackage{setspace, enumitem,titlesec}
\usepackage{calc}
\singlespacing
\titleformat{\section}{\normalfont\large\bfseries}{\thesection.}{.5em}{}
\titlespacing*{\section}{0pt}{3ex}{1ex}
\newlength{\mylength}
\setlength{\mylength}{\baselineskip-\topsep}
\begin{document}
\section*{My first section}
This is the first paragraph of the first subsection in my first section.
This is the second paragraph.\
\noindent Now this will be the first paragraph of the second subsection in my first section.
And this the second paragraph. You get the idea now.
\section*{My second section}
The first paragraph of the first subsection. This paragraph contains a list.
\begin{itemize}[noitemsep]
\item The first item
\item The second item
\end{itemize}
The first paragraph continues here. Or you might call it the second paragraph -- makes no difference to me.\
\noindent This, however, is the second subsection. This will also contain a list. But this time the list will end the subsection.
\begin{itemize}[noitemsep,after*=\vspace{\mylength}]
\item The first item
\item The second item
\end{itemize}
This is the third subsection. How do I get the space between the list above and this subsection to be \emph{exactly} the same as between two subsections elsewhere in my letter? As it is now, the space it too small -- it looks like another paragraph rather than another subsection.
\end{document}
注意后者后面的间距itemize
。
我定义了一个新的长度mylenght
并将其设置为\baselineskip-\topsep
。然后,\begin{itemize}[noitemsep,after*=\vspace{\mylength}]
应该可以做你想做的事。
如果要为所有列表设置该值,可以after*=\vspace{\mylength}
从特定列表中删除并添加
\setlist{after*=\vspace{\mylength}}
进行全局设置。
答案2
除了使用 来引入子节\\
(在纯文本中这几乎总是错误的),您还可以使用内置命令之一,例如\bigbreak
。如果这对您来说还不够大,您可以定义自己的版本,如下所示(可能带有夸张的间距):
\documentclass{article}
\usepackage{setspace,enumitem,titlesec}
\singlespacing
\titleformat{\section}{\normalfont\large\bfseries}{\thesection.}{.5em}{}
\titlespacing*{\section}{0pt}{3ex}{1ex}
\newlength{\mysubsectionskip}
\setlength{\mysubsectionskip}{26pt plus 4pt minus 4pt}
\newcommand{\subsectionbreak}{\par\ifdim\lastskip<\mysubsectionskip
\removelastskip\penalty -200 \vspace{\mysubsectionskip} \fi}
\begin{document}
\section*{My first section}
This is the first paragraph of the first subsection in my first section.
This is the second paragraph.
\subsectionbreak
\noindent Now this will be the first paragraph of the second subsection in my first section.
And this the second paragraph. You get the idea now.
\section*{My second section}
The first paragraph of the first subsection. This paragraph contains a list.
\begin{itemize}[noitemsep]
\item The first item
\item The second item
\end{itemize}
\noindent The first paragraph continues here. Or you might call it the
second paragraph -- makes no difference to me.
\subsectionbreak
\noindent This, however, is the second subsection. This will also contain a list. But this time the list will end the subsection.
\begin{itemize}[noitemsep]
\item The first item
\item The second item
\end{itemize}
\subsectionbreak
\noindent This is the third subsection. How do I get the space between
the list above and this subsection to be \emph{exactly} the same as
between two subsections elsewhere in my letter? As it is now, the
space it too small -- it looks like another paragraph rather than
another subsection.
\end{document}
就像\bigbreak
这个\subsectionbreak
命令一样,它会查看最后添加的垂直空间,如果它小于,则\mysubsectionskip
用该值替换它。请注意,通常会在这些长度中留出一些灵活性。如果您希望它完全固定,则设置\mysubsectionskip
为26pt
。您还可以考虑在定义的\nointerlineskip
前面放置。这两个结合起来会使空间恰好。 \ifdim
\sectionbreak
26pt
当然,您可以使用\bigbreak
并重新定义\bigskipamount
为您想要使用的值,但您可能会发现该值在文档设计的其他地方被使用。
在以上所有内容中,26pt
被选为一个夸张的值; 12pt
将为您提供标准的基线跳过。
添加正如 daleif 指出的那样,您可以构建一个宏版本,自动确保以下段落不会缩进,如下所示:
\newlength{\mysubsectionskip}
\setlength{\mysubsectionskip}{26pt plus 4pt minus 4pt}
\makeatletter
\newcommand{\subsectionbreak}{\par\ifdim\lastskip<\mysubsectionskip
\removelastskip\penalty -200 \vspace{\mysubsectionskip} \fi
\@afterindentfalse\@afterheading}
\makeatother
这使用 LaTeX 的内部功能\@afterheading
来响应开关的设置\@afterindent
。由于这些名称包含,因此@
我们需要将代码括在一\makeatletter / \makeatother
对中。