Indent without adding a bullet point or number in RMarkdown
Asked Answered
C

2

9

I want to make an indented list, but I don't want it to have bullet points or numbers. I am using Rmarkdown in RStudio, and knitting to html.

#### bla bla bla  

* Example indented line with bullet point  
    * Another indent with another bullet point  
* Yea this is good except for the stupid bullets!  

1. Example indented line with numbers  
    * sure and an indent with a bullet too  
2. But there's these stupid numbers now!  

  two spaces doesn't indent at all  
    or nest indent with 4  
  yea still no indent with 2.  

    four spaces ALSO doesn't indent  
      just makes some stupid code
    why do you hate indents rmd??
Childlike answered 3/11, 2017 at 2:25 Comment(1)
"why do you hate indents rmd?" Because Markdown is about semantics, not presentation. What do your indents mean? Mark them appropriately for the semantics you want and then style them using CSS as Marius shows below.Damnable
P
7

If you want to change how a list looks and you're outputting to HTML, use css:

---
title: "ListTest"
output: html_document
---

<style>
.nobullet li {
  list-style-type: none;
}
</style>

<div class="nobullet">
* This list
* Doesn't have bullets
</div>

* This list 
* Is normal

This won't work for other output formats.

Photocell answered 3/11, 2017 at 2:33 Comment(0)
L
10

This can be achieved using Line Blocks which are built-in to the R Markdown syntax. If you want the indentation to be respected, you can start a line with |.

This approach works across multiple output formats and doesn't require any additional CSS styling:

---
output:
  html_document: default
  pdf_document: default
---

Here is some text with no indentation

|    A list
|         A sublist
|         Sublist Item 2
|         Sublist Item 3
Lederman answered 29/9, 2018 at 16:6 Comment(3)
By far, the simplest solution.Helbon
This doesn't appear to work when formating on stackexchange. Any way to get it working here?While
@While this formatting is actually done via Pandoc, as described in the link: "Pandoc understands an extended and slightly revised version of John Gruber’s Markdown syntax. ". It processes the data before presenting the Markdown. So not possible to use this on SELederman
P
7

If you want to change how a list looks and you're outputting to HTML, use css:

---
title: "ListTest"
output: html_document
---

<style>
.nobullet li {
  list-style-type: none;
}
</style>

<div class="nobullet">
* This list
* Doesn't have bullets
</div>

* This list 
* Is normal

This won't work for other output formats.

Photocell answered 3/11, 2017 at 2:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.