简体   繁体   English

Sweave xtable:如何在文本之间定位表?

[英]Sweave xtable: how to position tables between text?

I have a number of tables with text around them describing them. 我有很多表格,周围有文字描述它们。 Something like this: 像这样的东西:

This table shows blah blah...

<<echo=FALSE, results=tex>>=
print(
    xtable(x,
        caption = "blah", label = "tab:four", table.placement = "tbp", caption.placement = "top")
  , size = "small", table.placement="ht")
@

This table shows blah blah...

<<echo=FALSE, results=tex>>=
print(
    xtable(x,
        caption = "blah", label = "tab:five", table.placement = "tbp", caption.placement = "top")
  , size = "small", table.placement="ht")
@

I want all my descriptive text to be in line with the tables so that they follow in the sequence that I am writing them. 我希望我的所有描述性文本都与表格一致,以便它们遵循我正在编写它们的顺序。 But around the end of a page, some tables move off onto the next page and the descriptive text is just free floating. 但是在页面末尾,一些表格移到下一页,描述性文本只是自由浮动。 Is there some particular table.placement command that will ensure that everything stays the way that it is written? 是否有一些特定的table.placement命令可以确保所有内容都保持写入的方式?

The latex float package provides the float specifier H , which allows you to force tables and figures to be precisely in the location they occur in the latex code. latex float包提供了浮点说明符H ,它允许您强制表和数字精确地位于它们在乳胶代码中出现的位置。 For example: 例如:

\usepackage{float} 

...

<<echo=FALSE, results=tex>>=
print(xtable(x),table.placement="H")
@

See here for the table placement. 请参阅此处了解表格位置。 You could try "!h" to force the table to stay where you wan't. 你可以尝试“!h”迫使桌子停留在你想要的地方。

我发现浮点数有时是有用的\\clearpage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM