Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented May 19, 2022

This fixes #924

As shown in #924 (comment), the issue is that the raw LaTeX for caption is not inserted in the right place when option for the table environment are passed: https://fr.overleaf.com/learn/latex/Tables#Reference_guide

Issue happens with gt because it adds something like \begin{longtable}{rr} and it needs to be matched in our script.

Also we need to add LaTeX new line after the caption to avoid a no align error. In knitr, we are adding \\ but I believe in Quarto you may expect \tabularnewline - I have seen this in here:

if (line.match(/^\\caption.*?\\tabularnewline$/)) {

So I used that.

This changes fix the initial issue.
I am opening this PR to run tests. I don't know if this change will be supported for all output and all type of LaTeX tables.
Also so that you can review and advice.

@cderv
Copy link
Collaborator Author

cderv commented May 19, 2022

It seems like everything is passing ok. I'll add tests for this new addition though

@jjallaire
Copy link
Collaborator

@cderv LMK when its okay to merge this

@cderv cderv force-pushed the latex-tables-caption branch from 05058e1 to 76b38ab Compare May 20, 2022 12:10
@cderv cderv marked this pull request as ready for review May 20, 2022 22:03
@cderv
Copy link
Collaborator Author

cderv commented May 20, 2022

@jjallaire this is now ok I manage to add the test and check different scenario. @dragonstyle hopefully I put them in the right place, tests for tables in latex using crossrefs can be put in several places in our current organization.

Regarding gt support I'll work with Rich to fix a few things in the R package before doing anything else in Quarto. It is not currently working ideally.

@jjallaire jjallaire merged commit d7efc45 into main May 21, 2022
@cderv cderv deleted the latex-tables-caption branch May 23, 2022 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues using {gt} objects as cross-referenced tables

3 participants