Search code examples
rmarkdownindentation

R markdown indentation issue


I have been searching for the solution for a long time. The indentation changes whenever I add a table in between as you can see in the picture. I am not sure where I did wrong.

title: "Markdown_file"
author: "MZ"
date: "10/27/2019"
output: pdf_document
---


1.  abc dd dd 
    (a) adb
    (b) dwd

|    |   A| B |  C | 
|---:|---:|--:|---:|
|a   |  1 | 2 |  3 |
|b   |  1 | 3 |  3 |
|c   |  1 | 3 |  3 |

    (c) ddd
    (d) dddw

This is what it looks like when I add a table. As you can see, it is not line up

enter image description here


Solution

  • This is really a Markdown issue, not particular to RMarkdown, and is answered here: https://superuser.com/a/1409106. The idea is that you indent your table, and don't include a blank line after it:

    ---
    title: "Markdown_file"
    author: "MZ"
    date: "10/27/2019"
    output: pdf_document
    ---
    
    
    1.  abc dd dd 
        (a) adb
        (b) dwd
    
        |    |   A| B |  C | 
        |---:|---:|--:|---:|
        |a   |  1 | 2 |  3 |
        |b   |  1 | 3 |  3 |
        |c   |  1 | 3 |  3 |
        (c) ddd
        (d) dddw