跳到正文

LaTeX 图的位置:[h]、[t]、[H] 与浮动体

在普通文档中,无论你给出什么位置参数,Scissor LaTeX 都会把每个图和表保留在源代码中你书写的位置;只有会议版式会把浮动体移到页面的顶部或底部。

什么是浮动体

浮动体就是 figure 或 table 环境。在 TeX 发行版中,LaTeX 可能会把它从你书写的位置移走,移到页面的顶部或底部,或者单独放在一页上,好让各页排得均匀。\begin{figure} 后面方括号中的字母说明它可以放在哪里。

带标题的图浮动体

Some text before the figure.

\begin{figure}[ht]
  \centering
  \begin{tikzpicture}
    \draw[thick] (0,0) rectangle (3,1.5);
    \draw (0,0) -- (3,1.5);
  \end{tikzpicture}
  \caption{A rectangle with one diagonal.}
  \label{fig:rect}
\end{figure}

Figure~\ref{fig:rect} sits right where it was written.
由 Scissor LaTeX 排版: 带标题的图浮动体

Scissor LaTeX 中浮动体的位置

Scissor LaTeX 根据文档的版式,以两种方式处理浮动体。

文档位置参数的作用
article、report、book 及其他所有普通文档类不起作用。浮动体严格按源代码中的位置排版,上下留出少许间距。
会议版式(IEEEtran、acmart、llncs 以及 neurips_2026 或 cvpr 等模板宏包)第一个字母是 h 或 H 时保留在原位;只有 t 时移到页面或栏的顶部,只有 b 时移到底部;其他情况则放到顶部和底部中较近的一处。

在这两种情况下,! 都会被忽略,p(浮动体页)也一样。没有任何字母时,会议版式中的浮动体可能放到顶部,也可能放到底部。

下一个示例用 [b] 要求放在页面底部。在 article 中,图仍留在两个段落之间:

article 中的 [b]:图留在原位

The paragraph before the figure.

\begin{figure}[b]
  \centering
  \begin{tikzpicture}
    \fill[gray!30] (0,0) circle (0.6);
    \draw (0,0) circle (0.6);
  \end{tikzpicture}
  \caption{A circle that asked for the bottom.}
\end{figure}

The paragraph after the figure.
由 Scissor LaTeX 排版: article 中的 [b]:图留在原位

在会议版式中,同样的字母会移动浮动体。这里 [t] 把图送到第一栏的顶部,位于源代码中在它之前的文字上方。“问题”标签页会注明使用的是哪种会议版式。

IEEEtran 文档中的 [t]:图移到顶部

\documentclass[conference]{IEEEtran}
\begin{document}
\section{Introduction}
This paragraph comes first in the source. The figure below asks for the
top of the column, so the layout moves it above this text.

\begin{figure}[t]
  \centering
  \begin{tikzpicture}
    \draw[thick] (0,0) rectangle (3,1.2);
    \node at (1.5,0.6) {Erika Mustermann};
  \end{tikzpicture}
  \caption{A figure placed with [t].}
\end{figure}

This paragraph follows the figure in the source.
\end{document}
由 Scissor LaTeX 排版: IEEEtran 文档中的 [t]:图移到顶部

“问题”标签页: Layout in the style of the IEEE conference format (final mode). Not official. To compile elsewhere, add IEEEtran.cls from ctan.org/pkg/ieeetran.

标题和编号

\caption{...} 为浮动体编号,并在文字前输出“Figure 1:”或“Table 1:”。写在标题之后的 \label 让你可以用 \ref 引用这个编号(参见标签与交叉引用)。

有两个细节需要了解:

  • 类型由内容决定。 只包含 tabular 的 figure 会按表编号(“Table 1”),而包含图片或绘图的 table 会按图编号。如果你希望数据表显示为“Figure”,请把它和其他内容一起放进 figure,或者让它保持为表。
  • 标题位置是固定的。 无论你把 \caption 写在哪里,表的标题总是排在表的上方,图的标题总是排在图的下方。

只包含 tabular 的 figure 按表编号

\begin{figure}[h]
  \centering
  \caption{Points per round.}
  \begin{tabular}{lr}
    Erika & 44 \\
    John  & 38 \\
  \end{tabular}
\end{figure}

通栏浮动体和特殊浮动体

其他宏包中的几个环境会按普通浮动体读取:

环境宏包在 Scissor LaTeX 中
figure*, table*标准文档类按 figure 和 table 排版。在双栏 article 中它们留在一栏内;在双栏会议版式中它们横跨两栏。
wrapfigure, wraptablewrapfig按普通图排版;文字不会环绕它。宽度参数会被读取并丢弃。
sidewaysfigure, sidewaystablerotating按普通图排版,不旋转。
SCfiguresidecap按普通图排版,标题在下方。
marginfigure, margintabletufte 文档类按正文中的普通图排版。
subfigure, subtablesubcaption合并到外层的图中;参见图与图片。

wrapfigure 变成普通图

LaTeX导言区: \usepackage{wrapfig}在编辑器中打开 (在新标签页中打开)
\begin{wrapfigure}{r}{0.4\textwidth}
  \centering
  \begin{tikzpicture}
    \draw[->] (0,0) -- (1.5,0);
    \draw[->] (0,0) -- (0,1.2);
  \end{tikzpicture}
  \caption{Two axes.}
\end{wrapfigure}
In a TeX installation this text would flow around the figure on its right.
Here the figure takes its own line and the text continues below it.
由 Scissor LaTeX 排版: wrapfigure 变成普通图

让文档在两边都能正常工作

如果你的文档还必须能在 TeX 发行版中编译,请按通常的方式编写浮动体:大多数图用 [htbp] 或 [t],在内部写 \centering,并把 \caption 放在 \label 之前。Scissor LaTeX 会把它们保留在原位,TeX 发行版则照常让它们浮动。控制浮动的命令,例如 placeins 的 \FloatBarrier 或 \clearpage,都会被接受:\FloatBarrier 在这里不起作用,\clearpage 会另起一页。

与 TeX 发行版的区别

关于浮动体宏包的详情,请参阅 float、wrapfig 和 rotating。手册可在 CTAN 上找到:float、wrapfig 和 rotating。

常见问题

在 LaTeX 中如何强制图留在当前位置?

在 Scissor LaTeX 中不需要这样做:普通文档中的图总是留在你书写的位置。在 TeX 发行版中,请加载 float 宏包并写 \begin{figure}[H];这在这里同样可用。

为什么我的图出现在页面顶部?

这只会在会议版式中发生,它们会像 LaTeX 一样让图浮动。在那里把 [h] 写成第一个字母,图就会留在正文中。

为什么我的图被标为“Table 1”?

这个图只包含一个 tabular,所以按表编号。表格请使用 table 环境,图片和绘图请使用 figure。

本页的每个示例都在构建网站时由 Scissor LaTeX 排版。 最后更新:2026-11-07