summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-floats.html
blob: 8def4b57e1f21ca7538ce52ad6b921fb9c132419 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<head>
<title>UK TeX FAQ -- question label floats</title>
</head><body>
<h3>Moving tables and figures in LaTeX</h3>
<p/>Tables and figures have a tendency to surprise, by <em>floating</em>
away from where they were specified to appear.  This is in fact
perfectly ordinary document design; any professional typesetting
package will float figures and tables to where they&#8217;ll fit without
violating the certain typographic rules.  Even if you use the
placement specifier <code>h</code> for &#8216;here&#8217;, the figure or table will not be
printed &#8216;here&#8217; if doing so would break the rules; the rules themselves
are pretty simple, and are given on page 198, section C.9 of the
LaTeX manual.  In the worst case, LaTeX&#8217;s rules can cause the
floating items to pile up to the extent that you get an error message
saying <a href="FAQ-tmupfl.html">&#8220;Too many unprocessed floats&#8221;</a>.
What follows is a simple checklist of things to do to solve these
problems (the checklist talks throughout about figures, but applies
equally well to tables, or to &#8220;non-standard&#8221; floats defined by the
<i>float</i> or other packages).
<ul>
<li> Do your figures need to float at all?  If not, look at the
  recommendations for &#8220;<a href="FAQ-figurehere.html">non-floating floats</a>&#8221;
<li> Are the placement parameters on your figures right?  The
  default (<code>tbp</code>) is reasonable, but you can reasonably change it (for
  example, to add an <code>h</code>).  Whatever you do, <em>don&#8217;t</em>
  omit the &#8216;<code>p</code>&#8217;: doing so could cause LaTeX to believe that if you
  can&#8217;t have your figure <em>here</em>, you don&#8217;t want it
  <em>anywhere</em>.  (LaTeX does try hard to avoid being confused in
  this way&#8230;)
<li> LaTeX&#8217;s own float placement parameters could be preventing
  placements that seem entirely &#8220;reasonable&#8221; to you &#8212; they&#8217;re
  notoriously rather conservative.  To encourage LaTeX not to move
  your figure, you need to loosen its demands.  (The most important
  ones are the ratio of text to float on a given page, but it&#8217;s
  sensible to have a fixed set that changes the whole lot, to meet
  every eventuality.)
<pre>
\renewcommand{\topfraction}{.85}
\renewcommand{\bottomfraction}{.7}
\renewcommand{\textfraction}{.15}
\renewcommand{\floatpagefraction}{.66}
\renewcommand{\dbltopfraction}{.66}
\renewcommand{\dblfloatpagefraction}{.66}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
</pre>
  The meanings of these
  parameters are described on pages 199&#8211;200, section C.9 of the
  LaTeX manual.
<li> Are there places in your document where you could &#8216;naturally&#8217;
  put a <code>\</code><code>clearpage</code> command?  If so, do: the backlog of floats is
  cleared after a <code>\</code><code>clearpage</code>.  (Note that the <code>\</code><code>chapter</code>
  command in the standard <i>book</i> and <i>report</i> classes
  implicitly executes <code>\</code><code>clearpage</code>, so you can&#8217;t float past
  the end of a chapter.)
<li> Try the <i>placeins</i> package: it defines a
  <code>\</code><code>FloatBarrier</code> command beyond which floats may not pass.  A
  package option allows you to declare that floats may not pass a
  <code>\</code><code>section</code> command, but you can place <code>\</code><code>FloatBarrier</code>s wherever
  you choose.
<li> If you are bothered by floats appearing at the top of the page
  (before they are specified in your text), try the <i>flafter</i>
  package, which avoids this problem by insisting that floats should
  always appear after their definition.
<li> Have a look at the LaTeX2e <i>afterpage</i> package.
  Its documentation gives as an example the idea
  of putting <code>\</code><code>clearpage</code> <em>after</em> the current page (where it
  will clear the backlog, but not cause an ugly gap in your text), but
  also admits that the package is somewhat fragile.  Use it as a last
  resort if the other possibilities below don&#8217;t help.
<li> If you would actually <em>like</em> great blocks of floats at the
  end of each of your chapters, try the <i>morefloats</i> package;
  this &#8216;simply&#8217; increases the number of floating inserts that LaTeX
  can handle at one time (from 18 to 36).
<li> If you actually <em>wanted</em> all your figures to float to the
  end (<em>e.g</em>., for submitting a draft copy of a paper), don&#8217;t
  rely on LaTeX&#8217;s mechanism: get the <i>endfloat</i> package to do
  the job for you.
</ul>
<dl>
<dt><tt><i>afterpage.sty</i></tt><dd>Distributed as part of <a href="http://mirror.ctan.org/macros/latex/required/tools.zip">macros/latex/required/tools</a> (or <a href="http://mirror.ctan.org/macros/latex/required/tools/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/afterpage.html">catalogue entry</a>
<dt><tt><i>endfloat.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/endfloat.zip">macros/latex/contrib/endfloat</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/endfloat/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/endfloat.html">catalogue entry</a>
<dt><tt><i>flafter.sty</i></tt><dd>Part of the LaTeX distribution
<dt><tt><i>float.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/float.zip">macros/latex/contrib/float</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/float/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/float.html">catalogue entry</a>
<dt><tt><i>morefloats.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/misc/morefloats.sty">macros/latex/contrib/misc/morefloats.sty</a>; <a href="http://mirror.ctan.org//help/Catalogue/entries/morefloats.html">catalogue entry</a>
<dt><tt><i>placeins.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/placeins.zip">macros/latex/contrib/placeins</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/placeins/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/placeins.html">catalogue entry</a>
</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats</a>
</body>