在浮体之前和之后插入段有什么区别?

在浮体之前和之后插入段有什么区别?

一般情况下,两个段落之间会插入一个浮动体,我们会在\par浮动体的上方和下方插入,但是\par可以进行分割。我发现如果只\par在浮动体前面插入 ,排版效果很好,但是如果只在\par浮动体后面插入 ,排版效果不好,而且两个段落之间会产生多余的垂直间距。在浮动体的上方和下方插入 进行分割有什么区别\par,为什么会产生不同的排版效果。

这样,两个段之间就会产生额外的垂直距离。

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
\begin{figure}
\centering
\input{1.pgf}
\caption{fig1}
\label{fig1}
\end{figure}
\par
This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.

这样两段之间的距离就正常了。

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
\par
\begin{figure}
\centering
\input{2.pgf}
\caption{fig2}
\label{fig2}
\end{figure}
This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.

由于示例代码太短,以上两个示例代码可能无法复现。

答案1

您显示的两种形式的段落间距应该是相同的,请参见此示例,\par其中第一个图之前和第二个图之后有一个空行()。

但请注意,空间是可拉伸的,因此不同页面的段落之间可能会有不同的空间。

在此处输入图片描述

\documentclass{article}

\usepackage{parskip}

\begin{document}

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.

\begin{figure}
\centering
\rule{2cm}{3cm}
\caption{fig1}
\label{fig1}
\end{figure}
This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
\begin{figure}
\centering
\rule{2cm}{3cm}
\caption{fig2}
\label{fig2}
\end{figure}

This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.
\end{document}

但是,如果浮动之前的最后一行是全长的,并且没有在浮动之前放置段落结尾,则需要注意最后的空格是否会单独结束在一行上:

在此处输入图片描述

\documentclass{article}

\usepackage{parskip}

\begin{document}

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
This is the first paragraph. This is the first...

\begin{figure}
\centering
\rule{2cm}{3cm}
\caption{fig1}
\label{fig1}
\end{figure}
This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
This is the first paragraph. This is the first...
\begin{figure}
\centering
\rule{2cm}{3cm}
\caption{fig2}
\label{fig2}
\end{figure}

This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.
\end{document}

可以通过在图前添加段落结尾或注释掉行尾来避免此处在图 2 周围产生的空格,我在%这里用 a 来展示:

\documentclass{article}

\usepackage{parskip}

\begin{document}

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
This is the first paragraph. This is the first...

\begin{figure}
\centering
\rule{2cm}{3cm}
\caption{fig1}
\label{fig1}
\end{figure}
This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.

This is the first paragraph. This is the first paragraph. This is the first paragraph. This is the first paragraph.
This is the first paragraph. This is the first...%
\begin{figure}
\centering
\rule{2cm}{3cm}
\caption{fig2}
\label{fig2}
\end{figure}

This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph.
\end{document}

相关内容