Open rmnldwg opened 6 months ago
Thanks for the report.
I think the reason is that the LaTeX code contains multirow commands that look like this: \multirow{2}{=}{foo}, because when I use \multirow{2}*{foo}, then the table looks nice.
I don't know exactly for the specific with Quarto but regarding this generated latex, I believe this is directly Pandoc https://github.com/jgm/pandoc/blob/32280fd919ca2bdba27b5beff9182d8691eb6c1d/src/Text/Pandoc/Writers/LaTeX/Table.hs#L359C1-L364C53
They do use =
only with no option for *
Here is an example with a HTML table having a rowspan
attribute (like the one created with the python code above)
> quarto pandoc -t latex -f html
<table>
<tr>
<th>Month</th>
<th>Savings</th>
<th>Savings for holiday!</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
<td rowspan="2">$50</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
^Z
\begin{longtable}[]{@{}lll@{}}
\toprule\noalign{}
Month & Savings & Savings for holiday! \\
\midrule\noalign{}
\endhead
\bottomrule\noalign{}
\endlastfoot
January & \$100 & \multirow{2}{=}{\$50} \\
February & \$80 \\
\end{longtable}
It creates in Latex a \multirow{2}{=}{\$50
with the =
Using this in a document will also make the table spread along...
---
title: "Test Title"
format:
pdf:
keep-tex: true
keep-md: true
---
```{=html}
<table>
<tr>
<th>Month</th>
<th>Savings</th>
<th>Savings for holiday!</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
<td rowspan="2">$50</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
![image](https://github.com/quarto-dev/quarto-cli/assets/6791940/f6e52a6a-4bb8-4f09-a74d-1947a26f8c58)
I think they uses `=` to get the column width (from https://texlive.mycozy.space/macros/latex/contrib/multirow/multirow.pdf)
> (width) is the width to which the text is to be set. Special values are * to indicate that the text parameter's natural width is to be used, and = to indicate that the specified width of the column in which the \multirow entry is set should be used.
So this is probably something related to how Pandoc convert to LaTeX or something due to our own processing...
- If the former, then this should be a report in Pandoc so that they allow `*` in some case.
- If the latter, not sure what yet 🤔
It seems to me there could be some problem in column width handling in pandoc for multiline table when `ColWidthDefault` is used with the writer.
I am facing the same issue and would appreciate a fix or workaround.
Bug description
When using pandas to create tables with a multi-index, Quarto uses the
\multirow
LaTeX command to display that in the PDF. However, the resulting columns are far too wide.I think the reason is that the LaTeX code contains multirow commands that look like this:
\multirow{2}{=}{foo}
, because when I use\multirow{2}*{foo}
, then the table looks nice.Steps to reproduce
With an installation of Python 3.10 and pandas 2.2.1, compile the below document to PDF via
quarto render test.qmd --to pdf
. The command runs without any errors or warnings.Expected behavior
The table should fit on the page, as in this screenshot:
Actual behavior
All columns are stretched wide and the table extends beyond the right side of the page. See this screenshot:
Your environment
Quarto check output