简体   繁体   English

在 LaTeX 中浮动图像后如何清除?

[英]How to clear after floating images in LaTeX?

I'm trying to text-wrap floating images in LaTeX, using code like the following:我正在尝试使用如下代码在 LaTeX 中对浮动图像进行文本换行:

\begin{wrapfigure}{R}{0.5\textwidth}
\begin{center}
\includegraphics{images/image.png}
\caption{This is the caption.}
}
\label{fig:image1}
\end{center}
\end{wrapfigure

This works fine most of the time (creating an image that floats on the right-hand side), but sometimes LaTeX does not properly clear after the image, and it leaves an open column for another page or two.这在大多数情况下都可以正常工作(创建一个浮动在右侧的图像),但有时 LaTeX 在图像后无法正确清除,并且会为另一或两页留下一个空列。 How does one remedy this, or ideally, does LaTeX have a function similar to clear: both in CSS?如何解决这个问题,或者理想情况下,LaTeX 是否具有类似于clear: both的功能clear: both在 CSS 中?

There is the \\clearpage command, but it's not appropriate when there's no natural place to break to a new page near the image.\\clearpage命令,但是当在图像附近没有自然的地方可以中断到新页面时,它是不合适的。

You might try to manually set the height of the figure using the optional argument of wrapfigure您可以尝试使用 wrapfigure 的可选参数手动设置图形的高度

\begin{wrapfigure}[lineheight]{alignment}{width}

where lineheight is the number of text lines which shall wrap around the image.其中 lineheight 是环绕图像的文本行数。

I still don't have a good answer to this question, but the solution for now is to not use wrapfigure at all.对于这个问题,我仍然没有很好的答案,但现在的解决方案是根本不使用wrapfigure Using only figure solves the problem of open columns, but it's not the most ideal solution.仅使用figure解决了开列的问题,但这不是最理想的解决方案。 Any other answers are still welcome, but I'll post my half-way solution here for those who might also need it:仍然欢迎任何其他答案,但我会在此处为那些可能也需要它的人发布我的中途解决方案:

\begin{figure}
\begin{center}
\includegraphics{images/image.png}
\caption{This is the caption.}
\end{center}
\label{fig:image1}
\end{figure}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM