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

Caption and crossrefs not working in Quarto (Word output) #451

Closed
busemorose opened this issue Sep 4, 2022 · 6 comments
Closed

Caption and crossrefs not working in Quarto (Word output) #451

busemorose opened this issue Sep 4, 2022 · 6 comments

Comments

@busemorose
Copy link

busemorose commented Sep 4, 2022

Hello. First, thank you very much for your work. I've been using flextable for more than 1 year and it's awesome. I'm not sure where to post so feel free to delete the issue if not appropriate.

I'm trying to transition from Rmarkdown to Quarto and I'm struggling to have the flextable objects working as intended. The tables appear nicely but there is no label neither caption. I had a look at a recent thread about this problem and a potential solution but couldn't manage to make it work (quarto-dev/quarto-cli#1556 (comment)). I (hopefully correctly) updated flextable, quarto, office and officedown to the last Github version available, as suggested.

Reproducible example

---
title: "Untitled"
format: docx
---

```{r include=FALSE}
library(officer)
library(officedown)
knitr::opts_chunk$set(echo = FALSE)
```


blah blah blah `r run_reference(id = "tbl-flextable")`.

```{r}
#| label: tbl-flextable
#| tbl-cap: Caption **strong**
flextable::flextable(mtcars[1:4, 1:4])
```

My output (traduction: Error! Reference Source Not Found)

2022-09-04 20_55_18-dddfdfd docx  Lecture seule   Mode de compatibilité  - Word

sessionInfo

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] flextable_0.7.4.008  officer_0.4.4.005    officedown_0.2.5.001

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        digest_0.6.29     R6_2.5.1          grid_4.1.0        evaluate_0.16    
 [6] zip_2.2.0         cachem_1.0.5      rlang_1.0.4       gdtools_0.2.4     cli_3.3.0        
[11] uuid_1.1-0        data.table_1.14.2 rstudioapi_0.13   xml2_1.3.3        rmarkdown_2.16   
[16] tools_4.1.0       yaml_2.3.5        xfun_0.32         fastmap_1.1.0     compiler_4.1.0   
[21] systemfonts_1.0.4 base64enc_0.1-3   rvg_0.2.5         memoise_2.0.1     htmltools_0.5.3  
[26] knitr_1.40      

quarto check install

$ quarto check install

[>] Checking Quarto installation......OK
      Version: 1.2.57
      Path: C:\Users\hsm\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

quarto check knitr

$ quarto check knitr

[>] Checking R installation...........OK
      Version: 4.1.0
      Path: C:/PROGRA~1/R/R-41~1.0
      LibPaths:
        - C:/Users/hsm/Documents/R/win-library/4.1
        - C:/Program Files/R/R-4.1.0/library
      rmarkdown: 2.16

[>] Checking Knitr engine render......OK
@davidgohel
Copy link
Owner

hello,

Yes, we removed quarto/docx captions from the dev version temporary.

We are working on it. We will put them back soon, this week probably. :)

@busemorose
Copy link
Author

Nice to hear! Thank you.

@davidgohel
Copy link
Owner

Hello,

It should be ok now. Note it's recommended to define the caption with set_caption if you want formatted caption!

---
title: "Untitled"
format: docx
---

```{r include=FALSE}
library(flextable)
library(officer)
knitr::opts_chunk$set(echo = FALSE)
```


blah blah blah `r run_reference(id = "tbl-flextable")`.

```{r}
#| label: tbl-flextable
#| tbl-cap: Caption **strong**
flextable(mtcars[1:4, 1:4]) |>
  set_caption(
    caption = as_paragraph(
      "Caption ",
      as_chunk("strong", props = fp_text_default(bold = TRUE))
    )
  )
```

Capture d’écran 2022-09-06 à 14 43 18

@davidgohel
Copy link
Owner

davidgohel commented Sep 6, 2022

I am closing the issue, let me know if I should reopen it.

@busemorose
Copy link
Author

Thank you very much. It works perfectly!

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants