-
Notifications
You must be signed in to change notification settings - Fork 214
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
Option to omit longtable environment in Latex #1310
Comments
I agree with this suggestion. Right now I am struggling to add captions and labels to LaTeX tables produced by the gt package and this would be an easy solution. |
@spittssj In case it's helpful as a work-around, I wrote some simple functions here to convert longtable to tabular in a text file. The same link also has a function to extract only the part between the \begin{tabular} and \end{tabular}. This post-processing worked pretty well for me, although it'd be great if it were eventually made internal to gt. |
@jonathandroth the link you provided doesn't work but the code you describes sounds useful. Can you check the link (or perhaps the security settings)? Thanks. |
@spittssj apologies, here is a public version https://github.com/jiafengkevinchen/logs-public/blob/6b2e96e482a2b389e182b1c8bbbc4d5023931fae/extract_tabular.R#L41 |
Thanks @jonathandroth. I tried the code and it works well. |
Glad to hear!
…On Tue, Dec 26, 2023, 2:33 PM Stephen Pitts SJ ***@***.***> wrote:
Thanks @jonathandroth <https://github.com/jonathandroth>. I tried the
code and it works well.
—
Reply to this email directly, view it on GitHub
<#1310 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE6EXFFTCEM5VZGA45JFZGTYLMRALAVCNFSM6AAAAAAXBIFCW6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRZG4ZTIOJTGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I think this would be fixed if #1588 is merged? |
I think not quite, because the request was to have the output begin with Just to clarify, the motivation for this request is that I find it much easier to handle creating tables locally in Latex--- because captioning, labeling, and desired placement are specific to the document. So my Latex document would have
Of course, while you're modifying this code, it seems like it should be straightforward to omit the |
There is a new # dev gt
# pak::pak("rstudio/gt")
library(gt)
gt(exibble) |>
tab_caption("caption") |>
tab_options(latex.tbl.pos = "h!") |>
as_latex()
|
Duplicate of #1549 |
It's great that you can handle positioning and titles within gt. However, I personally find it much easier to handle those in the Latex document itself, and not have to run my code again every time I want to change the title or position of my table. That is why it's much easier to have gt output only the \begin{tabular} ... \end{tabular} part without the table environment. But totally understood if you don't have the time/energy to implement that. I can continue to ex-post process the output to remove the table environment as in the code snippet shared above. |
The other option would be to use a Rnw file instead of LaTeX. Rnw files are just LaTeX containing R code chunks, and can be processed by knitr, so you could have the table-generation code directly in the LaTeX source so it is automatically regenerated when you compile to PDF. |
Thank you for the great package!
I think it would be great if the gtsave function had an option to omit the \begin{longtable} and \end{longtable} parts and only save the the text from \begin{tabular} to \end{tabular}. This would facilitate incorporating the output into Latex documents, and would be analogous to e.g. the contents_only option in xtable.
The text was updated successfully, but these errors were encountered: