有没有办法让 LaTeX 将图形放置在同一页面中作为对该图形的引用?

发布于 2024-07-12 09:48:18 字数 333 浏览 13 评论 0原文

我正在使用 LaTeX 和图形环境。

我非常熟悉该环境的参数:[htbp],而且我通常也熟悉 LaTeX 默认情况下决定将每个图形放在哪里的策略。 例如,将图形放置在页面的顶部或底部。

我想知道是否有一个包、宏或一些我可以提供的命令,这样如果我有一个单列文档并且我主要有一个对图的文本内引用,那么该图会更多可能会被放置在参考文献的同一页中吗?

例如,假设我有一个很长的段落,中间有一个 \ref{FIG:X}。 渲染时,有些段落出现在分页符之前,有些则出现在分页符之后。 我还可以将图形命令放置在整个段落之前和之后的某个位置。 有没有办法让它实际放置在与实际参考相同的页面中?

I am using LaTeX and the figure environment.

I am well familiar with the parameters to that environment: [htbp], and I am also generally familiar with the strategies that LaTeX takes, by default, to decide where to put each figure. For example, by placing figures at the top or bottom of the page.

What I am wondering is whether there is a package, macro, or some commands that I can give so that if I have a single-column document and I mostly have a single in-text reference to a figure, that the figure would be more likely to be placed in the same page of the reference?

For example, imagine that I have a long paragraph which in the middle has a \ref{FIG:X}. When rendered, some of the paragraph appears before the page break, and some appears after the page break. I can also place the figure command somewhere before and after the whole paragraph. Is there a way to get it to actually be placed in the same page as the actual reference?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

面犯桃花 2024-07-19 09:48:18

我不想听起来消极,但有时候,如果没有大量“人为”的分页符调整,您想要的几乎是不可能的。

如果标注自然落在页面底部附近,并且图形落在下一页上,则将图形向后移动一页可能会使标注向前移动。

我建议(尽可能,并取决于数字的确切大小):

  • 将数字放置在 [t](或 [h],如果必须的话)
  • 将数字尽可能靠近“正确”的位置( [t] 和 [h] 有所不同)
  • 用 \input 包含来自单独文件的数字,这将使它们在进行最终调整时更容易移动

根据我的经验,这是一个很大的非- 可用时间 (:-)


在回复 Jon 的评论时,我认为这本质上是一个困难的问题,因为 LaTeX 的人并不懒惰。 您可能想阅读Frank Mittelbach 的论文

I don't want to sound too negative, but there are occasions when what you want is almost impossible without a lot of "artificial" tuning of page breaks.

If the callout falls naturally near the bottom of a page, and the figure falls on the following page, moving the figure back one page will probably displace the callout forward.

I would recommend (as far as possible, and depending on the exact size of the figures):

  • Place the figures with [t] (or [h] if you must)
  • Place the figures as near as possible to the "right" place (differs for [t] and [h])
  • Include the figures from separate files with \input, which will make them much easier to move around when you're doing the final tuning

In my experience, this is a big eater-up of non-available time (:-)


In reply to Jon's comment, I think this is an inherently difficult problem, because the LaTeX guys are no slouches. You may like to read Frank Mittelbach's paper.

淡写薰衣草的香 2024-07-19 09:48:18

是的,将 float 包包含到文档顶部,并将 H(大写 H)作为数字说明符:

\usepackage{float}

\begin{figure}[H]
.
.
.
\end{figure}

Yes, include float package into the top of your document and H (capital H) as a figure specifier:

\usepackage{float}

\begin{figure}[H]
.
.
.
\end{figure}
一抹淡然 2024-07-19 09:48:18

您可以随时添加“!” 进入你的浮动选项。 这样,Latex 会尽力将图形放置在您想要的位置(我主要使用 [h!tb]),从而扩展了排版的正常规则。

我找到了另一个解决方案:
使用 float 包。 这样您就可以将图形放置在想要的位置。

You can always add the "!" into your float-options. This way, latex tries really hard to place the figure where you want it (I mostly use [h!tb]), stretching the normal rules of type-setting.

I have found another solution:
Use the float-package. This way you can place the figures where you want them to be.

紅太極 2024-07-19 09:48:18

我通过始终在浮点数(例如数字)上使用 [h] 选项来解决这个问题,以便它们(大部分)到达我放置它们的位置。 然后,当我查看最终草案时,我通过在 LaTeX 源中移动浮动来调整浮动的位置。 通常这意味着将其移动到引用它的段落中。 有时我需要在适当的位置添加分页符。

我发现 LaTeX 中浮动的默认位置是合理的,但几乎总是需要手动调整才能使这样的事情恰到好处。 (有时,当有大量浮动和脚注时,不可能一切都完美。)

memoir 类的手册 有一些关于 LaTeX 如何放置浮动的有用信息以及一些操作算法的建议。

I solve this problem by always using the [h] option on floats (such as figures) so that they (mostly) go where I place them. Then when I look at the final draft, I adjust the location of the float by moving it in the LaTeX source. Usually that means moving it around the paragraph where it is referenced. Sometimes I need to add a page break at an appropriate spot.

I've found that the default placement of floats is reasonable in LaTeX, but manual adjustments are almost always needed to get things like this just right. (And sometimes it isn't possible for everything to be perfect when there are lots of floats and footnotes.)

The manual for the memoir class has some good information about how LaTeX places floats and some advice for manipulating the algorithm.

摘星┃星的人 2024-07-19 09:48:18

如果您想在所有人物上强制执行此行为,请尝试

...
\usepackage{float}
\floatplacement{figure}{H}
...

If you want force this behaviour on all of your figures try

...
\usepackage{float}
\floatplacement{figure}{H}
...
聊慰 2024-07-19 09:48:18

也许这会对你有帮助?

\begin{center}
\includegraphics[scale=0.5]{picture_name}
\end{center}    

我认为当你的图形跑掉时最好使用图形命令。

Maybe this will help you?

\begin{center}
\includegraphics[scale=0.5]{picture_name}
\end{center}    

I think is better to use the graphics command when your figures run away.

野生奥特曼 2024-07-19 09:48:18

我有一些有用的意见。 因为我在人物位置上也遇到了类似的问题。
我使用了“wrapfig”包,它允许用文本包裹图形。

...
\usepackage{wrapfig}
\usepackage{graphicx}
...
\begin{wrapfigure}{r}{53pt}
\includegraphics[width=53pt]{cone.pdf}
\end{wrapfigure}

In options {r} 之类的意思是从右侧放置数字。 {l} 可用于左侧。

I have some useful comments. Because I had similar problem with location of figures.
I used package "wrapfig" that allows to make figures wrapped by text.
Something like

...
\usepackage{wrapfig}
\usepackage{graphicx}
...
\begin{wrapfigure}{r}{53pt}
\includegraphics[width=53pt]{cone.pdf}
\end{wrapfigure}

In options {r} means to put figure from right side. {l} can be use for left side.

鲜肉鲜肉永远不皱 2024-07-19 09:48:18
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.7}

http://robjhyndman.com/researchtips/latex-floats/

\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.7}

http://robjhyndman.com/researchtips/latex-floats/

叫嚣ゝ 2024-07-19 09:48:18

我发现有助于解决此问题的一种方法是使用 \include{file_with_tex_figure_commands}

不是输入)

One way I found that helps with this is to use \include{file_with_tex_figure_commands}

(not input)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文