vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
196 stars 16 forks source link

multipage not working in PDF tutorial #236

Closed andrewheiss closed 5 months ago

andrewheiss commented 5 months ago

I've been struggling to get multipage working with Quarto, and it seems that the documentation is too.

The vignette at https://vincentarelbundock.github.io/tinytable/vignettes/tinytable_tutorial.pdf currently doesn't show multipage working:

image

The older tutorial vignette at https://vincentarelbundock.github.io/tinytable/vignettes/tutorial.pdf has it working:

image
andrewheiss commented 5 months ago

The LaTeX output seems to not be using longtblr anymore:

tmp <- rbind(mtcars, mtcars)[, 1:6]

cap <- "A long 80\\% width table with repeating headers."

tt(tmp, width = .8, caption = cap) |>
  theme_tt("multipage", rowhead = 1) |> 
  print("latex")
\begin{talltblr}[         %% tabularray outer open
caption={},
caption={A long 80\% width table with repeating headers.},
]                     %% tabularray outer close
{                     %% tabularray inner open
width={0.8\linewidth},
colspec={X[]X[]X[]X[]X[]X[]},
rowhead=1,
}                     %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat & wt \\ \midrule %% TinyTableHeader
21.0 & 6 & 160.0 & 110 & 3.90 & 2.620 \\
21.0 & 6 & 160.0 & 110 & 3.90 & 2.875 \\
...
vincentarelbundock commented 5 months ago

Thanks a lot for the investigation. You put your finger right on it. Should be fixed now on Github.

Note that chunk options for caption and label do not work in Quarto with multipage table, as reported here: https://github.com/quarto-dev/quarto-cli/discussions/9332

You'll need to use the caption argument and insert \\label{blahblah} in the caption itself if you want references to work in LaTeX.

andrewheiss commented 5 months ago

Et voilà! Thanks!

image
vincentarelbundock commented 5 months ago

Nice! now how do we avoid linebreaks? You could then use the resize theme to make it fit horizontally...

andrewheiss commented 5 months ago

Using landscape works well here

Add this to the preamble bc pandoc doesn't parse anything in between \begin{} and \end{}

\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}

Then use those in the document:

\blandscape

```{r}
tt(...) |>
  theme_tt("multipage", rowhead = 1)

\elandscape



<img width="1120" alt="image" src="https://github.com/vincentarelbundock/tinytable/assets/73663/0a7e04d2-a706-480a-9809-8017ac3bf665">

(idk what's happening with the centering here for some of those columns 🤷‍♂️ )