17

Is there a way to to specify the vertical alignment of table cell contents in markdown/pandoc?

Details:
The default behavior is center alignment, I want cell contents to be aligned to the top of the cell. For an example of the default behavior:

|           |               |
|-----------|---------------|
| Something | This is a very long line that breaks into two. This is a very long line that breaks into two.This is a very long line that breaks into two.This is a very long line that breaks into two.|

The contents of the left cell in the example above will be vertically-centered.

Mustafa
  • 1,814
  • 3
  • 17
  • 25
  • 2
    I hacked it by inserting `
    ` many times after `Something` until it appears at the top of the cell. I assume the same hack works *before* if you want it to go to the bottom.
    – Fuhrmanator Sep 30 '19 at 00:46

1 Answers1

12

Use multiline table syntax (supported by Pandoc only -- it is a Pandoc-specific extension of Markdown):

   -------------------------------------------------------------
    Centered   Default           Right Left
     Header    Aligned         Aligned Aligned
   ----------- ------- --------------- -------------------------
      First    row                12.0 Example of a row that
                                       spans multiple lines.

     Second    row                 5.0 Here's another one. Note
                                       the blank line between
                                       rows.
   -------------------------------------------------------------

   Table: Here's the caption. It, too, may span
   multiple lines.

Multiline tables allow headers and table rows to span multiple lines of text (but cells that span multiple columns or rows of the table are not supported).

These work like simple tables, but with the following differences:

  • They must begin with a row of dashes, before the header text (unless the headers are omitted).

  • They must end with a row of dashes, then a blank line.

  • The rows must be separated by blank lines.

In multiline tables, the table parser pays attention to the widths of the columns, and the writers try to reproduce these relative widths in the output. So, if you find that one of the columns is too narrow in the output, try widening it in the markdown source.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • 3
    Thanks Kurt. I want to reiterate your remark from your answer on my [other question](http://stackoverflow.com/questions/27219629/how-to-control-cell-width-in-pandoc-markdown-table), this solution does not necessarily work for HTML. – Mustafa Dec 02 '14 at 00:43
  • Yes, it does not work in HTML. Here an pandoc conversion from incomplete LaTeX http://tex.stackexchange.com/a/247003/13173 where it would be nice to be able to have relative table format. At the moment, the tables are quite narrow which takes a lot of pages. @Kurt Is there any method how you can have relative table size through HTML i.e. increase the horizontal width? I think the increase of the horizontal width is not going to work like here http://stackoverflow.com/q/27219629/54964 – Léo Léopold Hertz 준영 May 31 '15 at 08:18