0

I would like to be able to generate a series of tables in r-quarto. They are small tables, nothing fancy and generally will have the structure below in (1). A title that is a separate line of text and a table, this will repeat 20 or 30 times. To accomplish this I want to generate the code/formatting on the fly from what I read in from a table. What I have tried does not work (see 2 below) - I assume because the divs are wrapped in ":::{divs}" and therefore treated as text. How do I get r/quarto to recognize the divs output from code as something to render?

---
format:
  docx:
      reference-doc: MyQuartoStyles.docx
engine: knitr
editor: visual
---


```{r, echo=FALSE}

d<-"funtimes"
```


<!--This looks the way I want it-->

`r paste("1. ", d)`

::: {layout-ncol="2"}

Words

More Words

`r paste0(1:4,collapse="  \n")`

`r paste0(1:4,collapse="  \n")`

:::



<!--But, I want to be able to generate that in a code statement-->

`r paste("2. ", d, ":::{layout-ncol=2}", "Words", "More Words",":::", sep="  \n")`
5
  • 2
    This question is similar to: Generate paragraphs inside a loop in Quarto. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented May 22 at 17:26
  • 2
    Generally, you will need two newlines (\n\n) at the end of each section, not just one. Commented May 22 at 17:27
  • The question you refer to does not deal with inclusion of divs in a paste or cat statement. Commented May 22 at 18:28
  • RE \n\n you are correct, my use of "` \n`" is what was causing the problem. Commented May 22 at 19:58
  • So it seems the question I pointed you to did indeed contain the solution. Look at the concepts, not the details. Commented May 22 at 21:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.