Table layouts for use with Pandoc

I am trying to create a document creation workflow (professional documents). The goal is to write as much Markdown as possible. The final document must be PDF, and, if necessary, can be exported to .docx.

I settled on Pandoc, for which I will create a Latex template and use a YAML document to store the document metadata. So far, so good. However, from time to time I need to use tables, from very simple to more complex layouts, for example. column.

Markdown is hardly applicable to anything but the most basic tables. I tried HTML to define a more complex table layout, but it seems that Pandoc doesn't know how to handle columns or rows.

Couldn't fully define a table in Latex if there is any other alternative that makes it easy to maintain an approach to defining tables while still being able to convert from Pandoc to Latex / PDF?

An example of a more complex table (taken from here ):

<body>
<table border="1">

<!-- First row -->

<tr>
<td>1</td>
<td colspan="2">2 and 3</td>
<td>4</td>
</tr>

<!-- Second row -->

<tr>
<td rowspan="3">5, 9 and 13</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>

<!-- Third row -->

<tr>
<td>10</td>
<td>11</td>
<td>12</td>
</tr>

<!-- Fourth row -->

<tr>
<td colspan="3">14, 15 and 16</td>
</tr>

</table>
</body>
      

Run codeHide result


This is the PDF output:

PDF result

+3


source to share


2 answers


Indeed, Pandoc does not (currently) support col- or rowspans.



If you absolutely need cell spacing for multiple output formats, your best bet is to write your tables (inside pandoc markdown code blocks or <div class="table">

) in whatever format you want (like HTML or even reStructuredText ). Then you can write one pandoc filter that converts that part of the pandoc AST to HTML and another filter that converts it to LaTeX.

+1


source


From https://github.com/jgm/pandoc/wiki/Pandoc-vs-Multimarkdown :
"Pandoc pipe tables [...] don't have all the features of MMD pipe tables (sections, colspan, rowspan, grouping).



Hence, perhaps a workaround could be to process the (complex) tables in reStructuredText in separate files and then include them. These are just my 2 ยข, because I probably won't have to face this challenge until after a few weeks. If you find a solution, please submit it! I am very curious, welcomes!

+2


source







All Articles