Closed selinaZitrone closed 2 years ago
Thanks for reporting this! It turns out we needed to handle some escaping to accommodate the %
. Fix is here: https://github.com/quarto-dev/quarto-cli/commit/e357d1c5232082fc0e3f9da9c7d377d5c1563a4d
Thanks for fixing the bug so quickly. I found that this renders nicely the html document. However, for pdf, there is still an error thrown:
---
format: pdf
---
```{r}
#| label: tbl-rel-diff
#| tbl-cap: "Median and 95% confidence interval"
kableExtra::kbl(head(iris))
This gives me the following error:
![image](https://user-images.githubusercontent.com/38790212/167103405-d6c98d35-4279-42fe-b749-d83e07319e30.png)
Looking into the `.tex` file, I find that the `%` is not escaped an therefore the closing `}` of the caption is turned into a comment:
![image](https://user-images.githubusercontent.com/38790212/167103607-99965517-b73d-4a2a-be6f-84a11ee8f463.png)
I tried to look into the quarto code to fix it but don't understand lua enough to find the mistake.
In LaTeX, the %
needs it self to be escaped. So when we are writing the caption code in YAML we need to produce \%
.
@jjallaire I think we need to do that in the pre processing only when we are creating a caption
diff --git a/src/resources/filters/quarto-pre/table-captions.lua b/src/resources/filters/quarto-pre/table-captions.lua
index 3c1eb9f9e..e5870aaf0 100644
--- a/src/resources/filters/quarto-pre/table-captions.lua
+++ b/src/resources/filters/quarto-pre/table-captions.lua
@@ -216,7 +216,7 @@ function applyLatexTableCaption(latex, tblCaption, tblLabel, tablePattern)
if #tblLabel > 0 then
captionText = captionText .. " {#" .. tblLabel .. "}"
end
- latex = latex:gsub(latexCaptionPattern, "%1" .. captionText:gsub("%%", "%%%%") .. "%3", 1)
+ latex = latex:gsub(latexCaptionPattern, "%1" .. captionText:gsub("%%", "\\%%%%") .. "%3", 1)
return latex
end
I think we need to add a escaped function to process caption so that we handle any of the 10 special chars if found in caption
{ } % & $ # _ ^ ~ \
I'll submit a PR
Thanks @cderv! This should now be fixed here: https://github.com/quarto-dev/quarto-cli/pull/814
Rendering of the following doc (both html and pdf) returns an error in
quarto-pre.lua
: