Closed pbousquets closed 8 months ago
We need a full file; I can't repro your simple case:
---
crossref:
chapters: false
custom:
- kind: float
key: sfig
latex-env: suppfig
reference-prefix: Figure S
caption-prefix: Figure S
space-before-numbering: false
latex-list-of-description: Supplementary Figure
keep-tex: true
---
::: {#sfig-modifs}
![](https://placeholder.co/400/400.png)
My caption.
:::
See [@sfig-modifs].
Ah, I think I know what this is. (This is why we ask for full repros, incidentally, and please try to provide them in the future) It has to be related to books specifically.
Actually, I can't reproduce it in a book setting either. Did you add the crossref entries to the project metadata?
Hi, thanks a lot for replying so quickly.
You're totally right. I should've shared a full file. I tried what you did and it worked indeed with the default book.
My book is a bit complex, it has a large latex preamble to format the final PDF. After trying to obtain a minimal reproducible environment, I found that providing a template tex file is what causes the issue:
I created a new book. I changed the yaml to:
project:
type: book
book:
title: "mybook"
author: "Norah Jones"
date: "3/12/2024"
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
crossref:
chapters: false
custom:
- kind: float
key: sfig
latex-env: suppfig
reference-prefix: Figure S
caption-prefix: Figure S
space-before-numbering: false
latex-list-of-description: Supplementary Figure
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
template: mytex.tex
And then, I added a minimal template (mytex.tex):
\documentclass[a4paper]{book}
\usepackage{bookmark}
\usepackage{framed}
\newenvironment{Shaded}{\begin{singlespace}\begin{snugshade}}{\end{snugshade}\end{singlespace}}
\begin{document}
$body$
\end{document}
I tried to use sfig
in the index.qmd file:
# Preface {.unnumbered}
This is a Quarto book.
To learn more about Quarto books visit <https://quarto.org/docs/books>.
[@sfig-na]
::: {#sfig-na}
![aa](cover.png){fig-align="center"}
:::
I attached a zip file for this example book. aa.zip
@pbousquets By replacing the whole template, you will lose some of Pandoc and Quarto features as we mentioned in the doc. You should read about LaTeX partials introduction and usage : https://quarto.org/docs/journals/templates.html#template-partials
In this specific example, you did remove header-includes
pandoc's variable, and this is what is used to inject the custom LaTeX commands created for the custom cross-ref.
Quarto has introduced LaTeX partials to allow tweaking part of the template when creating format, without loosing requirement from Pandoc regarding features.
Hope this clarify.
I'm going to go ahead and close this since it's not a bug on our side (see the comment about header-includes specifically).
Thanks a lot both of you for checking this so quickly.
Bug description
I'm writing a quarto book, where I need to add Supplementary Figures. I followed the steps from the tutorial, with my YAML having:
I add my figure in the appendix:
And then I cite it with:
Steps to reproduce
No response
Expected behavior
It should cite the suppfig
Actual behavior
ERROR: compilation failed- error Undefined control sequence. l.2124 (\quartosfigref {sfig-modifs}).
Your environment
quarto 1.4.542
Quarto check output
No response