Open Mavoort opened 5 months ago
If you look at the generated LaTeX-file document.tex
, the problem is in line 127:
126 \usepackage[]{biblatex}
127 \addbibresource{quarto\_references.bib}
If you remove the underscore there and then run xelatex+biber+xelatex again
xelatex --interaction=nonstopmode document.tex
biber document
everything works fine.
That's a LaTeX limitation I'm afraid. LaTeX "does not like" underscores and needs to escape them which in some situations leads to crash or weird side effects. I'm not sure there is anything that can be done here.
Note that keep-latex
does not exist, the correct option is keep-tex
.
Hm, the option keep-latex
works fine for me.
Thanks for you answer. However, I still think this has nothing to do with LaTeX.
LaTeX "doesn't like" underscores because it uses them to typeset subscript: H_2 O
--> H₂O . That's why Quarto has to escape them in normal text, meaning it converts text with _ underscore
in the .qmd file to text with \_ underscore
in the generated LaTeX file.
But there are exceptions to this, which are filenames. For example, Quarto converts
![description](image_with_underscore.png)
to
\includegraphics{image_with_underscore.png}
in the generated .tex file (notice: no backslashes). Otherwise, it would not be possible to include images with an underscore in the filename. The same is true for hyperlinks with \href
.
This means Quarto must have an internal filter somewhere: Escape all underscores with a backslash, except in filenames of hyperlinks and images.
What I am suggesting is to add bibtex files to that exception. That way, everything would work. You can see this the following way:
quarto render document.qmd
--> generates a LaTeX-file, document.tex
document.tex
manually to remove the backslash at
\addbibresource{quarto\_references.bib}
xelatex --interaction=nonstopmode document.tex
biber document
This works without problems, generating a pdf-file with the desired citations. There are no error messages in XeLaTeX or biber. For this reason I think the problem lies with Quarto and not with LaTeX.
Hm, the option keep-latex works fine for me.
Try with a document that does not crash. It can't work because that option does not exist in the codebase.
The issue is Pandoc. Quarto does not handle citations, Pandoc does.
quarto pandoc -s --bibliography=refer_ences.bib --biblatex -o index.tex index.md
Will lead to \addbibresource{refer\_ences.bib}
.
It's a problem with LaTeX not handling _
everywhere the same way. In some places, they need to be escaped and in others, they don't. Here Pandoc escaped it while it should not.
This needs to be reported upstream (https://github.com/jgm/pandoc).
FYI, I did not see a report for bibliography file but another one for another part:
I think you're right. I did not consider that the problem might be with Pandoc. I'll open an issue there.
Related discussion
and historically Pandoc has this issue reported, but it seems it was not a Pandoc issue directly 🤔
It is possible they missed something and that \addbibresource
does not allow escaped underscore, which is what Pandoc templating system is adding.
bibliography: '`quarto_references.bib`{=latex}'
(i.e., specifying that the string is raw latex, based on a suggestion made in https://github.com/jgm/pandoc/issues/9262#issuecomment-1859241645) seems to work for the example given in the OP.
That is a good solution !
bibliography
is not a format specific fieldSo I would say solutions should be
Thanks
Bug description
If you write an article that contains citations and use the
biblatex
engine instead of the default one (citeproc), Quarto cannot handle underscores in the filename of the .bib file.Steps to reproduce
Content of
documend.qmd
:Content of
quarto_references.bib
:Expected behavior
Quarto should render the document to a pdf-file and use biber to create correct citations:
Actual behavior
Quarto apparently runs biber on
quarto\_references.bib
(notice the backslash), which doesn't exist. This causes biber to fail with an error message:Your environment
Quarto check output