Skip to content

Converting pipe tables into LaTeX #2626

Closed
vancleve opened this Issue · 2 comments

2 participants

@vancleve

I have some pipe tables with some long rows and when they get converted to LaTeX, the columns widths add up to more than one, resulting in the table extending into and beyond the margin of the page.

I can reproduce the behavior for even a small table with the --columns argument set small enough. For example, if test.md is:

| test  | header | row    |
|-------+--------+--------|
| first | row    | elemnt |

Then running

pandoc test.md --columns=12 -t latex

yields

\begin{longtable}[c]{@{}lll@{}}
\toprule
\begin{minipage}[b]{0.61\columnwidth}\raggedright\strut
test
\strut\end{minipage}
&
\begin{minipage}[b]{0.68\columnwidth}\raggedright\strut
header
\strut\end{minipage}
&
\begin{minipage}[b]{0.68\columnwidth}\raggedright\strut
row
\strut\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.61\columnwidth}\raggedright\strut
first
\strut\end{minipage}
&
\begin{minipage}[t]{0.68\columnwidth}\raggedright\strut
row
\strut\end{minipage}
&
\begin{minipage}[t]{0.68\columnwidth}\raggedright\strut
elemnt
\strut\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

where the columns widths in a row sum to more than one \columnwidth. In fact, narowing the
--columns make the problem worse:

pandoc test.md --columns=10 -t latex

produces

\begin{longtable}[c]{@{}lll@{}}
\toprule
\begin{minipage}[b]{0.73\columnwidth}\raggedright\strut
test
\strut\end{minipage}
&
\begin{minipage}[b]{0.82\columnwidth}\raggedright\strut
header
\strut\end{minipage}
&
\begin{minipage}[b]{0.82\columnwidth}\raggedright\strut
row
\strut\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
first
\strut\end{minipage}
&
\begin{minipage}[t]{0.82\columnwidth}\raggedright\strut
row
\strut\end{minipage}
&
\begin{minipage}[t]{0.82\columnwidth}\raggedright\strut
elemnt
\strut\end{minipage}\tabularnewline
\bottomrule
\end{longtable}
@jgm
Owner
@jgm jgm closed this in c4fdf28
@vancleve

Thanks @jgm! Tables look great after this change!

@c-forster c-forster pushed a commit to c-forster/pandoc that referenced this issue
@jgm Markdown reader: renormalize table column widths if they exceed 100%.
Closes #2626.
c15924a
@c-forster c-forster pushed a commit to c-forster/pandoc that referenced this issue
@jgm Markdown reader: renormalize table column widths if they exceed 100%.
Closes #2626.
3a5bd68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.