I'm creating a blog with
blogdown in which I compare code from R and code from Stata. I would like to show both codes so that the user can compare how it's done in R and in Stata. Howewer, putting two or more chunks in a row (code for R, code for Stata + output) makes the reading quite uncomfortable.
Several layouts came to my mind to include several chunks but I don't know if they are already implemented or if it's even possible to do so.
Have a button to display/hide chunks (one button per chunk)
One idea would be to have:
- the R code chunks visible by default in the article,
- the Stata code chunks invisible by default but visible if the user clicks on a button
This person and this person succeeded in folding their code chunks in blogdown but apparently it hides or shows every chunks by default. How can I hide only some chunks by default? Is there an option (like the options
echo...) that hides or shows code chunk in
Chunks with "tabs"
The title of this part speaks for itself: is it possible to have tabs in a chunk so that we can switch from one code to the other (just like tabs in web browsers for example)?
Display two chunks side by side
blogdown themes (maybe all, I don't know), the width is quite reduced and there is some unused space on the sides. Therefore, is it possible to increase the width on some parts of an article and to display two chunks side by side?
Any idea if one of these layouts can be realized in
This question has already been asked on StackOverflow and I only came up with a very partial answer (see in the same link) so I post it here.