Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandoc Does Not Parse Tabular With Itemize #3709

Closed
schrieveslaach opened this issue May 29, 2017 · 6 comments
Closed

Pandoc Does Not Parse Tabular With Itemize #3709

schrieveslaach opened this issue May 29, 2017 · 6 comments

Comments

@schrieveslaach
Copy link
Contributor

The current pandoc dev version does not parse tabular environments if they contains an itemize environment. For example:

\begin{tabular}{cc}
    A & B \\
    C & D \begin{itemize}
    \item 1                                     
    \item 2 
    \item 3
    \item 4 
    \item 5 
  \end{itemize}
\end{tabular}

Pandoc produces following output:

[warning] Skipped '\begin{tabular}' at line 1 column 16
[warning] Skipped '\end{tabular}' at line 10 column 14
<p><span>cc</span> A &amp; B<br />
C &amp; D</p>
<ul>
<li><p>1</p></li>
<li><p>2</p></li>
<li><p>3</p></li>
<li><p>4</p></li>
<li><p>5</p></li>
</ul>

However, pandoc should produce following output:

<table>
<tbody>
<tr class="odd">
<td style="text-align: center;">A</td>
<td style="text-align: center;">B</td>
</tr>
<tr class="even">
<td style="text-align: center;">C</td>
<td style="text-align: center;">D <ul>
<li><p>1</p></li>
<li><p>2</p></li>
<li><p>3</p></li>
<li><p>4</p></li>
<li><p>5</p></li>
</ul>
</td>
</tr>
</tbody>
</table>
@jgm
Copy link
Owner

jgm commented May 29, 2017

Yes, so far we only have simpTable, which parses simple tables (no relative widths, no block structure in cells). To allow things like lists in cells, we'd also need relative widths.

@jgm
Copy link
Owner

jgm commented May 29, 2017

Did you try compiling that snippet with pdflatex?
When I try, I get an error - "! LaTeX Error: Something's wrong--perhaps a missing \item" at line 8 "\item 1".
When I enclose the itemize environment in a minipage environment, it works fine -- and pandoc handles that case fine too.

If this is invalid LaTeX, then it's not a problem with pandoc.

@jgm
Copy link
Owner

jgm commented May 30, 2017

Closing this, but feel free to comment if you think there's a mistake.

@jgm jgm closed this as completed May 30, 2017
@schrieveslaach
Copy link
Contributor Author

Sorry, I made a mistake in the example. When you specifc p as column type, itemize environments are allowed in tabular. Here is a full example:

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\begin{document}

\begin{tabular}{|c|p{0.9\linewidth}|}
  \hline
    A & B \\
  \hline
    C & D \begin{itemize}
      \item 1                                     
      \item 2 
      \item 3
      \item 4 
      \item 5 
    \end{itemize} \\
  \hline
\end{tabular}

\end{document}

The PDF looks like this:

bildschirmfoto von 2017-05-30 10-04-11

@schrieveslaach
Copy link
Contributor Author

I also tested your solution with minipage, see following example:

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\begin{document}

\begin{tabular}{|c|c|}
  \hline
    A & B \\
  \hline
    C & \begin{minipage}{0.9\linewidth}
      D \begin{itemize}
      \item 1                                     
      \item 2 
      \item 3
      \item 4 
      \item 5 
    \end{itemize}
    \end{minipage} \\
  \hline
\end{tabular}

\end{document}

However, pandoc produces:

[warning] Could not load include file 'inputenc.sty' at line 3 column 28
[warning] Skipped '\hline
! ' at line 8 column 1
[warning] Skipped '\hline
! ' at line 10 column 1
[warning] Skipped '\hline
! ' at line 20 column 1
[warning] Skipped '\begin{tabular}' at line 6 column 16
[warning] Skipped '\end{tabular}' at line 20 column 14
<p><span>|c|c|</span> A &amp; B<br />
C &amp;</p>
<p>D</p>
<ul>
<li><p>1</p></li>
<li><p>2</p></li>
<li><p>3</p></li>
<li><p>4</p></li>
<li><p>5</p></li>
</ul>
<p><br />
</p>

@schrieveslaach
Copy link
Contributor Author

pandoc 1.19.2.1 is able to parse the minipage example. Not the dev version (see previous post). Here is the ouput of 1.19.2.1

[user@host ~]$ pandoc --version
pandoc 1.19.2.1
Compiled with pandoc-types 1.17.0.5, texmath 0.9.4, skylighting 0.1.1.5
Default user data directory: /home/marc/.pandoc
Copyright (C) 2006-2016 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
[user@host ~]$ pandoc -f latex -t html /tmp/t.tex
<table>
<thead>
<tr class="header">
<th align="center">A</th>
<th align="center">B</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">C</td>
<td align="center"><p>D</p>
<ul>
<li><p>1</p></li>
<li><p>2</p></li>
<li><p>3</p></li>
<li><p>4</p></li>
<li><p>5</p></li>
</ul></td>
</tr>
</tbody>
</table>

@jgm jgm reopened this Jun 1, 2017
@jgm jgm closed this as completed in 1e7ba5c Jun 1, 2017
jgm added a commit that referenced this issue Jun 1, 2017
Currently we only handle the form `0.9\linewidth`.
Anything else would have to be converted to a percentage,
using some kind arbitrary assumptions about line widths.

See #3709.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants