当前位置:网站首页>Latex use - control the display position of tables or graphics
Latex use - control the display position of tables or graphics
2022-07-27 19:05: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.
边栏推荐
猜你喜欢

"Testing novice encyclopedia" 5-minute quick start pytest automated testing framework

CMD 命令

LeetCode 刷题 第三天

Music rhythm colorful gradient lamp chip -- dlt8s04a- Jericho

IDEA成功连接Database但不显示表怎么办

Docker - docker installation, MySQL installation on docker, and project deployment on docker

How to break the team with automated testing

Blog Garden beautification tutorial

Self control principle learning notes - system stability analysis (1) - BIBO stability and Routh criterion

连续时间系统的性能分析(2)-二阶系统性能改善方式PID,PR
随机推荐
Hash、Set、List、Zset、BitMap、Scan
C # interaction with MySQL database - MySQL configuration and addition, deletion, query and modification operations
Greedy method, matroid and submodular function (refer)
WinForm screenshot save C code
"Testing novice encyclopedia" 5-minute quick start pytest automated testing framework
PHP字符串操作
WSN Journal indexed by SCI(转)
Unity显示Kinect捕获的镜头
Latex使用--subfigure竖排图形
I'm afraid I won't use the JMeter interface testing tool if I accept this practical case
USB rechargeable hand warmer chip dltap602sc Jericho
ref 关键字的用法
normal distribution, lognormal distribution,正态随机数的生成
Redis annotation
Whole body multifunctional massage instrument chip-dltap602sd
Unity learning notes - six common functions of object movement
Blog Garden beautification tutorial
Electric heating neck pillow chip-dltap703sc
webservice的疑问
Runtimeerror: output with shape [1, 256, 256] doesn't match the broadcast shape [3, 256, 256] [error]