Skip to content

pipe_tables overflow the page width for PDF output #2471

Closed
ndaniel opened this Issue · 7 comments

3 participants

@ndaniel

pipe_tables overflow the page width for PDF output!

multiline_tables do not overflow the page width in PDF output! This is/should-be the expected behavior for every table types (e.g. pipe_tables, multiline_tables, grid_tables, simple_tables)!

Also, the default assumption for pipe_tables when fitting a table into page's width is that all its column have the same width.

@adunning

Would you mind providing a minimal example showing the command you used and your input?

@jgm
Owner
@ndaniel

Here is an example example.md of what I mean.

Please, keep in mind that this is an example and it is not a case which I have. Therefore fixing this example does not solve the bug which I submitted!

In order to fit a table one may change the paper type from A4 to A3 from example but still there is need that the table auto-fits within the page.

@jgm
Owner

I think this is going to have to be a "don't fix" for the reason
I gave in my comment above. With LaTeX tables you either
specify the column width explicitly, or it won't wrap. If we specify
the width explicitly, the only rational choice is the textwidth divided
by the number of columns. But this will lead to bad results on
must pipe tables, since it will make all pipe tables, even tiny ones,
render as wide as the page. So it's better to keep things as they are.

Thinking of other possibilities:

(1) One might be to use a different LaTeX table package,
if there is one that has more HTML-like behavior (automatically
wrapping without explicit column width specifications). I'm open
to considering this, but (a) I want to avoid depending on uncommon
packages, and (b) I want to allow tables longer than a page (which
longtable allows).

(2) Another possibility would be for pandoc to estimate, based on table
cell contents, whether the table is likely to overflow textwidth, and set
explicit column widths if it thinks it will. The problem is that this estimation
is going to be pretty unreliable, as pandoc lacks a lot of the information
that LaTeX would use in determining widths.

@ndaniel

I think this is going to have to be a "don't fix" for the reason
I gave in my comment above. With LaTeX tables you either
specify the column width explicitly, or it won't wrap. If we specify
the width explicitly, the only rational choice is the textwidth divided
by the number of columns. But this will lead to bad results on
must pipe tables, since it will make all pipe tables, even tiny ones,
render as wide as the page. So it's better to keep things as they are.

The idea is to have some kind of command line option for pandoc which would force the pipe tables (or other types of tables) to be treated (from alignment and style point of view) like multiline tables (instead of user converting manually all its tables from pipes to multiline tables). Of course the conversion of pipe tables to multiline tables would be a lossy one (i.e. all columns have the same width and the table width will be the page width). As I have shown in my example, already pandoc is (almost) able to convert pipe tables to "multilines" tables (and extra small hacking) when converting from markdown to markdown.

(1) One might be to use a different LaTeX table package,..

There is no need for this. See above!

(2) Another possibility would be for pandoc to estimate, based on table
cell contents, whether the table is likely to overflow textwidth, and set
explicit column widths if it thinks it will. The problem is that this estimation
is going to be pretty unreliable, as pandoc lacks a lot of the information
that LaTeX would use in determining widths.

An idea here would be for pipe tables to use this line:

|:---|----|--------|------------|

in order to specify the columns widths (i.e. first column and second column have the same width, the third column is twice wider than first column, and fourth column is three times wider than first column).

@jgm
Owner
@jgm jgm added a commit that closed this issue
@jgm Pipe tables with long lines now get relative cell widths.
If a pipe table contains a line longer than the column
width (as set by `--columns` or 80 by default), relative
widths are computed based on the widths of the separator lines
relative to the column width.

This should solve persistent problems with long pipe tables in
LaTeX/PDF output, and give more flexibility for determining
relative column widths in other formats, too.

For narrower pipe tables, column widths of 0 are used,
telling pandoc not to specify widths explicitly in output
formats that permit this.

Closes #2471.
eb8aee4
@jgm jgm closed this in eb8aee4
@ndaniel

Thanks! It works great in pandoc 1.15.1.1 (Compiled with texmath 0.8.4, highlighting-kate 0.6.).

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.