APA theme and helpers #426
Replies: 5 comments 18 replies
-
Hi in shameless self-promotion, I am quite happy with my I think overall a function or template for the APA Style is very useful and would be highly appreciated by a wide community, as there is a whole range of Journals in Social Science and Medicine that explicitly require APA Style. In the APA Publication Manual the Chapter would be "7 Tables and Figures" (pp 195. - 209). There are also examples included, which are also on the apastyle webpage you referenced (examples can be found: here). PS: Just noticed that I did not credit List of Details on Formatting (relevant to flextable):
|
Beta Was this translation helpful? Give feedback.
-
Ok. Here's a first attempt. library(flextable)
theme_apa <- function(x) {
if (!inherits(x, "flextable")) {
stop("theme_apa supports only flextable objects.")
}
apa.border <- list("width" = 1, color = "black", style = "solid")
x <- font(x, part = "all", fontname = "Times New Roman")
x <- line_spacing(x, space = 2, part = "all")
x <- hline_top(x, part = "head", border = apa.border)
x <- hline_bottom(x, part = "head", border = apa.border)
x <- hline_top(x, part = "body", border = apa.border)
x <- hline_bottom(x, part = "body", border = apa.border)
x <- align(x, align = "center", part = "all")
x <- valign(x, valign = "center", part = "all")
x <- colformat_double(x, digits = 2)
fix_border_issues(x)
}
head(mtcars*22.22) |>
flextable() |>
theme_apa()
Discussion
@Buedenbender, anything missing in your opinion? I tried combining both our custom functions. Thanks for setting up all the resources and explanations in your first post! |
Beta Was this translation helpful? Give feedback.
-
@davidgohel would it be useful if I submitted a PR with the new APA theme? |
Beta Was this translation helpful? Give feedback.
-
(Sorry for the delay; I was in holidays, and then I tested flextable with quarto and since I am working on captions... but it is related to our subjects) You can prepare a PR, it will be welcome. But we may have to iterate over it, because there is something to enable for captions (with the caption structure table xx/caption/table), it must be made compatible with cross-referencing in bookdown and in quarto if possible. I am not sure if it's easy. (Everything related to caption is crazily time-consuming!) I am also working on enabling captions formatting as you have suggested. That's almost ready. |
Beta Was this translation helpful? Give feedback.
-
Sorry again for the delay but I do what I can :) @rempsyc to answer your questions
Starting from the PR of @rempsyc and the latest GitHub version of flextable,
This solution comes with some limits:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to help with APA subject
@rempsyc @Buedenbender
guidelines and references:
Beta Was this translation helpful? Give feedback.
All reactions