Using the table example from "Markdown Cheatsheet" on GitHub, you get this:
| Tables | Are | Cool | | ------------- |:-------------:| -----:| | col 3 is | right-aligned | $1600 | | col 2 is | centered | $12 | | zebra stripes | are neat | $1 |
My question is, is there any way to left-align the header cells?
Mark up the row and column header cells with <th> In all data tables, mark up each column and row header cell with the <th> tag. When a cell is essential to understand the data provided in the table, it must be marked up with <th> .
Tables are center-aligned by default when they are included in a table environment (i.e., when the table has a caption). If you do not want to center a table, use the argument centering = FALSE.
Unfortunately markdown does not support this.
It depends on which implementation you are using.
Tables are a non-standard feature of Markdown and each implementation which supports them does so differently. For example, the "cheetsheet" pointed to in the question is within the Markdown Here project. That project's Readme includes the following explanation:
To discover what can be done with Markdown in Markdown Here, check out the Markdown Here Cheatsheet and the other wiki pages.
So that "cheetsheet" is specific to the implementation used by Markdown Here.
GitHub has documented their implementation of Markdown as an extension of the Commonmark spec (Commonmark is a Markdown variant which does not support tables). According to example 192, the column headers receive the same alignment as the column cells:
| abc | defghi | :-: | -----------: bar | baz <table> <thead> <tr> <th align="center">abc</th> <th align="right">defghi</th> </tr> </thead> <tbody> <tr> <td align="center">bar</td> <td align="right">baz</td> </tr></tbody></table>
So, you need to check the specific implementation of Markdown you are using and read that implementation's documentation. However, personally, I have never come across an implementation which allows you to define separate alignment for the headers from the cells. In my experience, either you get headers which match the cells, or headers which have no alignment assigned.
Markdown:
| Tables | Are | Cool | |:------------- |:-------------:| -----:| | col 3 is | right-aligned | $1600 | | col 2 is | centered | $12 | | col 1 is | left-aligned | $42 | | zebra stripes | are neat | $1 |
Result:
Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | $1600 |
col 2 is | centered | $12 |
col 1 is | left-aligned | $42 |
zebra stripes | are neat | $1 |
Note that the colon (":") on the second row, and the second character is what worked to The other option is to move the numbers to the left-most column (as below)
Amount | Items ------:|:----- 20 | Wooden Boards 5 | Old Parts
Try it on StackEdit.
It does not seem to work putting the ---- line above the headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With