ickc / pantable

CSV Tables in Markdown: Pandoc Filter for CSV Tables
https://ickc.github.io/pantable/
BSD 3-Clause "New" or "Revised" License
86 stars 15 forks source link

image link in a table cell makes error at pdf output #20

Closed K4zuki closed 7 years ago

K4zuki commented 7 years ago

Description

  1. When adding some image(s) in a table cell, no matter external file or code block, pandoc raises error and fails to output pdf.
$ pandoc markdown.md -t latex --filter=pantable -o pdf.pdf
! Misplaced \noalign.
\caption ->\noalign
                    \bgroup \@ifnextchar [{\egroup \LT@c@ption \@firstofone ...
l.132 \caption
pandoc: Error producing PDF
  1. Tested if latex output differs by filtering: pantable generated source is not identical to inline table
    • $ pandoc markdown.md -t latex --latex-engine=xelatex --filter=pantable -o latex.tex
    • $ pandoc markdown.md -t latex --latex-engine=xelatex -o latex2.tex
$ diff latex.tex latex2.tex
...
> \begin{longtable}[]{@{}ll@{}}
> \caption{CAPTION}\tabularnewline
> \toprule
> \begin{minipage}[b]{0.24\columnwidth}\raggedright\strut
> image\strut
> \end{minipage} & \begin{minipage}[b]{0.71\columnwidth}\raggedright\strut
> \begin{figure}
> \centering
> \includegraphics{./png.png}
> \caption{caption}
> \end{figure}
> \strut
> \end{minipage}\tabularnewline
...

From the diff the filtered latex contains \begin{figure}...\end{figure} block while inline does not. Can you confirm if this is a bug in pantable/panflute or pandoc itself?


Source files

png.png

png.png

csv.csv

image,![caption](./png.png)
text,this is a text
,foo
bar,

markdown.md

# include image by standard way

![caption](./png.png)

# include image in inline grid table

Table: CAPTION

+-------+-----------------------+
| image | ![caption](./png.png) |
+=======+=======================+
| text  | this is a text        |
+-------+-----------------------+
|       | foo                   |
+-------+-----------------------+
| bar   |                       |
+-------+-----------------------+

# include image in grid table generated by pantable

```table
---
# table-width:
header: True
markdown: True
caption: CAPTION
include: csv.csv
---

source files

commands

  1. pandoc markdown.md -t html --filter=pantable -o html.html
  2. pandoc markdown.md -t latex --latex-engine=xelatex --filter=pantable -o latex.tex
  3. pandoc markdown.md -t latex --latex-engine=xelatex -o latex2.tex
  4. pandoc markdown.md -t latex --latex-engine=xelatex --filter=pantable -o pdf.pdf
  5. pandoc markdown.md -t latex --latex-engine=xelatex -o pdf.pdf
ickc commented 7 years ago

It's an upstream bug. See jgm/pandoc#3836.

ickc commented 7 years ago

@K4zuki, it's fixed in https://github.com/jgm/pandoc/commit/3504915e63c68c3a4e91b8dcccb90c93435cf212

I verified this works using https://github.com/pandoc-extras/pandoc-nightly/releases/latest

either wait for the next release of use pandoc-nightly for the meanwhile (which might have unstable features though.)

K4zuki commented 7 years ago

@ickc Thank you for the help and information! I can wait for a while till next pandoc release.