wjschne / apaquarto

A quarto extension for creating APA7 documents in .docx, .html, and .pdf formats
https://wjschne.github.io/apaquarto/
Creative Commons Zero v1.0 Universal
166 stars 14 forks source link

Enable `include-in-header` #60

Closed mvuorre closed 5 months ago

mvuorre commented 6 months ago

It would be great to be able to use the Quarto standard methods for including LaTeX stuff, such as the include-in-header metadata field. However currently one must use a apaquarto custom (?) command header-insert to do so, which breaks interoperability and makes maintaining harder (?). See e.g. #40.

As a salient example, I would like to use the excellent tinytable package, which automatically adds LaTeX requirements to the document (see 7.2 here). However it doesn't work with apaquarto since it cannot use the standard Quarto methods for doing so. So for example the following would not work without lines 8-13 (which then do not propagate to other PDF formats):

---
title: "My Title"
author:
  - name: Jane Doe
format:
  apaquarto-pdf:
    documentmode: doc
header-insert: |
  \usepackage{tabularray}
  \usepackage{float}
  \usepackage{graphicx}
  \usepackage[normalem]{ulem}
  \UseTblrLibrary{booktabs}
---

```{r}
library(knitr)
library(tinytable)
tbl <- mtcars[1:4, 1:4]

knitr::kable works

kable(tbl)

tinytable::tt doesnt

tt(tbl)


What features are blocking this and how can I help?
wjschne commented 5 months ago

Whatever the problem was before, it seems to be gone. I have now enabled include-in-header. Let me know if tinytable now works as you expect it to.

mvuorre commented 5 months ago

Yes, wonderful, works just fine now. 🎉

This

---
title: "My Title"
author:
  - name: Jane Doe
format:
  apaquarto-pdf:
    documentmode: doc
---

```{r}
library(knitr)
library(tinytable)
tbl <- mtcars[1:4, 1:4]

knitr::kable works

kable(tbl)

tinytable::tt does too!

tt(tbl) |>
  theme_tt("placement", latex_float = "H")


Correctly produces this

<img width="763" alt="image" src="https://github.com/wjschne/apaquarto/assets/7349270/8bd3470c-aef4-4966-b017-d7cf314d8bd2">