Long note in modelsummary

758 Views Asked by At

I was wondering, whether it is possible to align text on both sides in notes using modelsummary. It would be great if the note would look similar to notes in this paper https://www.econ.uzh.ch/dam/jcr:a68d7a76-93af-4ceb-86aa-344d6ee8d0c6/dodging%20the%20taxman%20AEJ%20Applied.pdf (in particular similar to that on page 151).

In markdown notes look fine. Once I export to .tex the text is somewhat misaligned.

Here is the code that I used.

library("modelsummary")

#small example:
x<-rnorm(5)
y<-rnorm(5)
modelsummary(list(lm(y~x),lm(y~x)),notes = "this is my very very very very very very long note this is my very very very very very very long note",output = "test.tex")
1

There are 1 best solutions below

0
On BEST ANSWER

The default output for the modelsummary function is a table drawn by the kableExtra package. It looks like kableExtra supports the LaTeX threeparttable package which, I believe, allows you to left-and-right justify footnotes. To learn how to customize kableExtra tables, I strongly recommend you read the excellent LaTeX-focused vignette which can be found on the kableEtra website.

If you don't like the default footnotes supplied by modelsummary, for example, you can create your own using the footnote function from kableExtra. To do this, you need to specify "latex" as your output format, then apply the footnote function, then finally save the table with save_kable.

This code should bring you very close to the desired result, but note that kableExtra allows lots of ways to customize almost everything about your table:

library("modelsummary")
library("kableExtra")

x<-rnorm(5)
y<-rnorm(5)

m <- list(lm(y~x),lm(y~x))
n <- "this is my very very very very very very long note this is my very very very very very very long note"

modelsummary(m, output = "latex") %>%
    footnote(general = n, threeparttable = TRUE) %>%
    save_kable(file = "~/Downloads/test.tex")

enter image description here