latex表格调整位置_Latex使用-控制表格或者图形的显示位置 | 学步园

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­sonsthat 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

Counter

Default

topnumber

max­i­mum num­ber of floats at top of page

2

bottomnumber

max­i­mum num­ber of floats at bot­tom of page

1

totalnumber

max­i­mum num­ber of floats on a page

3

Com­mand

\topfraction

max­i­mum frac­tion of page for floats at top

0.7

\bottomfraction

max­i­mum frac­tion of page for floats at bottom

0.3

\textfraction

min­i­mum frac­tion of page for text

0.2

\floatpagefraction

min­i­mum frac­tion of float­page that should have floats

0.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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值