quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.74k stars 305 forks source link

Having a section with underlined text together with unnumber operator gives error #6962

Open psads-git opened 11 months ago

psads-git commented 11 months ago

Consider the following quarto document:

---
title: "Untitled"
format: pdf
toc: true
---

# some [underlined text]{.underline} {-}

It gives the following error:

updating tlmgr

updating existing packages

compilation failed- error
Use of \SOUL@n doesn't match its definition.
\SOUL@ulunderline #1->{\setbox \z@ \hbox {#1}
                                             \dimen@ =\wd \z@ \dimen@i =\SOU...
l.159 ...{toc}{section}{some \ul{underlined text}}

see Untitled-1.log for more information.

If one removes {-} the error does not show up.

I am using quarto 1.4.376 version.

cscheid commented 11 months ago

This isn't a quarto bug; it's a limitation of the latex format. The following happens with Pandoc directly:

$ cat pandoc-title-test.qmd
---
title: "Untitled"
---

# some [underlined text]{.underline} {-}

$ pandoc -f markdown -t pdf pandoc-title-test.qmd -o out.pdf
Error producing PDF.
! Use of \SOUL@n doesn't match its definition.
\SOUL@ulunderline #1->{\setbox \z@ \hbox {#1}
                                             \SOUL@dimen =\wd \z@ \SOUL@dime...
l.69 ...e{toc}{section}{some \ul{underlined text}}

The issue, I believe, is that the LaTeX template from Pandoc doesn't allow decorated text in the table of contents.

cscheid commented 11 months ago

Ideally, we'd figure out the difference between decorated and undecorated text, and we would emit an error message or warning. Unfortunately, that's very hard to do in general. I've made this an enhancement issue, and I'll leave it open; perhaps someone can come up with a clever idea here.

psads-git commented 11 months ago

Thanks, Carlos, for your answer.

Is there some workaround users can resort to?

cscheid commented 11 months ago

Is there some workaround users can resort to?

The workaround is crude: don't use adorned text in headings.

psads-git commented 11 months ago

Thanks, Carlos. I have successfully used LaTeX instead of markdown to create the unnumbered underlined section.

cderv commented 11 months ago

I have successfully used LaTeX instead of markdown to create the unnumbered underlined section.

Can you share what you used ? I am curious...

The issue happens because of this in the LaTeX file

\addcontentsline{toc}{section}{some \ul{underlined text}}

Using \ul inside \addcontentsline seems not permitted.

\addcontentsline is added when a secion is .unnumbered but listed. If you use

# some [underlined text]{.underline} {.unnumbered .unlisted}

you won't have the issue.

The LaTeX is written by Pandoc. So if you have a LaTeX workaround, you could report in Pandoc's repo so that they do not create not working LaTeX code maybe. 🤷

psads-git commented 11 months ago

Thanks, Christophe. Actually, I do not use any underlining inside the table of contents entry (that is maybe why it works):

\subsubsection*{Some \ul{underlined text}}
\addcontentsline{toc}{subsubsection}{Some underlined text}
cderv commented 11 months ago

I do not use any underlining inside the table of contents entry (that is maybe why it works)

Yes exactly. This is the underlying problem - as Pandoc is not stripping the \ul itself when creating the tex line.