我希望遵循用换行符标记段落分隔符的惯例,而不是 LaTex 默认的缩进。但是我不希望在节标题后有换行符。
以前的问题已经解决了如何在段落后添加换行符,例如: 段落之间有换行符,无缩进 和:https://stackoverflow.com/questions/2195908/latex-multiple-linebreaks
其他问题已经解决了如何删除标题后的换行符,例如 减少标题后的间距
但是当我结合这两种方法时,段落后的换行符会覆盖从标题下方删除换行符的命令。如何同时实现这两种效果?
为了显示:
\documentclass[11pt]{article}
\usepackage{titlesec}
\setlength{\parindent}{0pt}
\parskip = 12pt plus 6pt minus 4pt
%Settings for the headings
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\begin{document}
\section{This is a section}
Here is my first paragraph; it should appear directly below the section heading.
This is my second paragraph. there should be a line break before it and the one above.
\end{document}
答案1
手册手册第4页titlesec
,命令的描述\titlespacing
:
<after-sep>
是标题与正文之间的间隔——垂直方向为hang
、block
和display
,水平方向为runin
、drop
和wrap
。...margin
通过使该值为负数,您可以定义小于 的有效空间\parskip
。
所以就这么做吧:
\documentclass[11pt]{article}
\usepackage{titlesec}
\setlength{\parindent}{0pt}
\setlength{\parskip}{12pt plus 6pt minus 4pt}
%Settings for the headings
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{-\parskip}\relax
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{-\parskip}\relax
\begin{document}
\section{This is a section}
Here is my first paragraph;
it should appear directly below the section heading.
This is my second paragraph;
there should be a line break before it and the one above.
\subsection{This is a subsection}
The first paragraph in the subsection.
The second paragraph.
The third paragraph.
\end{document}
我获得的输出是: