Search code examples
rquarto

Automating bullet lists in quarto with Word output


I want to make an automated bullet list in Quarto. The input would be items<-c("item1", "item2", "item3"). The output should be

items

  • item1
  • item2
  • item3

Any help would be appreciated.


Solution

  • Using a small custom function and chunk option results='asis'you could do:

    ---
    title: "Bullet List"
    format: docx
    ---
    
    ```{r}
    bullet_list <- function(...) {
      cat(paste0("- ", c(...), collapse = "\n"))
      cat("\n")
    }
    ```
    
    ```{r results="asis"}
    bullet_list(paste("Item", 1:3))
    ```
    
    Blah blah
    
    ```{r results="asis"}
    bullet_list("Item 1", "Item 2", "Item 3")
    ```
    
    Blah blah
    

    enter image description here