@@ -612,10 +612,14 @@ graph TD;
612
612
613
613
# Tables {#sec: tables }
614
614
615
- We support two notation styles for tables: Markdown and HTML .
615
+ We support several notation styles for tables.
616
616
617
617
## Markdown Tables
618
618
619
+ There are several ways to write a table in Markdown.
620
+
621
+ ### Simple Markdown Tables {#sec: simple-markdown-tables }
622
+
619
623
Small, simple tables like @tbl : shapes are easier to read in raw Markdown form in the following style:
620
624
621
625
``` md
@@ -636,69 +640,186 @@ Table: Shapes {#tbl:shapes}
636
640
| Triangle | 3 |
637
641
| Möbius strip | 1 |
638
642
643
+ Note the table caption and cross-reference in curly braces above the table.
639
644
645
+ ### Multiline Markdown Tables {#sec: multiline-markdown-tables }
640
646
641
- Note the table caption and cross-reference in curly braces above the table.
647
+ Sometimes, you may need to write a lot of Markdown content in the cell of a table,
648
+ and this content may need multiple lines in your editor.
642
649
643
- ## HTML Tables
650
+ ``` md
651
+ Table: Table Types {#tbl:table-types}
652
+
653
+ -------------------------------------------------------------------------------
654
+ **Table Kind** **Easy?** **Recommended?** **References**
655
+ --------------- ----------- ------------------- -------------------------------
656
+ Simple Yes When each cell @sec:simple-markdown-tables,
657
+ Markdown is about one @tbl:shapes
658
+ Tables word or so.
659
+
660
+ Multiline Yes When you have @sec:multiline-markdown-tables,
661
+ Markdown content that's @tbl:table-types
662
+ Tables more than a few
663
+ words.
664
+
665
+ Grid Markdown No When you have @sec:grid-tables,
666
+ Tables row or column @tbl:fruits-grid
667
+ spans and need
668
+ full Markdown
669
+ support (e.g.,
670
+ crossrefs or
671
+ equations).
672
+
673
+ HTML Yes When you have @sec:html-tables,
674
+ Tables row or column @tbl:fruits-html
675
+ spans, and
676
+ don't need
677
+ full Markdown
678
+ or don't mind
679
+ doing all the
680
+ styling in
681
+ HTML.
682
+ -------------------------------------------------------------------------------
683
+ ```
684
+
685
+ Table: Table Types {#tbl: table-types }
686
+
687
+ -------------------------------------------------------------------------------
688
+ ** Table Kind** ** Easy?** ** Recommended?** ** References**
689
+ --------------- ----------- ------------------- -------------------------------
690
+ Simple Yes When each cell @sec : simple-markdown-tables ,
691
+ Markdown is about one @tbl : shapes
692
+ Tables word or so.
693
+
694
+ Multiline Yes When you have @sec : multiline-markdown-tables ,
695
+ Markdown content that's @tbl : table-types
696
+ Tables more than a few
697
+ words.
698
+
699
+ Grid Markdown No When you have @sec : grid-tables ,
700
+ Tables row or column @tbl : fruits-grid
701
+ spans and need
702
+ full Markdown
703
+ support (e.g.,
704
+ crossrefs or
705
+ equations).
706
+
707
+ HTML Yes When you have @sec : html-tables ,
708
+ Tables row or column @tbl : fruits-html
709
+ spans, and
710
+ don't need
711
+ full Markdown
712
+ or don't mind
713
+ doing all the
714
+ styling in
715
+ HTML.
716
+ -------------------------------------------------------------------------------
717
+
718
+ ### Grid Tables {#sec: grid-tables }
719
+
720
+ You may have some data that needs to be presented in a table that allows you
721
+ to make cells span rows or columns. Grid tables like @tbl : fruits-grid can be
722
+ used for this. Note that editing these tables requires a bit more typing. It's
723
+ recommended to use these only when you need row and column spanning.
724
+
725
+ Some tools provide assistance for generating tables of this type. If you find
726
+ a tool that is handy for editing Markdown grid-style tables, please send a PR
727
+ to github.com/trustedcomputinggroup/pandoc!
644
728
645
- For larger, or more complex tables like @tbl : fruits , it may be preferable to use HTML. If you want to make
646
- table cells span rows or columns, this is the only way to do it.
729
+ ``` md
730
+ Table: Fruits (Pipe) {#tbl:fruits-grid}
731
+
732
+ +----------------------+----------------------------+
733
+ | **Color and Fruit** | **Mistaken for Vegetable** |
734
+ +=============+========+============================+
735
+ | | Red | No |
736
+ | Apple +--------+----------------------------+
737
+ | | Green | No |
738
+ +-------------+--------+----------------------------+
739
+ | Tomato | Red | Yes |
740
+ +-------------+--------+----------------------------+
741
+ | Banana | Yellow | No |
742
+ +-------------+--------+----------------------------+
743
+ ```
744
+
745
+ Table: Fruits (Pipe) {#tbl: fruits-grid }
746
+
747
+ +----------------------+----------------------------+
748
+ | ** Color and Fruit** | ** Mistaken for Vegetable** |
749
+ +=============+========+============================+
750
+ | | Red | No |
751
+ | Apple +--------+----------------------------+
752
+ | | Green | No |
753
+ +-------------+--------+----------------------------+
754
+ | Tomato | Red | Yes |
755
+ +-------------+--------+----------------------------+
756
+ | Banana | Yellow | No |
757
+ +-------------+--------+----------------------------+
758
+
759
+
760
+ ## HTML Tables {#sec: html-tables }
761
+
762
+ A rowspan/colspan table like @tbl : fruits-pipe can be implemented in HTML like
763
+ the below. Note that this is a little easier to type, and a little harder to
764
+ read in plain-text form. We recommend preferring [ grid tables] ( #sec:grid-tables )
765
+ to HTML tables, but HTML tables can be fine in certain situations (for example,
766
+ a gradual migration away from a Word document using Pandoc, which typically
767
+ converts Word tables into HTML).
647
768
648
769
``` md
649
- <table id="tbl:fruits">
650
- <caption>Fruits</caption>
770
+ <table id="tbl:fruits-html ">
771
+ <caption>Fruits (HTML) </caption>
651
772
<tr>
652
- <th colspan="2">Color and Fruit</th>
653
- <th>Mistaken for Vegetable</th>
773
+ <th colspan="2"><strong> Color and Fruit</strong> </th>
774
+ <th><strong> Mistaken for Vegetable</strong> </th>
654
775
</tr>
655
776
<tr>
656
- <td>Red</td>
657
777
<td rowspan="2">Apple</td>
778
+ <td>Red</td>
658
779
<td>No</td>
659
780
</tr>
660
781
<tr>
661
782
<td>Green</td>
662
783
<td>No</td>
663
784
</tr>
664
785
<tr>
665
- <td>Red</td>
666
786
<td>Tomato</td>
787
+ <td>Red</td>
667
788
<td>Yes</td>
668
789
</tr>
669
790
<tr>
670
- <td>Yellow</td>
671
791
<td>Banana</td>
792
+ <td>Yellow</td>
672
793
<td>No</td>
673
794
</tr>
674
795
</table>
675
796
```
676
797
677
798
The above HTML table becomes the below:
678
799
679
- <table id =" tbl:fruits " >
680
- <caption>Fruits</caption>
800
+ <table id =" tbl:fruits-html " >
801
+ <caption>Fruits (HTML) </caption>
681
802
<tr>
682
- <th colspan="2">Color and Fruit</th>
683
- <th>Mistaken for Vegetable</th>
803
+ <th colspan="2"><strong> Color and Fruit</strong> </th>
804
+ <th><strong> Mistaken for Vegetable</strong> </th>
684
805
</tr>
685
806
<tr>
686
- <td>Red</td>
687
807
<td rowspan="2">Apple</td>
808
+ <td>Red</td>
688
809
<td>No</td>
689
810
</tr>
690
811
<tr>
691
812
<td>Green</td>
692
813
<td>No</td>
693
814
</tr>
694
815
<tr>
695
- <td>Red</td>
696
816
<td>Tomato</td>
817
+ <td>Red</td>
697
818
<td>Yes</td>
698
819
</tr>
699
820
<tr>
700
- <td>Yellow</td>
701
821
<td>Banana</td>
822
+ <td>Yellow</td>
702
823
<td>No</td>
703
824
</tr>
704
825
</table >
0 commit comments