crsh / papaja

papaja (Preparing APA Journal Articles) is an R package that provides document formats to produce complete APA manuscripts from RMarkdown-files (PDF and Word documents) and helper functions that facilitate reporting statistics, tables, and plots.
https://frederikaust.com/papaja_man/
Other
654 stars 133 forks source link

Broken captions for tables on Word documents #556

Open tkerwin opened 1 year ago

tkerwin commented 1 year ago

In docx file output from quarto, tables created with apa_table are prefixed with

(#tab:unnamed-chunk-8)
**

-- where "8" is whatever the chunk number is.

Adding a caption field gets rid of the ** but the erroneous table cross-reference code is still there.

I see there is a pull request from the word-fixes branch that looks like it could fix the issue, but it is not in the released version. Right now the released version is unusable for professional document output without editing the document after generation.

crsh commented 1 year ago

Hi Thomas, I just merged the branch. Could you try installing from the main branch and let me know if this fixes the problem for you?

tkerwin commented 1 year ago

This fixes a problem, but does not solve it completely for me. The fixes you merged in make the table work properly when using RMarkdown + Bookdown. However, it doesn't work for Quarto documents.

It looks like the problem is that Bookdown wants Table: (\#tab:table-name) Caption, but Quarto wants : Caption {#tbl-table-name} (or a table label and caption metadata in the block).

I've tried to find out how to detect if the block is being parsed with RMarkdown or Quarto but I'm not sure if there is an easy way. My suggestion would be to have a configuration flag somewhere in papaja to tell the library if you want Bookdown style output or Quarto style output.