How to create and use recurring fun icons for mileposts within a bookdown book, as inspired by the work of Desiree De Leon.
div.warning (blank line before)
example of
:::warning
warning content :::
div.tip (blank line before)
example of
:::tip
tip content :::
div.tryit (blank line before)
example of
:::tryit
try an example content :::
div.challenge (blank line before)
example of
:::challenge
challenge (end of chapter) content
:::
div.explore (blank line before)
example of
:::explore
links to explore more within this topic area:::
It is common to want to create standard mileposts for recurring kinds of items in a bookdown book, like:
etc.
You can set these up, as outlined by Desiree De Leon, with div tips, as seen here. These are pandoc style custom divs, set up with css. These will work for .Rmd, bookdown, distill, and blogdown, but no tfor xaringan, .md, or .Rmarkdown.
include
subdirectory.Open the file _site.yml
and add to the output the following:
output:
html_document:
css: include/style.css
output:
distill::distill_article:
css: include/style.css
output:
bookdown::html_document2:
css: include/style.css
For a bookdown in the Gitbook style
If you’re working in bookdown, do this by making sure your _output.yml has this:
output:
bookdown::gitbook:
css: include/style.css
style.css
to Style our div tipsYou can set:
Here is an example of css to paste into style.css
/* -----------div tips------------- */
div.puzzle, div.fyi, div.demo, div.note {: 1em;
padding: 1em 0;
margin-left: 100px;
padding-size: 70px;
background-repeat: no-repeat;
background-position: 15px center;
background-height: 120px;
min: #1f5386;
color-color: #bed3ec;
background: solid 5px #dfedff;
border }
Use short names after div.
You can have different styles for each div.x
Consider giving div.tips a different google font, and specify the font-family
in the style.css file.
Pick a distinct, informative image for each div.tip
Use .PNG images with transparent backgrounds
Save the images in your images
directory. Mine are saved in include/images_included
. This is so that they are easily found relative to style.css
, which is also in the include
folder in my RMRWR bookdown project.
Open style.css
Paste in your style rules to add images, as below
div.puzzle {-image: url("images_included/warning.png");
background
}
div.fyi {-image: url("images_included/fyi.png");
background
}
div.demo {-image: url("images_included/Live-code.png");
background
}
div.note {-image: url("images_included/lightbulb.png");
background }
Change the file path within the url()
field for each div.tip style so that it points to the correct image that you want to use. These urls are relative to where your CSS file (style.css) lives.
Use a blank line before you start
Then start off with 3 colons :::
followed by the name
of the div.tip, then
on a new line add content, then
on another new line then add 3 colons to close :::
as in:
:::warning
content goes here
:::
example of div.warning
:::warning
warning content :::
example of div.tip
:::tip
tip content :::
example of div.tryit
:::tryit
try an example content :::
example of div.challenge
:::challenge
challenge (end of chapter) content
:::
example of div.explore
:::explore
links to explore more within this topic area:::
For attribution, please cite this work as
Higgins (2021, Oct. 20). Medical R: Creating Standard Mileposts in your Bookdown Book. Retrieved from https://higgi13425.github.io/medical_r/posts/2021-10-20-creating-standard-mileposts-in-your-bookdown-book/
BibTeX citation
@misc{higgins2021creating, author = {Higgins, Peter}, title = {Medical R: Creating Standard Mileposts in your Bookdown Book}, url = {https://higgi13425.github.io/medical_r/posts/2021-10-20-creating-standard-mileposts-in-your-bookdown-book/}, year = {2021} }