views:

83

answers:

3

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?

+2  A: 

See here for the table placement. You could try "!h" to force the table to stay where you wan't.

Matti Pastell
Thanks! I ended up setting the table.placement above to "!h" and that solved the problem.
griffin
Glad that you got it working!
Matti Pastell
+2  A: 

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. For example:

\usepackage{float} 

...

<<echo=FALSE, results=tex>>=
print(xtable(x),table.placement="H")
@
nullglob
Thanks! That's very helpful! Although !h seemed to work better.
griffin
+1  A: 

I find \clearpage after a float is sometimes useful.

Jeromy Anglim