-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem parsing raw LaTeX table environment with option (like H position) #9522
Comments
Thanks for the report: This is seems to be an issue with table processing when the table is using cross-reference. If you remove the \begin{table}[H]
\centering
\begin{tabular}[t]{l>{\raggedleft\arraybackslash}p{30em}rrrrrrrrrr}
\toprule
& mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb\\
\midrule
\cellcolor{gray!10}{Mazda RX4} & \cellcolor{gray!10}{21.0} & \cellcolor{gray!10}{6} & \cellcolor{gray!10}{160} & \cellcolor{gray!10}{110} & \cellcolor{gray!10}{3.90} & \cellcolor{gray!10}{2.620} & \cellcolor{gray!10}{16.46} & \cellcolor{gray!10}{0} & \cellcolor{gray!10}{1} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{4}\\
Mazda RX4 Wag & 21.0 & 6 & 160 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4\\
\cellcolor{gray!10}{Datsun 710} & \cellcolor{gray!10}{22.8} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{108} & \cellcolor{gray!10}{93} & \cellcolor{gray!10}{3.85} & \cellcolor{gray!10}{2.320} & \cellcolor{gray!10}{18.61} & \cellcolor{gray!10}{1} & \cellcolor{gray!10}{1} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{1}\\
Hornet 4 Drive & 21.4 & 6 & 258 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1\\
\cellcolor{gray!10}{Hornet Sportabout} & \cellcolor{gray!10}{18.7} & \cellcolor{gray!10}{8} & \cellcolor{gray!10}{360} & \cellcolor{gray!10}{175} & \cellcolor{gray!10}{3.15} & \cellcolor{gray!10}{3.440} & \cellcolor{gray!10}{17.02} & \cellcolor{gray!10}{0} & \cellcolor{gray!10}{0} & \cellcolor{gray!10}{3} & \cellcolor{gray!10}{2}\\
\addlinespace
Valiant & 18.1 & 6 & 225 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1\\
\bottomrule
\end{tabular}
\end{table}
When the \begin{table}
\caption{\label{tbl-cars}Some cars}
\centering{
[H]
\centering
\begin{tabular}[t]{l>{\raggedleft\arraybackslash}p{30em}rrrrrrrrrr}
\toprule
& mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb\\
\midrule
\cellcolor{gray!10}{Mazda RX4} & \cellcolor{gray!10}{21.0} & \cellcolor{gray!10}{6} & \cellcolor{gray!10}{160} & \cellcolor{gray!10}{110} & \cellcolor{gray!10}{3.90} & \cellcolor{gray!10}{2.620} & \cellcolor{gray!10}{16.46} & \cellcolor{gray!10}{0} & \cellcolor{gray!10}{1} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{4}\\
Mazda RX4 Wag & 21.0 & 6 & 160 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4\\
\cellcolor{gray!10}{Datsun 710} & \cellcolor{gray!10}{22.8} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{108} & \cellcolor{gray!10}{93} & \cellcolor{gray!10}{3.85} & \cellcolor{gray!10}{2.320} & \cellcolor{gray!10}{18.61} & \cellcolor{gray!10}{1} & \cellcolor{gray!10}{1} & \cellcolor{gray!10}{4} & \cellcolor{gray!10}{1}\\
Hornet 4 Drive & 21.4 & 6 & 258 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1\\
\cellcolor{gray!10}{Hornet Sportabout} & \cellcolor{gray!10}{18.7} & \cellcolor{gray!10}{8} & \cellcolor{gray!10}{360} & \cellcolor{gray!10}{175} & \cellcolor{gray!10}{3.15} & \cellcolor{gray!10}{3.440} & \cellcolor{gray!10}{17.02} & \cellcolor{gray!10}{0} & \cellcolor{gray!10}{0} & \cellcolor{gray!10}{3} & \cellcolor{gray!10}{2}\\
\addlinespace
Valiant & 18.1 & 6 & 225 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1\\
\bottomrule
\end{tabular}
}
\end{table}% So our caption insertion is somehow broken here. I though we fixed that previously, but it may have been something else... |
@cscheid I believe this is another occurences of
Our current regex used for floatref element quarto-cli/src/resources/filters/modules/patterns.lua Lines 38 to 41 in 163a059
covers less cases than our others one quarto-cli/src/resources/pandoc/datadir/init.lua Lines 1711 to 1712 in 163a059
Especially we don't cover options like
For the non floatref case we were doing more test I believe quarto-cli/src/resources/filters/quarto-pre/table-captions.lua Lines 170 to 175 in 163a059
quarto-cli/src/resources/filters/quarto-pre/table-captions.lua Lines 198 to 215 in 163a059
I believe the two patterns (one without options and one with options) was needed because default Lua patterns does not support a Maybe another library would help here, but I believe we need to match Reprex---
title: "Table"
format: pdf
keep-md: true
keep-tex: true
---
::: {#tbl-test}
```{=latex}
\begin{table}[H]
\centering
\begin{tabular}[t]{l|r|r|r|r|r|r|r|r|r|r|r}
\hline
& mpg & cyl & disp & hp & drat & wt & qsec & vs & am & gear & carb\\
\hline
Mazda RX4 & 21.0 & 6 & 160 & 110 & 3.90 & 2.620 & 16.46 & 0 & 1 & 4 & 4\\
\hline
Mazda RX4 Wag & 21.0 & 6 & 160 & 110 & 3.90 & 2.875 & 17.02 & 0 & 1 & 4 & 4\\
\hline
Datsun 710 & 22.8 & 4 & 108 & 93 & 3.85 & 2.320 & 18.61 & 1 & 1 & 4 & 1\\
\hline
Hornet 4 Drive & 21.4 & 6 & 258 & 110 & 3.08 & 3.215 & 19.44 & 1 & 0 & 3 & 1\\
\hline
Hornet Sportabout & 18.7 & 8 & 360 & 175 & 3.15 & 3.440 & 17.02 & 0 & 0 & 3 & 2\\
\hline
Valiant & 18.1 & 6 & 225 & 105 & 2.76 & 3.460 & 20.22 & 1 & 0 & 3 & 1\\
\hline
\end{tabular}
\end{table}
```
Caption
:::
|
I think we should do something more drastic starting in Quarto 1.6, which is that if a raw html block contains |
That's correct. |
Note, also, that we use
But we also use it here:
|
The more I look at this, the less I want to fix it. I think we should just encourage users to not use @bhattmaulik, the following will work for you:
|
Thank you @cscheid sir for this suggestion. I didn't know that
But when other users also had the same issue, the issue was re-opened at the kableExtra repository. After that, I decided to open a separate issue here. |
I also ran into this. It would also be good to add |
This is an instance of the discussion we had last week about limitations of our autocompletion/validation. The problem is that we support more than just In other words: yes, it's a bug. But fixing it is harder than it seems at first glance. |
Bug description
I am using Quarto to prepare a document. I want to render it as PDF/Latex document. In this document, I need some tables, which I am formatting using kableExtra package. I want to HOLD the position of the table, so that they don't appear on the next page. But when I add "HOLD_position" option in the kable_styling, it adds an extra [H] above the table. Interestingly, even if I have set tbl-cap-position below the table, this [H] remains above the table instead of moving with the caption.
A minimal example is given below.
I created an issue with the repository of kableExtra, thinking that it is an issue with the package. But from the comment in that issue, I realized that this issue doesn't happen if I use R Markdown document instead of Quarto. Therefore, I am creating a bug report here.
Steps to reproduce
Expected behavior
There should not be [H] in the table caption.
Actual behavior
There is an [H] written above the table.
Your environment
RSudio Version: 2024.04.0 Build 725, OS: Windows 11
Quarto check output
$ quarto
$ quarto check
Quarto 1.5.31
[>] Checking versions of quarto bin
ary dependencies...
Pandoc version 3.1.13: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[>] Checking versions of quarto dep
endencies......OK
[>] Checking Quarto installation...
...OK
Version: 1.5.31
Path: C:\Users\Hp\AppData\Loc
al\Programs\Quarto\bin
CodePage: 1252
[>] Checking tools.................
...OK
TinyTeX: (external install)
Chromium: (not installed)
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
(-) Checking LaTeX.................
...
() Checking LaTeX.................
...
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
(-) Checking LaTeX.................
...
() Checking LaTeX.................
...
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
(-) Checking LaTeX.................
...
() Checking LaTeX.................
...
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
(-) Checking LaTeX.................
...
() Checking LaTeX.................
...
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
(-) Checking LaTeX.................
...
() Checking LaTeX.................
...
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
(-) Checking LaTeX.................
...
() Checking LaTeX.................
...
(|) Checking LaTeX.................
...
(/) Checking LaTeX.................
...
[>] Checking LaTeX.................
...OK
Using: TinyTex
Path: C:\Users\Hp\AppData\Roa
ming\TinyTeX\bin\windows
Version: 2024
(|) Checking basic markdown render.
...
(/) Checking basic markdown render.
...
(-) Checking basic markdown render.
...
() Checking basic markdown render.
...
(|) Checking basic markdown render.
...
(/) Checking basic markdown render.
...
(-) Checking basic markdown render.
...
() Checking basic markdown render.
...
(|) Checking basic markdown render.
[>] Checking basic markdown render.
...OK
[>] Checking Python 3 installation.
...(None)
version of Python 3.
Install Python 3 from https:/
/www.python.org/downloads/
(|) Checking R installation........
...
(/) Checking R installation........
...
(-) Checking R installation........
...
[>] Checking R installation........
...OK
Version: 4.4.0
Path: C:/PROGRA
1/R/R-441.0LibPaths:
- C:/Users/Hp/AppData/Local
/R/win-library/4.4
- C:/Program Files/R/R-4.4.
0/library
knitr: 1.46
rmarkdown: 2.26
(|) Checking Knitr engine render...
...
(/) Checking Knitr engine render...
...
(-) Checking Knitr engine render...
...
() Checking Knitr engine render...
...
(|) Checking Knitr engine render...
...
(/) Checking Knitr engine render...
...
(-) Checking Knitr engine render...
...
() Checking Knitr engine render...
...
(|) Checking Knitr engine render...
...
(/) Checking Knitr engine render...
...
(-) Checking Knitr engine render...
...
() Checking Knitr engine render...
...
(|) Checking Knitr engine render...
...
(/) Checking Knitr engine render...
[>] Checking Knitr engine render...
...OK
The text was updated successfully, but these errors were encountered: