jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.63k stars 3.38k forks source link

Pandoc not rendering table cell overflow right #6174

Closed gijsentius closed 4 years ago

gijsentius commented 4 years ago

Hi,

I encountered a strange behaviour when I updated from pandoc 1.19.2.4 to 2.9.2. The reason for using an older version was, because I simply installed pandoc via apt.

Pandoc is since the update creating strange tables. The tables overflow the document width. A preview of this behaviour is shown in the figures below.

Good behaviour:

table_g

Bad behaviour:

table_b

As shown the table source markdown was not changed. The source code is the following:

| Bruikbaarheidseigenschap | Omschrijving |
|----------|-------------------------------------------------------|
| Appropriateness recognisability | De mate waarin de gebruiker herkent welke oplossingen er met een taal zijn voor een probleem |
| Learnability                    | De mate van leerbaarheid van de taal en bijbehorende frameworks |
| Operability                     | de mate waarin een taal gemakkelijk te gebruiken en controleren is |  
| User error protection           | De mate waarin een taal de gebruiker beschermd tegen het maken van fouten |
| User interface aesthetics       | De mate waarin de syntax van de taal prettig is om te lezen |
| Accessibility                   | De mate waarin verschillende programmeurs met dezelfde taal om kunnen gaan |

I use the eisvogel template from https://github.com/Wandmalfarbe/pandoc-latex-template. I checked the git versioning from my project and it shows I did not change anything in the template that has an impact on the tables. I checked this by using the same template in both versions of pandoc and it only showed the strange table with the newer version of pandoc.

I hope we can solve this strange behaviour with the information I provided.

Cheers,

Gijs

mb21 commented 4 years ago

maybe you can do -t latex to see what's the difference between the old and new output?

gijsentius commented 4 years ago

Hi mb21,

I was already planning to do a compare. I added the results below.

This is the output from pandoc 2.9.2.

\hypertarget{tbl:bruikbaarheid}{}
\begin{longtable}[]{@{}ll@{}}
\caption{\label{tbl:bruikbaarheid}Bruikbaarheidseigenschappen van een
programmeertaal.}\tabularnewline
\toprule
\begin{minipage}[b]{0.24\columnwidth}\raggedright
Bruikbaarheidseigenschap\strut
\end{minipage} & \begin{minipage}[b]{0.70\columnwidth}\raggedright
Omschrijving\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.24\columnwidth}\raggedright
Bruikbaarheidseigenschap\strut
\end{minipage} & \begin{minipage}[b]{0.70\columnwidth}\raggedright
Omschrijving\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.24\columnwidth}\raggedright
Appropriateness recognisability\strut
\end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
De mate waarin de gebruiker herkent welke oplossingen er met een taal
zijn voor een probleem\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.24\columnwidth}\raggedright
Learnability\strut
\end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
De mate van leerbaarheid van de taal en bijbehorende frameworks\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.24\columnwidth}\raggedright
Operability\strut
\end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
de mate waarin een taal gemakkelijk te gebruiken en controleren is\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.24\columnwidth}\raggedright
User error protection\strut
\end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
De mate waarin een taal de gebruiker beschermd tegen het maken van
fouten\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.24\columnwidth}\raggedright
User interface aesthetics\strut
\end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
De mate waarin de syntax van de taal prettig is om te lezen\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.24\columnwidth}\raggedright
Accessibility\strut
\end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
De mate waarin verschillende programmeurs met dezelfde taal om kunnen
gaan\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

This is the output from pandoc 1.19.2.4

\begin{longtable}[]{@{}ll@{}}
\caption{Bruikbaarheidseigenschappen van een programmeertaal.
\{\#tbl:bruikbaarheid\}}\tabularnewline
\toprule
\begin{minipage}[b]{0.14\columnwidth}\raggedright\strut
Bruikbaarheidseigenschap\strut
\end{minipage} & \begin{minipage}[b]{0.73\columnwidth}\raggedright\strut
Omschrijving\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.14\columnwidth}\raggedright\strut
Bruikbaarheidseigenschap\strut
\end{minipage} & \begin{minipage}[b]{0.73\columnwidth}\raggedright\strut
Omschrijving\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
Appropriateness recognisability\strut
\end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
De mate waarin de gebruiker herkent welke oplossingen er met een taal
zijn voor een probleem\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
Learnability\strut
\end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
De mate van leerbaarheid van de taal en bijbehorende frameworks\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
Operability\strut
\end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
de mate waarin een taal gemakkelijk te gebruiken en controleren is\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
User error protection\strut
\end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
De mate waarin een taal de gebruiker beschermd tegen het maken van
fouten\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
User interface aesthetics\strut
\end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
De mate waarin de syntax van de taal prettig is om te lezen\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
Accessibility\strut
\end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
De mate waarin verschillende programmeurs met dezelfde taal om kunnen
gaan\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

I also added a diff from the two files

0a1
> \hypertarget{tbl:bruikbaarheid}{}
2,3c3,4
< \caption{Bruikbaarheidseigenschappen van een programmeertaal.
< \{\#tbl:bruikbaarheid\}}\tabularnewline
---
> \caption{\label{tbl:bruikbaarheid}Bruikbaarheidseigenschappen van een
> programmeertaal.}\tabularnewline
5c6
< \begin{minipage}[b]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[b]{0.24\columnwidth}\raggedright
7c8
< \end{minipage} & \begin{minipage}[b]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[b]{0.70\columnwidth}\raggedright
13c14
< \begin{minipage}[b]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[b]{0.24\columnwidth}\raggedright
15c16
< \end{minipage} & \begin{minipage}[b]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[b]{0.70\columnwidth}\raggedright
20c21
< \begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[t]{0.24\columnwidth}\raggedright
22c23
< \end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
26c27
< \begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[t]{0.24\columnwidth}\raggedright
28c29
< \end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
31c32
< \begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[t]{0.24\columnwidth}\raggedright
33c34
< \end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
36c37
< \begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[t]{0.24\columnwidth}\raggedright
38c39
< \end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
42c43
< \begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[t]{0.24\columnwidth}\raggedright
44c45
< \end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright
47c48
< \begin{minipage}[t]{0.14\columnwidth}\raggedright\strut
---
> \begin{minipage}[t]{0.24\columnwidth}\raggedright
49c50
< \end{minipage} & \begin{minipage}[t]{0.73\columnwidth}\raggedright\strut
---
> \end{minipage} & \begin{minipage}[t]{0.70\columnwidth}\raggedright

The tex files are clearly different, and I don't understand why? The only difference is the pandoc version used.

The reason I can't keep using pandoc 1.19.2.4 is, because I want to start using pandoc-crossref adn the latests release of pandoc-crossref is build with pandoc 2.9.

jgm commented 4 years ago

Have you read this from the manual?

If a pipe table contains a row whose printable content is wider than the column width (see --columns), then the table will take up the full text width and the cell contents will wrap, with the relative cell widths determined by the number of dashes in the line separating the table header from the table body. (For example ---|- would make the first column 3/4 and the second column 1/4 of the full text width.) On the other hand, if no lines are wider than column width, then cell contents will not be wrapped, and the cells will be sized to their contents.

This should point toward a solution; you should be able to adjust the separator line widths to make it work better. It also matters what the default width is (set this with --columns).

gijsentius commented 4 years ago

Thank you for your reply. I have read the manual and tested if this was the solution. The actual problem is about the wrapping and the table width. With the previous pandoc version if I used a wrong number of dashes the tables were too small, but would never override the textwidth. The table will override the text width of the page. The table caption is also acting strange because it has a tab to the left without a reason.

Furthermore the problem only occurs when using pandoc 2.9.2 with the older 1.19 I had no issues whatsoever. Even with other table format the problem occurs.

Do you know why the beviour changed with the newer pandoc version?

jgm commented 4 years ago

Well, the main change is the one I pointed to in my comment (as described in the manual). When the table contents are wide (as in your case), the relative widths of the separator lines (relative to --columns width) determine the widths of the columns. In this case you've evidently specified too narrow a width for the first column; the very long words there don't have enough room so they run into the next column, overlapping it. Try increasing this width (using more dashes in |----------| and fewer for the next column).

By the way, here's what I see when I compile your document (adding a caption and a paragraph for comparison) using the latest version of eisvogel template:

Screen Shot 2020-03-09 at 10 05 37 AM

The only problem here is the overlap (which I've explained above). The table does not exceed the text width. The caption is not indented. If you're seeing that, I'm not sure why, but you'll need to provide fuller instructions for reproducing (exact input and exact command).

gijsentius commented 4 years ago

Thank you again for your explanation! I have tested again with a similar input as you did, and I found the problem. In a clean markdown file with a table the problem does not exists indeed. I included a tex file in my project and that was causing the problem. The tex file was just text, but I will solve this problem by myself, because it has nothing to do with pandoc, except for it to only occur with the newer version of pandoc.