R markdown table with a caption

前端 未结 1 1725
傲寒
傲寒 2021-02-05 11:43

I\'m trying to create a table outside of a code chunk using normal markdown notation and to add a caption to it. Here\'s an example file (taken from here:

---
ou         


        
相关标签:
1条回答
  • 2021-02-05 12:21

    The linked guide refers to MultiMarkdown, while RMarkdown uses Pandocs. Captions work a little bit differently in Pandoc. The following should do the trick. The syntax is Table: followed by your caption; Pandocs numbers automatically. Leave one line blank between the end of the table and the caption line.

    ---
    output: pdf_document
    ---
    
    | First Header  | Second Header | Third Header         |
    | :------------ | :-----------: | -------------------: |
    | First row     | Data          | Very long data entry |
    | Second row    | **Cell**      | *Cell*               |
    | Third row     | Cell that spans across two columns  ||
    
    Table: Your Caption
    
    0 讨论(0)
提交回复
热议问题