skip to Main Content

I have this Rmarkdown file:

---
title: "Indent heading under list"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## This is a heading

1. I have some numbered list items under this heading

2. And I want to have sub-heading under this numbered listed

3. Under this new sub-heading, I want to have tabs under it

### Sub-heading I want {.tabset .tabset-fade .tabset-pills}

#### Apple

- This is an apple

#### Orange

- This is an orange

###

4. I want the above sub-heading to have indentation so that it is indented under item number 3 above

Which is currently like this:

current_subheading

As explained in the Rmarkdown itself, I want to have indentation of the sub-heading under the numbered list, so that it will look like this:

target_subheading

Most resources I found online recommend manually indenting the heading(s) with four spaces under the numbered list, but that doesn’t work (see attached screenshot).

manual_indent

2

Answers


  1. If you want something to be part of the list item, in markdown you need to indent it beyond the list marker. Thus indent it either three or four spaces:

    2. And I want to have sub-heading under this numbered listed
    
    3. Under this new sub-heading, I want to have tabs under it
    
       ### Sub-heading I want
    
       #### Apple
    
       - This is an apple
    
       #### Orange
    
       - This is an orange
    
    4. I want the above sub-heading to have indentation so that it is indented under item number 3 above
    
    Login or Signup to reply.
  2. If you add an indented hyphen before the ### then this creates an indented sub-header. But then there’s a bullet, I don’t know how to get rid of this one.

    ---
    title: "Indent heading under list"
    output: html_document
    ---
    
    
    ## This is a heading
    
    1. I have some numbered list items under this heading
    
    2. And I want to have sub-heading under this numbered listed
    
    3. Under this new sub-heading, I want to have tabs under it
    
      - ### Sub-heading I want 
    
        - And I also want an apple
    

    pandoc indented subheader

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search