如何迫使两个数字停留在同一页在 LaTeX?

我有两个图像,我想显示在一个网页上的数字。每一个都占用了不到一半的可用空间,所以页面上没有多少空间放其他东西,但我知道有足够的空间放这两个图形。我试着用[ ht ]和[ hb ] ,都[ h ]和都[ ht ]放置图片,但仍然无法将这两个图片放在同一个页面上,而是至少要在它们之间放几个段落。

我怎样才能让这两个数字保持一致呢?

177319 次浏览

Try adding a !, e.g. [h!].

try [h!] first but else you can do it the ugly way.

LateX is a bit hard in placing images with such constraints as it manages placing itself. What I usually do if I want a figure right in that spot is do something like|:

text in front of image here


\newpage
\figure1
\figure2


text after images here

I know it may not be the correct way to do it but it works like a charm :).

//edit

You can do the same if you want a little text at top of the page but then just use /clearpage. Of course you can also scale them a bit smaller so it does not happen anymore. Maybe the non-seen whitespace is a bit larger than you suspect, I always try to scale down my image until they do appear on the same page, just to know for sure there is not like 1% overlap only making all of this not needed.

If you want them both on the same page and they'll both take up basically the whole page, then the best idea is to tell LaTeX to put them both on a page of their own!

\begin{figure}[p]

It would probably be against sound typographic principles (e.g., ugly) to have two figures on a page with only a few lines of text above or below them.


By the way, the reason that [!h] works is because it's telling LaTeX to override its usual restrictions on how much space should be devoted to floats on a page with text. As implied above, there's a reason the restrictions are there. Which isn't to say they can be loosened somewhat; see the FAQ on doing that.

You can put two figures inside one figure environment. For example:

\begin{figure}[p]
\centering
\includegraphics{fig1}
\caption{Caption 1}
\includegraphics{fig2}
\caption{Caption 2}
\end{figure}

Each caption will generate a separate figure number.

If you want to have images about same topic, you ca use subfigure package and construction:

\begin{figure}
\subfigure[first image]{\includegraphics{image}\label{first}}
\subfigure[second image]{\includegraphics{image}\label{second}}
\caption{main caption}\label{main_label}
\end{figure}

If you want to have, for example two, different images next to each other you can use:

\begin{figure}
\begin{minipage}{.5\textwidth}
\includegraphics{image}
\caption{first}
\end{minipage}
\begin{minipage}{.5\textwidth}
\includegraphics{image}
\caption{second}
\end{minipage}
\end{figure}

For images in columns you will have [1] [2] [3] [4] in the source, but it will look like

[1] [3]

[2] [4].

I had this problem while trying to mix figures and text. What worked for me was the 'H' option without the '!' option. \begin{figure}[H]
'H' tries to forces the figure to be exactly where you put it in the code. This requires you include \usepackage{float}

The options are explained here

Try using the float package and then the [H] option for your figure.

\usepackage{float}


...


\begin{figure}[H]
\centering
\includegraphics{fig1}
\caption{Write some caption here}\label{fig1}
\end{figure}

as already suggested by this insightful answer!

https://tex.stackexchange.com/questions/8625/force-figure-placement-in-text

Sometimes we want to put only one caption for two or three related images, and then again, we have two or three associated charts with one caption (for some journals, this style is necessary. In this case, subfloat or other similar environments does not help since they only allow one caption per subfloat, not a cation for all subfloats like the following:

|------|   |------|   |------|
|image1|   |image2|   |image3|
|______|   |______|   |______|
Figure 1. cation for all of the
subfloats


|------|   |------|   |------|
|image1|   |image2|   |image3|
|______|   |______|   |______|
Figure 2. cation for all of the
subfloats


content of the article,    content of the article
content of the article    content of the article

To produce such a style, I used the following snippet:

\begin{figure}[t]
\subfloat[]{}
\subfloat[]{}
\subfloat[]{}
\end{figure}
\begin{figure}[t!]
\subfloat[]{}
\subfloat[]{}
\subfloat[]{}
\end{figure}
\begin{figure}[t!]
\subfloat[]{}
\subfloat[]{}
\subfloat[]{}
\end{figure}