您的位置:首页 > 其它

Latex使用-控制表格或者图形的显示位置

2012-11-14 00:05 435 查看
It can be frus­trat­ing try­ing to get your fig­ures and tables to appear where you want them in a LaTeX doc­u­ment. Some­times, they just seem to float off onto another page of their own accord. Here is a col­lec­tion of tools and ideas that help you get con­trol
of those pesky floats.

Use the place­ment options: h, t, b and p. For example

\begin{figure}[htb]

causes LaTeX to try to fit the float “here”, or at the “top” of the cur­rent page (or the next page), or at the “bot­tom” of the cur­rent page (or the next page). If “p” is spec­i­fied, it
will allow the float to take a whole page to itself. You can’t spec­ify only “h” as that is too restric­tive, and LaTeX will auto­mat­i­cally change it to “ht”. The default set­ting is “tbp”.

One of the rea­sons that the floats won’t go where you want them is that there are a lot of con­straints on where they can go. The main ones are
CounterDefault
topnumber
max­i­mum num­ber of floats at top of page2
bottomnumber
max­i­mum num­ber of floats at bot­tom of page1
totalnumber
max­i­mum num­ber of floats on a page3
Com­mand
\topfraction
max­i­mum frac­tion of page for floats at top0.7
\bottomfraction
max­i­mum frac­tion of page for floats at bottom0.3
\textfraction
min­i­mum frac­tion of page for text0.2
\floatpagefraction
min­i­mum frac­tion of float­page that should have floats0.5
These can all be changed indi­vid­u­ally. But it is often eas­ier to add ! before the place­ment options, thus forc­ing LaTeX to ignore most of these con­traints. For exam­ple, I often use

\begin{figure}[!htb]

If you want to change the defaults, the fol­low­ing val­ues give rea­son­able results:

\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}

The
\clearpage
com­mand starts a new page and inserts all floats that have not yet appeared before con­tin­u­ing. This can leave
a bad page break, so a use­ful alter­na­tive is to use the
afterpage
pack­age, and then insert

\afterpage{\clearpage}

which will put all the floats at the end of the cur­rent page.

A very use­ful pack­age is
placeins
. This pro­vides the com­mand
\FloatBarrier
which
causes all unprocessed floats to be processed at that point, but does not start a new page unless it is nec­es­sary. To keep floats in the sec­tions in which they were included, use

\usepackage[section]{placeins}

This silently puts a
\FloatBarrier
com­mand before each sec­tion. There are other options explained in the
placeins
documentation.

Another use­ful pack­age is
flafter
. This causes floats to always appear after their
place­ment in the document.

If you really don’t want LaTeX to move your float at all, then use the
float
pack­age with the com­mand
\restylefloat{figure}
in
the pre­am­ble. This allows you to spec­ify
[H]
as the posi­tion para­me­ter which means “Here and only Here”. How­ever, this
often gives bad page breaks.

点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐