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

new crossrefs+flextable+docx interaction #7321

Open
cscheid opened this issue Oct 22, 2023 · 10 comments
Open

new crossrefs+flextable+docx interaction #7321

cscheid opened this issue Oct 22, 2023 · 10 comments
Assignees
Labels
bug Something isn't working crossref docx Issues with the docx format tables Issues with Tables including the gt integration
Milestone

Comments

@cscheid
Copy link
Collaborator

cscheid commented Oct 22, 2023

In .docx format, crossreferenceable code cells with flextable outputs cause Microsoft Word to emit a warning about a malformed document.

This doesn't happen when the code cell isn't crossreferenceable, so we're doing something bad to it.

@cscheid cscheid added bug Something isn't working crossref tables Issues with Tables including the gt integration docx Issues with the docx format labels Oct 22, 2023
@cscheid cscheid added this to the v1.4 milestone Oct 22, 2023
@cscheid cscheid self-assigned this Oct 22, 2023
@cscheid
Copy link
Collaborator Author

cscheid commented Oct 22, 2023

This is part of #4944.

@cscheid
Copy link
Collaborator Author

cscheid commented Nov 2, 2023

I spent a couple of hours trying to figure out what is going wrong and failed here - I can't tell what we might be emitting that's bad.

@cscheid cscheid added the needs-discussion Issues that require a team-wide discussion before proceeding further label Nov 2, 2023
@cscheid
Copy link
Collaborator Author

cscheid commented Nov 9, 2023

Let's check non-table crossrefs (duh)

@cderv
Copy link
Collaborator

cderv commented Jun 4, 2024

Just adding an example about this for context

---
title: demo
format: docx
---

```{r lib}
library(flextable)
```

```{r}
#| label: tbl-test
#| tbl-cap: "Caption"

flextable(head(mtcars)) 
```

image

@altonrus
Copy link

altonrus commented Jun 24, 2024

Thank you to the developers working on this! I discovered something interesting when using Quarto's new custom float cross-reference types to implement a workaround that may help you debug.

In the YAML header you can define a new custom table type. I used 'table' as the key instead of 'tbl'.

---
title: demo
format: docx
crossref: 
  custom:
    - kind: float
      key: table
      latex-env: table
      reference-prefix: Table
      space-before-numbering: true
      latex-list-of-description: Table
---

::: {#table-sample}

```{r}
flextable(head(mtcars)) 
```

Table caption here.

:::

As shown in @table-sample

This works without the "unreadable content" warning. BUT if I tell Quarto I want the caption on top of the table, as follows, I then get the unreadable content issue.

crossref: 
  custom:
    - kind: float
      key: table
      latex-env: table
      reference-prefix: Table
      space-before-numbering: true
      latex-list-of-description: Table
      caption-location: top

@cscheid
Copy link
Collaborator Author

cscheid commented Jun 24, 2024

@altonrus I edited your comment slightly. You can use more backticks in your code block declaration to allow backticks in the code.

@jhk0530
Copy link

jhk0530 commented Jun 25, 2024

@altonrus
It's amazing.
It solved my problem.
Thanks a lot.

@rps13
Copy link

rps13 commented Jan 7, 2025

Based on @altonrus finding the following works for me for docx output:

---
title: "Table test"
format:
  docx:
    tbl-cap-location: bottom
---

## Table test with reference

```{r, include=FALSE}
library("flextable")
```

```{r}
#| label: tbl-mt
#| tbl-cap: "mtcars with flextable"
head(mtcars) |> flextable()
```

See @tbl-mt.

The problem only seems to be the caption location for docx output.

@dchiu911
Copy link

I can confirm the warning only appears using default tbl-cap-location: top. Any updates to fix this?

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 14, 2025

Thank you for your interest.
Please refrain from asking updates, if there was one it would have been posted right here.
Instead, use the reactions on the original message to show you are interested in this issue to be fixed. This would help prioritise this over other issues. Again thanks for your interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crossref docx Issues with the docx format tables Issues with Tables including the gt integration
Projects
None yet
Development

No branches or pull requests

8 participants