1

I am trying to create a table where certain cells may contain more than one line or paragraph. I am creating my document in markdown and using pandoc to convert it to other formats which would be the ones disseminated.

The Pandoc User Guide mentions that "grid tables" support multiple paragraphs and even lists and I think that fits my requirements. However, the user guide mentions that the "grid tables" features requires lining up the columns like in the following example:

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | $1.34         | - built-in wrapper |
|               |               | - bright color     |
+---------------+---------------+--------------------+
| Oranges       | $2.10         | - cures scurvy     |
|               |               | - tasty            |
+---------------+---------------+--------------------+

If the pipe characters do not line up over the rows then the table is not rendered correctly. My problem is that my entries in each cell are lengthy and of variable length. So it is impossible for me to be able to line up the pipe characters. Is there any other way in markdown to create tables where cells can contain multiple lines and paras that renders correctly in other formats?

tarleb
  • 19,863
  • 4
  • 51
  • 80
sghosh
  • 11
  • 1
  • "it is impossible for me to be able to line up the pipe characters." impossible is a bit of a strong word? Unless you want to use a pandoc filter, grid tables are your only option. – mb21 Jan 17 '21 at 08:38

1 Answers1

0

Within the bounds of pure pandoc Markdown, grid tables are really the only option. They always require proper cell alignment.

An alternative would be to make use of pandoc filters. For example, a good Markdown-based solution is pandoc-list-table, which allows to define tables as nested lists.

Example from the README:

:::lol2table
*   -   foo
    -   bar
    -   baz
*   -   +   tic
        +   pic
    -   +   tac
        +   pac
:::

becomes equivalent to

+---------+---------+-----+
| foo     | bar     | baz |
+=========+=========+=====+
| -   tic | -   tac |     |
| -   pic | -   pac |     |
+---------+---------+-----+
tarleb
  • 19,863
  • 4
  • 51
  • 80