Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_caption does not work when rendered in quarto, but does with print() command #570

Closed
mlamias opened this issue Sep 13, 2023 · 3 comments

Comments

@mlamias
Copy link

mlamias commented Sep 13, 2023

It seems that set_caption does not appear to be working (for me, at least) when rendering in Quarto to a Word document using the following yaml header:

---
project:
  title: "Test"
format: docx

editor: visual
---

I have the following code in my .qmd file:

```{r}
#| echo: false
cars |> flextable() |> 
flextable::set_caption("THIS TEST")
```

Unfortunately, this seems to produce the following in my Word document:
image

However, if I issue the following statement in R console:

cars |> flextable() |> set_caption("THIS TEST") |> print(preview="docx")

I obtain the following Word document which produces the appropriate caption above the table:
image

I assume this should work since the set_caption() documentation reads:

When working with 'R Markdown' or 'Quarto', the caption settings defined with set_caption() will be prioritized over knitr chunk options.

Is this a bug with flextable, Quarto, or am I missing something?

@davidgohel
Copy link
Owner

It's a missing feature in Quarto. See #565 (comment), #494, quarto-dev/quarto-cli#1556, https://davidgohel.github.io/flextable/reference/set_caption.html#using-quarto-, https://ardata-fr.github.io/flextable-book/captions-and-cross-references.html#cross-references

Captions will work in Quarto with HTML and PDF but not Word.

@mlamias
Copy link
Author

mlamias commented Sep 13, 2023

Thanks @davidgohel. Sorry I missed this in the documentation. I did read through several pages and through opened cases, but I totally missed these. Thanks for pointing this out. I really appreciate the assist.

@davidgohel
Copy link
Owner

This issue can be closed, captions seem to work as expected with Quarto 1.4.549.

For future readers, TLTR, set_caption() has not effect with Quarto that manage captions on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants