bookdown custom block does not compile - r

I'm trying to create custom blocks for use in my book, written in bookdown. Unfortunately clicking Build Book in RStudio produces no output for the block. That is, the block does not appear in the output HTML but everything else in the book does.
I don't really know anything about CSS so decided to copy code from the bookdown book as a starting point. All the files below are located in the root folder of my book.
My style.css file looks like this:
.rmdcaution, .rmdimportant, .rmdnote, .rmdtip, .rmdwarning {
padding: 1em 1em 1em 4em;
margin-bottom: 10px;
background: #f5f5f5 5px center/3em no-repeat;
}
.boo {
padding: 1em 1em 1em 4em;
margin-bottom: 10px;
background: #f5f5f5;
position:relative;
}
div.boo:before {
content: "\f518";
font-family: FontAwesome;
left:10px;
position:absolute;
top:0px;
font-size: 45px;
}
p.caption {
color: #777;
margin-top: 10px;
}
p code {
white-space: inherit;
}
pre {
word-break: normal;
word-wrap: normal;
}
pre code {
white-space: inherit;
}
The first style block was copied from the bookdown book and the second was based on the SO example here.
Next, my _output.yml file looks like this:
bookdown::gitbook:
css: [style.css, fontawesome.min.css]
config:
toc:
before: |
<li>Surviving Statistics</li>
after: |
<li>Published with bookdown</li>
edit: https://github.com/rstudio/bookdown-demo/edit/master/%s
download: ["pdf", "epub"]
Finally, I call the blocks in my rmd file thus:
```{block, type='boo'}
Some text for this block. Some text for this block. Some text for this block. Some text for this block. Some text for this block. Some text for this block.
```
```{block2, type='rmdnote'}
If you are planning on printing your book to PDF, you will need a LaTeX distribution. We recommend that you install TinyTeX (which includes XeLaTeX): <https://yihui.name/tinytex/>.
```
As you can see, the first is a copy of the SO example above and the second is a copy of the bookdown book itself.
Any help much appreciated!

Related

How to correct R Markdown Cookbook instructions on including icons?

I am working with R bookdown to test out the basic functionality of including icons as is described in section 9.6.3 here from R Markdown Cookbook. Unfortunately, the R Markdown Cookbook instructions do not work for me when compiling the pdf, although the html does work just fine.
To create MWE use this minimal example. Then according to the R Markdown Cookbook, change the preamble.tex file to be as follows.
\usepackage{booktabs}
\usepackage{amsthm}
\makeatletter
\def\thm#space#setup{%
\thm#preskip=8pt plus 2pt minus 4pt
\thm#postskip=\thm#preskip
}
\makeatother
\usepackage{tcolorbox}
\newtcolorbox{blackbox}{
colback=black,
colframe=orange,
coltext=white,
boxsep=5pt,
arc=4pt}
\newenvironment{infobox}[1]
{
\begin{itemize}
\renewcommand{\labelitemi}{
\raisebox{-.7\height}[0pt][0pt]{
{\setkeys{Gin}{width=3em,keepaspectratio}
\includegraphics{images/#1}}
}
}
\setlength{\fboxsep}{1em}
\begin{blackbox}
\item
}
{
\end{blackbox}
\end{itemize}
}
Change the style.css file according to the R Markdown Cookbook instructions as follows.
p.caption {
color: #777;
margin-top: 10px;
}
p code {
white-space: inherit;
}
pre {
word-break: normal;
word-wrap: normal;
}
pre code {
white-space: inherit;
}
.blackbox {
padding: 1em;
background: black;
color: white;
border: 2px solid orange;
border-radius: 10px;
}
.infobox {
padding: 1em 1em 1em 4em;
margin-bottom: 10px;
border: 2px solid orange;
border-radius: 10px;
background: #f5f5f5 5px center/3em no-repeat;
}
.warning {
background-image: url("images/image_example.png");
}
Now insert into the index.Rmd file the custom box instructions from R Markdown Cookbook.
:::: {.infobox .warning data-latex="warning"}
Include the actual content here.
::::
Note that inside the bookdown-demo-main folder, you also need to create an images subfolder with an image called image_example.png. As far as I can tell, I have followed the cookbook instructions, but compiling to PDF using R command
bookdown::render_book("index.Rmd", "bookdown::pdf_book")
produces the error
! LaTeX Error: File `images/w' not found.
Notice that the knit button produces html just fine. The icon appears as intended, and as demonstrated in the cookbook's instructions, for the html version of the book. However, the pdf does not work. I don't know how R produces the tex file. Examination of the tex file itself does not help, because the custom box and image tex commands were not created in the first place in the pdf creation process executing by render_book. I don't know how to more troubleshoot this.
Note that I am just trying to follow the instructions in R Markdown Cookbook. Other of Cookbook's instructions have been great. This is the first from the book that does not work for me.

How to change the class of text size in RMarkdown slide and render math appropriately?

I made a presentation in which I can change the text size of the slides. But if there is a math equation in the text, it doesn't render anymore. Is there a way that I could create a text class that would change the size of the text and be able to render math as well? Also, is there a way I can use the .tiny class on text, math, code input and output, in 1 CSS class definition or I would need to create 4 different .tiny classes (see the .tiny-code code.r and the .tiny-code code[class="remark-code"])?
---
title: Check this out
output:
xaringan::moon_reader:
seal: false
---
```{css, echo=FALSE}
.tiny {
font-size: .6rem;
font-weight: 200;
}
.huge {
font-size: 2.6rem;
font-weight: 200;
}
/* Tiny R block of code */
.tiny-code code.r {
font-weight: bold;
font-size: .3rem;
}
/* Tiny ouput */
.tiny-code code[class="remark-code"] {
font-size: .3rem;
display: block;
border: 0px solid red;
}
```
# Check this slide out
.tiny[get the **best estimation** of the parameters ( $\beta$ s), become a heRo]
.huge[this is huge]
.tiny-code[
```{r}
mtcars[1:5, "mpg"]
```
]
I found that this:
<span class="tiny">get the **best estimation** of the parameters ( $\beta$ s), become a heRo.</span>
works, but is there a way not to use html and write Markdown only?
Ok, found it...
.tiny[get the **best estimation** of the parameters ( \(\beta\) s), become a heRo]
Source here
.tiny[get the best estimation of the parameters ( \\(\beta\\) s), become a heRo]

pagedown html resume with aside on first page only

I'm attempting to make a CV using R Markdown and the {pagedown} package.
Is it possible to only include the grey aside bar on the first page?
I've tried playing with the page identifiers as described here.
#page :first {
.aside{
width: var(--sidebar-width);
padding: 0.6in var(--sidebar-horizontal-padding);
font-size: 0.8rem;
float: right;
position: absolute;
right: 0;
}
}
My hope was that defining the .aside inside :first would make the grey aside bar only appear on page one, but no luck. Any suggestions?
A minimal example is here: https://github.com/wjakethompson/cv-test
with an new package updates, this previous answer wont work, you need to add this code chunk inside the rmd section:
```{css, echo=FALSE}
.pagedjs_page:not(:first-of-type) {
--sidebar-width: 0rem;
--sidebar-background-color: #ffffff;
--main-width: calc(var(--content-width) - var(--sidebar-width));
--decorator-horizontal-margin: 0.2in;
}
```
This question got solved here.
This can be achieved by adding the following to the css file:
.pagedjs_page:not(:first-of-type) {
--sidebar-width: 0rem;
--sidebar-background-color: #ffffff;
--main-width: calc(var(--content-width) - var(--sidebar-width));
--decorator-horizontal-margin: 0.2in;
}

Change size of body text in Jupyter notebook

I'd like to increase the size of all body text (I don't know the right term, but text that is not in a special markdown category) in a dozen Jupyter notebooks. The notebooks are all stored in one repo, so they can share a css file. But I've no expertise in css.
The directory containing these notebooks has this custom.css file
h4 {
font-weight: normal;
text-align: justify;
}
#TOC, #book-cover {
width: 50%;
float: left;
}
#TOC {
font-size: 130%;
}
#main_content_wrap p, #main_content_wrap ol {
text-align: justify;
}
#main_content_wrap ul li {
list-style-type: none;
margin-bottom: 5px;
}
#main_content_wrap ul li a {
font-weight: bold;
}
#image-cc {
width: auto !important;
}
but I do not know if it is being used. The system (a Docker container) contains a .jupyter directory, but it contains no css files.
Ideally, I'd like a reference to a clear, fairly simple manual on using css for Jupyter notebooks. I'm aware of this good CSS reference, but it does not consider Jupyter notebooks. ("Give a man a fish ..., teach a man to fish ...")
Thanks, Arthur
If you set the body tag font size, it will change the text everywhere. This includes relative sized css like your #TOC id which is based in % and also will impact any relative size values like em.
body { font-size: 20px; }

Change the line height of the post title in HUGO-Xmin theme

With R blogdown package, it is easy to build a personal website. I like the style of the yihui/hugo-xmin theme for its simplicity. I built a site with the R blogdown package in my folder 'c:/test' on the Windows OS:
install.packages('blogdown')
setwd('c:/test')
blogdown::new_site(theme='yihui/hugo-xmin')
and I wrote the following text into a .md file in c:/test/content/post/ folder:
---
title: "Summer Holiday in Southern France (VIII): Return to Nice (Videos) 带着俩娃游南法 (第十天): 重返尼斯 (视频)"
author: dapeng
date: "2017-08-17 15:22:06"
slug: summer-holiday-in-southern-france-viii-return-to-nice-videos
categories: [cn]
tags:
- cn
---
my text.
Then I previewed the site:
blogdown::serve_site()
However, the post title looks like this:
I was wondering how to change the line height in the title, which is too small by default. I added a line-heightcommand in /themes/hugo-xmin/static/css/style.css like this:
.menu, .article-meta, footer { text-align: center; }
.title { font-size: 1.1em; }
footer a { text-decoration: none; }
hr {
border-style: dashed;
line-height: 5em;
color: #ddd;
}
But it did not work.
Thanks for help!
The title is not in the <hr> tag but <h1>. Add something like this to your CSS should increase the line-height:
h1 { line-height: 1.2em; }
I recommend you to learn to use the Developer Tools of your web browser.

Resources