summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-floats.html
blob: 2883465ec024bdc6b43c1965bbea8dce2a726b72 (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&rsquo;ll fit without
violating the certain typographic rules.  Even if you use the
placement specifier <code>h</code> for &lsquo;here&rsquo;, the figure or table will not be
printed &lsquo;here&rsquo; 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&rsquo;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">&ldquo;Too many unprocessed floats&rdquo;</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 &ldquo;non-standard&rdquo; 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 &ldquo;<a href="FAQ-figurehere.html">non-floating floats</a>&rdquo;
<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&rsquo;t</em>
  omit the &lsquo;<code>p</code>&rsquo;: doing so could cause LaTeX to believe that if you
  can&rsquo;t have your figure <em>here</em>, you don&rsquo;t want it
  <em>anywhere</em>.  (LaTeX does try hard to avoid being confused in
  this way...)
<li> LaTeX&rsquo;s own float placement parameters could be preventing
  placements that seem entirely &ldquo;reasonable&rdquo; to you &mdash; they&rsquo;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&rsquo;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&ndash;200, section C.9 of the
  LaTeX manual.
<li> Are there places in your document where you could &lsquo;naturally&rsquo;
  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&rsquo;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&rsquo;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 &lsquo;simply&rsquo; 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&rsquo;t
  rely on LaTeX&rsquo;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://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/required/tools.zip">macros/latex/required/tools</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/required/tools/">browse the directory</a>)
<dt><tt><i>endfloat.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/endfloat.zip">macros/latex/contrib/endfloat</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/endfloat/">browse the directory</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://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>morefloats.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archivemacros/latex/contrib/misc/morefloats.sty">macros/latex/contrib/misc/morefloats.sty</a>
<dt><tt><i>placeins.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/placeins.zip">macros/latex/contrib/placeins</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk  tex-archive/macros/latex/contrib/placeins/">browse the directory</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>