summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-figurehere.html
blob: 6b2393bbe92241b0cbc5aec963c4ce3fde4c35cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<head>
<title>UK TeX FAQ -- question label figurehere</title>
</head><body>
<h3>Figure (or table) <em>exactly</em> where I want it</h3>
<p/>This is of course a contradiction: <code>figure</code> and
<code>table</code> are <em>designed</em> to float, and will always have
the potential to appear away from where you asked for them.  Therefore
you have to find a means of getting the caption and other effects
without allowing the figure or table to float.
<p/>The most straightforward way is to use the <i>float</i> package; it
gives you a <code>[H]</code> float placement option that prevents
floating:
<blockquote>
<pre>
\begin{figure}[H]
  \centering
  \includegraphics{foo}
  \caption{caption text}
  \label{fig:nonfloat}
\end{figure}
</pre>
</blockquote><p>
As the example shows, these <code>[H]</code> figures (and correspondingly,
tables) offer all you need to cross-reference as well as typeset.
<p/>However, you don&rsquo;t actually <em>have</em> to use <i>float</i> since
it is, in fact, doing rather little for you.  You can place your
figure as you please, with a sequence like
<blockquote>
<pre>
\begin{center}
  \includegraphics{foo}
  \captionof{figure}{caption text}
  \label{fig:nonfloat}
\end{center}
</pre>
</blockquote><p>
which relies on the <code>\</code><code>captionof</code> command to place a caption in
ordinary running text.  That command may be had from the extremely
simple-minded package <i>capt-of</i> or from the highly
sophisticated <i>caption</i> package.
<p/>Using either method, you have to deal with the possibility of the
figure or table being too large for the page.  (Floating objects will
float away in this circumstance; &ldquo;doing it by hand&rdquo;, like this, you
take upon yourself the responsibility for avoiding 
&lsquo;<i>Overfull <code>\</code><code>vbox</code></i>&rsquo; errors.
<p/>A further problem is the possibility that such &ldquo;fixed floats&rdquo; will
overtake &ldquo;real floats&rdquo;, so that the numbers of figures will be out
of order: figure 6 could be on page 12, while figure 5 had floated to
page 13.  It&rsquo;s best, therefore, either to stay with floating figures
throughout a document, or to use fixed figures throughout.
<p/>If it&rsquo;s really impossible to follow that counsel of perfection, you
can use the <i>perpage</i> package&rsquo;s command <code>\</code><code>MakeSorted</code>
command:
<blockquote>
<pre>
...
\usepackage{float}
\usepackage{perpage}
\MakeSorted{figure}
\MakeSorted{table}
...
</pre>
</blockquote><p>
and the sequence of float numbers is all correct.
<dl>
<dt><tt><i>capt-of.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archivemacros/latex/contrib/misc/capt-of.sty">macros/latex/contrib/misc/capt-of.sty</a>
<dt><tt><i>caption.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/caption.zip">macros/latex/contrib/caption</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/caption/">browse the directory</a>)
<dt><tt><i>float.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/float.zip">macros/latex/contrib/float</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/float/">browse the directory</a>)
<dt><tt><i>perpage.sty</i></tt><dd>Distributed as part <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/bigfoot.zip">macros/latex/contrib/bigfoot</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/bigfoot/">browse the directory</a>)
</dl>
<p/><p/><p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=figurehere">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=figurehere</a>
</body>