unable to resolve crossref for python chunks in quarto #7667
-
DescriptionI was using a quarto document to render to a word document that contained r and python code chunks with cross references in the text that referred to table or figure numbers. Everything had worked perfectly, but ... I attempted to put inline output from python into the text before I realized this only worked for r code. In the process of trying different options, nothing negative happened immediately. However, I eventually received a WARNING: unable to resolve crossref @tbl-name for all the python chunks I was using that contained cross references. All r chunks behave as they should. The output for the python chunks is present in the rendered document, but no cross ref works for the python chunks. I am only showing a python chunk, but my document contains r code; therefore, I omitted the jupyter: python3 statement in the yaml. There was no previous problem omitting that statement. I don't know what happened or how to resolve. Please note you would have to change the attached file from .txt to .py ---
format:
docx:
keep-tex: false
execute:
echo: False
warning: false
page-width: 7.5
tbl-colwidths: auto
always_allow_html: true
editor_options:
chunk_output_type: inline
---
```{python}
# | label: python libraries
from pyprojroot.here import here
```
```{python, file=here("n_treatments.py")}
# | label: tbl-rates
# | tbl-cap: Just a caption.
```
Just a statement to reference the values shown in @tbl-rates.
[n_treatments.txt](https://github.com/quarto-dev/quarto-cli/files/13431270/n_treatments.txt)
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
From what you are saying you are using knitr and reticulate, is it correct? You seem to not have closed properly your example as the attachment is included in it.
Note that if your document can be shared as a flat file which seems to be the case, you could simply paste that here. You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````qmd
---
title: "Reproducible Quarto Document"
format: html
---
This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.
```{r}
plot(cars)
```
The end.
```` |
Beta Was this translation helpful? Give feedback.
-
Code cell syntax with non-yaml is knitr-specific syntax. That You can verify that there's no output happening by:
With no |
Beta Was this translation helpful? Give feedback.
You have many typos and unnecessary options at least in your example.
#|
not# |
.docx:
.keep-tex
is not relevant fordocx
.if you want to use knitr/reticulate for Python code without R code cells, as said by Carlos, you need to explicitly set the engine.
Fixing everything and make it small works just fine: