vincentarelbundock / tinytable

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

theme ="resize" with scale down/up only option (feature request) #207

Closed MarcoPortmann closed 8 months ago

MarcoPortmann commented 8 months ago

It would be handy, if tt_theme(theme ="resize", width = ... had an option to resize the table in one direction only. For instance, I'd like to keep the original size, if a table's width is smaller than the page's width but I'd like to scale the table down if it doesn't fit on the page.

vincentarelbundock commented 8 months ago

What would be the resizebox{} LaTEX code for that, you think?

vincentarelbundock commented 8 months ago

I figured it out. It should work in the latest version from Github:

test.pdf

---
format: pdf
---

```{r}
library(tinytable)

tt(cbind(mtcars[1:4,], mtcars[1:4,])) |>
  theme_tt("resize", direction = "down") |>
  theme_tt("placement", "H")
tt(cbind(mtcars[1:4, 1:3])) |>
  theme_tt("resize", direction = "down") |>
  theme_tt("placement", "H")
library(tinytable)

tt(cbind(mtcars[1:4,], mtcars[1:4,])) |>
  theme_tt("resize", direction = "both") |>
  theme_tt("placement", "H")
tt(cbind(mtcars[1:4, 1:3])) |>
  theme_tt("resize", direction = "both") |>
  theme_tt("placement", "H")