This article introduces rich features of minidown::mini_document with live examples. This format is powered by R Markdown, Pandoc, KaTeX and light weight CSS framewroks such as sakura (default), Water.css, mini.css, and so on.
If you haven’t installed the minidown package on R, install it by
Documentation is ready at here.
Frameworks and themes
Default framework and its theme are "sakura" and "default". Followings are the list of available ones. Live examples are available via links.
| framework | theme |
|---|---|
| sakura | default, dark_solarized, dark, earthly, vader |
| water | light, dark |
| mini | default, nord, dark |
Here’s an example YAML frontmatter specifying a framework and a theme.
Code folding
Code folding can be controlled by the YAML frontmatter like:
output:
minidown::mini_document:
code_folding:
source: show
output: show
message: hide
warning: hide
error: show
The above results in
Output
## [1] 1
Message
Warning
## Warning in f(): warning
## Error in f(): error
If the code folding is specified for some of them, then the code folding of the others will be none.
Like rmarkdown::html_document, code_folding: show indicates source is show and others are none.
By default code_folding is none, however, you can select some chunks be folded by giving the details class (e.g., class.source='details').
Show/hide exceptions
When source: show, all the sources are shown. In case you need exceptions, add the hide class to the source. If you want to hide all with exceptions, add the show class to the exceptions. Of course, this feature is not limited to the source.
---
output:
minidown::mini_document:
code_folding:
source: show
---
```{r}
'This is shown'
```
```{r, class.source='hide'}
'This is hidden'
```
and hide classes.
Change summary
The content of summary can be controlled via summary.* chunk options. This feature is useful when you want to show the title of the source, to treat the output as a hidden answer, and so on.
Fold only some
Even if none is specified in YAML, code folding can be enabled for selected chunks by adding the details class.
---
output:
minidown::mini_document:
code_folding: none
---
```{r}
'This is shown'
```
```{r, class.source='details hide'}
'This is hidden'
```
Prefer rmarkdown::html_document
If you prefer rmarkdown::html_document except for the code foliding, specify the framework: bootstrap.
Results folding
By specifying result_folding: show or hide, you can fold entire results.
This is a good option when you have side effects such as drawing figures and tables. Result button is placed on the left so that you can distinguish from code_folding buttons.
Results
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
|---|---|---|---|---|
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
Change summary text
By default, summary text is “Results”. You can change this by a chunk option, summary.results. Just like summary.* in code folding.
Multiple results per chunk
If you have multiple results per chunk and combine them to a single folding, you have three options.
Set chunk options
with results='hold' and/or fig.show='hold'.
Results
Output
## [1] "foo"
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
|---|---|---|---|---|
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
Iterate with for or lapply
or their friends.
Results
Output
## [1] 1
## [1] 2
Define a function with side effects
Results
Output
## [1] "foo"
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
|---|---|---|---|---|
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
Exceptionally show/hide some results
To disable folding for some chunks, specify results.folding=NULL as a chunk option. When results_folding: show and you want to hide for some, then specify results.folding='hide' as a chunk option. Similarly, you make exeptions for results_folding: hide as well.
To disable folding by default, but enable it for some chunks, then specify results_folding: show # or hide as a YAML front matter, and run knitr::opts_chunk$set(results.folding=NULL) at the beggining of your document. Then, you can enable the feature for selected chunks by specifying 'show' or 'hide' to the results.folding chunk option.
---
output:
minidown::mini_document:
result_folding: show
---
`r''````{r, include=FALSE}
knitr::opts_knit$set(results.folding=NULL)
`r''````
`r''````{r}
'This chunk does not fold results'
`r''````
`r''````{r, result.folding='hide'}
'This chunk hides not fold results'
`r''````
Floating TOC
Table of contents can be floated on the left of the page by specifying toc_float: true. The layout is responsive to the windows size. Thus, floating TOC is available when the viewport has the enough width. See what happens by shrinking the width of your browser.
Tooltips
Tooltips are available.
Math with KaTeX
$\sum_{i=1}^{10}{\alpha_i}$ becomes \(\sum_{i=1}^{10}{\alpha_i}\) and
becomes
\[ \sum_{i=1}^{10}{\alpha_i} \]
Others
Visit https://minicss.org/docs for other features available via the mini.css framework.
Appendix: markdown results
Headings (H2)
H3
H4
H5
H6
Block quotations
Single
Nesting
another
Code blocks
A code block without line numbers.
Code block
A code block with line numbers.
Code blocks with long lines
Without specifiying language
long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long
With specifying language
Without line numbers
With line numbers
Lists
Bullet lists
Tight
- Tight 1
- Tight 2
- Tight 2-1
- Tight 2-2
Loose
Loose 1
Loose 2
Loose 3
Ordered lists
- one
- two
- three
Task lists
- an unchecked task list item
- checked item
Definition lists
- Term 1
- Definition 1
- Term 2
- Definition 2a
- Definition 2b
Horizontal rule
Table
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
|---|---|---|---|---|
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
| 4.7 | 3.2 | 1.3 | 0.2 | setosa |
| 4.6 | 3.1 | 1.5 | 0.2 | setosa |
| 5.0 | 3.6 | 1.4 | 0.2 | setosa |
| 5.4 | 3.9 | 1.7 | 0.4 | setosa |
Inline formatting
- Emphasis
- Strong emphasis
Strikeout- superscript
- subscript
Verbatim- Small caps
Link
Image

Footnote
See1
footnote↩︎