STAT545-UBC / Discussion

Public discussion
38 stars 20 forks source link

List problems in Rmarkdown #356

Open RosieRedfield opened 7 years ago

RosieRedfield commented 7 years ago

Is there some subtle trick to formatting lists in Rmarkdown?

My code has:

  1. Item one
  2. Item two
  3. Item three

but it formats as:

  1. Item one 2. Item two 3. Item three

Same problem with unordered lists.

I found some online advice about adding two blank spaces at the end of each line. That seemed to work the first time I tried it (in homework 1) but not now.

jennybc commented 7 years ago

Here is a good cheatsheet: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet

You might be seeing some differences between how rendered markdown looks locally vs on GitHub.

About line breaking in general:

Yes markdown requires either a blank line separating lines or spaces at the end of each line. Locally RStudio renders markdown in a way that honors this.

Github-Flavoured markdown is more relaxed and will tolerate a lack of two spaces. It takes your line breaks literally.

About bulleted and numbered lists:

It is important to have a single blank line between the main prose and the first list item. This is easy to forget and leads to mangled list formatting.

RosieRedfield commented 7 years ago

Aha! Inserting a blank line before the list solved the problem!

oganm commented 7 years ago

Here's a fun unrelated trivia about markdown numbered lists. If you do

1. first them
1. still the first item
1. i'm telling you its the first item

you'll still get

  1. first them
  2. still the first item
  3. i'm telling you its the first item