rlistr-markdownquarto

quarto bullet list under a list item


I have the following qmd file of bullet lists:

---
title: "lists"
format: html
editor: visual
---


# hello

this is my first sentance of lists:

-   my first list:


```{r bulletlist1, echo = FALSE, eval = TRUE, results = 'asis'}
cat(paste("*", levels(iris$Species)), sep = "\n")
```



-   this is next

    other lists:

```{r bulletlist2, echo = FALSE, eval = TRUE, results = 'asis'}
cat(paste("*", levels(iris$Species)), sep = "\n")
```

    $~$

    and the other lists:
    

```{r bulletlist3, echo = FALSE, eval = TRUE, results = 'asis'}
cat(paste("*", levels(iris$Species)), sep = "\n")
```

which returns:

enter image description here

but i want:

enter image description here

Previously in rmd, I have indented the chunks like this (although when I have updated packages it doesn't seem to work anymore even in rmd):

---
title: lists
---

# hello

this is my first sentance of lists:

-   my first list:


    ```{r bulletlist1, echo = FALSE, eval = TRUE, results = 'asis'}
cat(paste("*", levels(iris$Species)), sep = "\n")
```



-   this is next

    other lists:

    ```{r bulletlist2, echo = FALSE, eval = TRUE, results = 'asis'}
cat(paste("*", levels(iris$Species)), sep = "\n")
```

    $~$

    and the other lists:
    

    ```{r bulletlist3, echo = FALSE, eval = TRUE, results = 'asis'}
cat(paste("*", levels(iris$Species)), sep = "\n")
```

Any suggestions?

thanks


Solution

  • The issue has nothing to do with using * or - or whether we are using Quarto or Rmarkdown. It's just a matter of the correct indentation, i.e. you can achieve your desired result by adding a tabulator aka \t to each sublist item so that they get indented by "four" spaces in the knitrred markdown document:

    ---
    title: "lists"
    format: html
    editor: visual
    ---
    
    # hello
    
    this is my first sentance of lists:
    
    -   my first list:
    
    ```{r bulletlist1, echo = FALSE, eval = TRUE, results = 'asis'}
    cat(paste("\t*", levels(iris$Species)), sep = "\n")
    ```
    
    -   this is next
    
        other lists:
    
    ```{r bulletlist2, echo = FALSE, eval = TRUE, results = 'asis'}
    cat(paste("\t*", levels(iris$Species)), sep = "\n")
    ```
    
    ```         
    $~$
    
    and the other lists:
    ```
    
    ```{r bulletlist3, echo = FALSE, eval = TRUE, results = 'asis'}
    cat(paste("\t*", levels(iris$Species)), sep = "\n")
    ```
    

    enter image description here

    To clarify check this simplified Rmd:

    ---
    title: "lists"
    format: 
      html:
        keep-md: true
    editor: visual
    ---
    
    -   without tab:
    
    ```{r bulletlist1, echo = FALSE, eval = TRUE, results = 'asis'}
    cat(paste("*", levels(iris$Species)), sep = "\n")
    ```
    
    -   with tab:
    
    ```{r bulletlist1-tab, echo = FALSE, eval = TRUE, results = 'asis'}
    cat(paste("\t*", levels(iris$Species)), sep = "\n")
    ```
    

    which after knitting results in this md file:

    ---
    title: "lists"
    format: 
      html:
        keep-md: true
    editor: visual
    ---
    
    -   without tab:
    
    * setosa
    * versicolor
    * virginica
    
    -   with tab:
    
        * setosa
        * versicolor
        * virginica