Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for specialized environments before and after LaTeX table code #157

Open
rich-iannone opened this issue Jan 31, 2019 · 3 comments · May be fixed by #1588
Open

Add options for specialized environments before and after LaTeX table code #157

rich-iannone opened this issue Jan 31, 2019 · 3 comments · May be fixed by #1588

Comments

@rich-iannone
Copy link
Member

This new issue is based on a comment from @kuriwaki from the closed issue #114.

xtable::print.xtable has an argument floating that either generates .tex with a float environment with captions \begin{table}... (the default), or without the floating environment and starts directly with \begin{tabular} (if set to FALSE). Both options would be great to have with the file export argument.

library(xtable)
library(ggplot2)

tab <- xtabs(~ cyl + drv, data = mpg)
xtbl <- xtable(tab)

print.xtable(xtbl, floating = TRUE)
#> % latex table generated in R 3.5.1 by xtable 1.8-3 package
#> % Sun Jan 13 15:28:24 2019
#> \begin{table}[ht]
#> \centering
#> \begin{tabular}{rrrr}
#>   \hline
#>  & 4 & f & r \\ 
#>   \hline
#> 4 &  23 &  58 &   0 \\ 
#>   5 &   0 &   4 &   0 \\ 
#>   6 &  32 &  43 &   4 \\ 
#>   8 &  48 &   1 &  21 \\ 
#>    \hline
#> \end{tabular}
#> \end{table}
print.xtable(xtbl, floating = FALSE)
#> % latex table generated in R 3.5.1 by xtable 1.8-3 package
#> % Sun Jan 13 15:28:24 2019
#> \begin{tabular}{rrrr}
#>   \hline
#>  & 4 & f & r \\ 
#>   \hline
#> 4 &  23 &  58 &   0 \\ 
#>   5 &   0 &   4 &   0 \\ 
#>   6 &  32 &  43 &   4 \\ 
#>   8 &  48 &   1 &  21 \\ 
#>    \hline
#> \end{tabular}

Created on 2019-01-13 by the reprex package (v0.2.1)

@benediktclaus
Copy link

It would be great to control the floating of a table (as in LaTeX like \begin{table}[htbp]) and not just automatically break it. Or at least control the floating environment (table instead of lontable).

@AaronGullickson
Copy link
Contributor

I want to second this suggestion. I am in the process of switching over to gt from kableExtra and this is the one thing making that transition difficult. IMO, a floating environment should be the default for any latex output.

@andrewheiss
Copy link

Hi! Just checking in on this, given advancements in Quarto. With Quarto it's possible to control figure position in PDF/LaTeX documents (see https://quarto.org/docs/authoring/figures.html#figure-position), with options like b, h, t, etc.

With {gt} tables, though, it isn't possible yet, leading to tables that span multiple pages and the general inability to position tables as floats, like this issue/discussion here: quarto-dev/quarto-cli#7171

@AaronGullickson AaronGullickson linked a pull request Feb 25, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment