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

Main header font size needs to be set explicitly #257

Closed baarthur closed 4 months ago

baarthur commented 4 months ago

I don't know if I should split this into two issues, so I opted for conciseness.

First, I'd like to suggest passing fontsize into options, I actually thought I could do it (see the commented options()).

Second, I saw in the manual that headers can be updated by style_tt() except those generated by group_tt() in formats Word and Markdown. What I am trying to do is quite simple, to get the whole table in the same font size (I've set a ridiculously small one just for the sake of the argument).


---
title: "debug_tinytable"
format: pdf
---

```{r}
#| label: setup
#| warning: false
#| message: false

library(dplyr)
library(tinytable)
#options(tinytable_tt_fontsize = 0.6688)

set.seed(1)

font_8pt <- 0.6688

Header font won't change automatically

#| tbl-cap: "Trying to format header and table altogether"
df %>% 
  tt() %>% 
  style_tt(fontsize = font_8pt)
#| tbl-cap: "I need to ajust the header font manually"

df %>% 
  tt() %>% 
  style_tt(fontsize = font_8pt) %>% 
  style_tt(fontsize = font_8pt, i = 0)
vincentarelbundock commented 4 months ago

You don't have to make two separate calls. This works:

library(tinytable)
library(magrittr)
head(iris) %>% 
  tt() %>% 
  style_tt(i = 0:nrow(.), fontsize = 0.6)
baarthur commented 4 months ago

Ohh, okay. But why won't it adjust the header automatically?

vincentarelbundock commented 4 months ago

Ohh, okay. But why won't it adjust the header automatically?

The behavior is the same for all arguments: it adjusts the contents of the table, not the headers by default. Try style_tt(color = "orange")

baarthur commented 4 months ago

One last thing, how can I adjust footnote size? Should I pass it as a latex argument, like we do for the label when using multipage?

vincentarelbundock commented 4 months ago

tabularray is super powerful for this stuff. For example:

---
title: "debug_tinytable"
format: 
    pdf:
        header-includes: |
            \SetTblrStyle{foot}{font=\LARGE}
---

```{r}
library(tinytable)
library(magrittr)
tt(head(iris), notes = "Blah blah") |> style_tt(color = "orange")
baarthur commented 4 months ago

you're a hero, Vincent, thanks again! I never learned latex properly since I jumped from word to RMd/Quarto skipping the overleaf phase, so I'm still learning a lot.