当前位置:网站首页>Latex使用-控制表格或者图形的显示位置
Latex使用-控制表格或者图形的显示位置
2022-07-27 16:21:00 【bamboogz99】
It can be frustrating trying to get your figures and tables to appear where you want them in a LaTeX document. Sometimes, they just seem to float off onto another page of their own accord. Here is a collection of tools and ideas that help you get control of those pesky floats.
Use the placement 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 current page (or the next page), or at the “bottom” of the current page (or the next page). If “p” is specified, it will allow the float to take a whole page to itself. You can’t specify only “h” as that is too restrictive, and LaTeX will automatically change it to “ht”. The default setting is “tbp”.
One of the reasons that the floats won’t go where you want them is that there are a lot of constraints on where they can go. The main ones are
| Counter | Default | |
topnumber | maximum number of floats at top of page | 2 |
bottomnumber | maximum number of floats at bottom of page | 1 |
totalnumber | maximum number of floats on a page | 3 |
| Command | ||
\topfraction | maximum fraction of page for floats at top | 0.7 |
\bottomfraction | maximum fraction of page for floats at bottom | 0.3 |
\textfraction | minimum fraction of page for text | 0.2 |
\floatpagefraction | minimum fraction of floatpage that should have floats | 0.5 |
These can all be changed individually. But it is often easier to add ! before the placement options, thus forcing LaTeX to ignore most of these contraints. For example, I often use
\begin{ figure}[!htb] |
If you want to change the defaults, the following values give reasonable 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 command starts a new page and inserts all floats that have not yet appeared before continuing. This can leave a bad page break, so a useful alternative is to use the afterpage package, and then insert
\afterpage{ \clearpage} |
which will put all the floats at the end of the current page.
A very useful package is placeins. This provides the command \FloatBarrier which causes all unprocessed floats to be processed at that point, but does not start a new page unless it is necessary. To keep floats in the sections in which they were included, use
\usepackage[section]{ placeins} |
This silently puts a \FloatBarrier command before each section. There are other options explained in the placeins documentation.
Another useful package is flafter. This causes floats to always appear after their placement in the document.
If you really don’t want LaTeX to move your float at all, then use the float package with the command \restylefloat{figure} in the preamble. This allows you to specify[H] as the position parameter which means “Here and only Here”. However, this often gives bad page breaks.
边栏推荐
- Day 3 of leetcode question brushing
- PyGame aircraft war game background implementation
- WinForm remove the close button in the upper right corner
- Nodejs 模板引擎ejs
- npm、cnpm 淘宝镜像
- 家用静音驱蚊灯芯片-DLTAP703SD-杰力科创
- JS to realize simple form verification and select all functions
- 内网的公司邮箱服务器怎么发外部邮件
- Openstack login dashboard prompt authentication error
- Typeerror: conv2d(): argument 'padding' (position 5) must be multiple of ints, not STR [error]
猜你喜欢
随机推荐
JDBC MySQL 02 data access and Dao mode
迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
MongoDB
Overview of Baidu map technology, and application development of basic API and webapi
全自动吸奶器芯片-DLTAP703SD
多功能无线遥控艾灸仪芯片-DLTAP703SD
JS to achieve smooth scrolling of pages or DOM elements
ERROR 1366 (HY000): Incorrect string value: ‘\xE8\xB5\xB5\xE9\x9B\xB7‘ for column ‘s_ name‘ at row 1
Arrays and objects in JS
TypeScript安装
Electric heating neck pillow chip-dltap703sc
飞机大战英雄出场加子弹实现
JS中的数组与对象
WPS turns off annoying advertisements
USB rechargeable hand warmer chip dltap602sc Jericho
【微信小程序】项目实战—抽签应用
js中的函数与DOM获取元素和事件属性的使用
Order submission
ES6数值的扩展
家用静音驱蚊灯芯片-DLTAP703SD-杰力科创









