quarto-dev / quarto-cli

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

Problem with markdown tables, when they are followed by some content in beamer presentation. #10019

Open MerkulovDaniil opened 2 weeks ago

MerkulovDaniil commented 2 weeks ago

Bug description

I have many repositories with presentations and sites built using Quarto (❤️). Some of them encountered issues when they were automatically deployed with GitHub Actions after a commit, resulting in errors like this:

ERROR: 
compilation failed- error
Undefined control sequence.
\@currentHref ->table.\theHtable 

l.196 \end{frame}

As a result, for the past week, I switched from automatic deployment to manually running:

quarto publish gh-pages

However, after updating from TeX Live 2023 to TeX Live 2024, I noticed that several documents which previously built successfully now crash with the same errors. I decided to create the smallest possible example to reproduce the problem and observed that the issue occurs when a markdown table is followed by any content.

Here are my findings:

Steps to reproduce

Here is small Quarto document, that raise an error

---
title: Table problems
format: 
    beamer:
        pdf-engine: pdflatex
---

# Section

## Slide 1

| Customer / Source | Arnhem [euro/ton] |  Gouda [euro/ton] | Demand [tons] |
| :---: | :--: | :--: | :--: |
| London | n/a | 2.5 | 125 |
| The Hague | 1.4 | 0.8 | 200 |
| **Supply [tons]** | 550 tons | 700 tons | n/a |

## Slide 2

While If you remove the Slide 2, the problem will disappear.

---
title: Table problems
format: 
    beamer:
        pdf-engine: pdflatex
---

# Section

## Slide 1

| Customer / Source | Arnhem [euro/ton] |  Gouda [euro/ton] | Demand [tons] |
| :---: | :--: | :--: | :--: |
| London | n/a | 2.5 | 125 |
| The Hague | 1.4 | 0.8 | 200 |
| **Supply [tons]** | 550 tons | 700 tons | n/a |

You can compile the document with the command

quarto preview file.qmd

Expected behavior

Produce beamer presentation

Actual behavior

Rendering PDF
running pdflatex - 1
  This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
   restricted \write18 enabled.
  entering extended mode

updating tlmgr

updating existing packages
ERROR: 
compilation failed- error
Undefined control sequence.
\@currentHref ->table.\theHtable 

l.196 \end{frame}

Your environment

Macos 14.5 (23F79) The problem occurs both in VSCode and in terminal compilation.

Quarto check output

% quarto check                                                                         
Quarto 1.5.45
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.45
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.06
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/USER/Library/TinyTeX/bin/universal-darwin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.11.4
      Path: /Users/USER/.pyenv/versions/3.11.4/bin/python
      Jupyter: 5.3.2
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
MerkulovDaniil commented 2 weeks ago

I figured out, that adding the following line to the tex preamble solves the problem both locally and in the CI mode with GitHub page automatic build.

\newcommand{\theHtable}{\thetable}
mcanouil commented 2 weeks ago

The below command will exhibit the issue.

quarto pandoc --from markdown index.qmd --to beamer -o index.pdf

In the LaTeX file, the issue seems to be: \phantomsection\label{slide-2}.

And looking a bit deeper with an educated guess: that's a bad interaction with longtable (cc @cscheid 😏).

Not working with "longtable"Working just fine with "tabular"
````qmd --- title: Table problems format: beamer --- # Section ## Slide 1 ```{=latex} \begin{longtable}{|c|c|c|} \hline \textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\ \hline \endfirsthead Cell 1 & Cell 2 & Cell 3 \\ \hline Cell 4 & Cell 5 & Cell 6 \\ \hline \end{longtable} ``` ## Slide 2 ```` ````qmd --- title: Table problems format: beamer --- # Section ## Slide 1 ```{=latex} \begin{tabular}{|c|c|c|} \hline \textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\ \hline Cell 1 & Cell 2 & Cell 3 \\ \hline Cell 4 & Cell 5 & Cell 6 \\ \hline \end{tabular} ``` ## Slide 2 ````
cderv commented 2 weeks ago

@mcanouil it seems like an issue with Pandoc converting markdown tables to longtable, and then an issue with longtable used in beamer in certain context right ?

If so, we should report to Pandoc probably

mcanouil commented 2 weeks ago

Yes, that's my understanding of the issue from few tests.

Note that using the \newcommand{\theHtable}{\thetable} trick in the template could be a good fix which should not harm (although it would be good to know what overwrites this in the first place that needs to be set it again).

mcanouil commented 1 week ago

@mattysimonson as showed the bug does not originate from Quarto. That's still bad LaTeX bug but a LaTeX one nonetheless.

The fix will very likely be the workaround with the newcommand command.

cscheid commented 1 week ago

the Posit folks really need to address this bug as soon as possible.

Just to set the expectations: we don't consider this tone to be helpful or constructive, and we expect you to be both in this forum.

mattysimonson commented 1 week ago

the Posit folks really need to address this bug as soon as possible.

Just to set the expectations: we don't consider this tone to be helpful or constructive, and we expect you to be both in this forum.

Sorry! Was not thinking about my tone. I should have said, "I expect this issue will affect a lot of users in the coming days, so I hope it can be addressed promptly."