I used a different color on sections and subsections in my rmarkdown document, but in the reader the names in sections (bookmarks) pane are now blank.
\textcolor{mycolor}{My section}
It looks like even if I revert mycolor to black ({RGB}{0,0,0}), the issue persists, so I assume I'm incorrectly using the \textcolor{mycolor}{Section text to color}.
Is there another way? Also, is there a way to apply the same color to all sections/subsections?
Here is an arguably better approach to accomplish your goal of colored section headings:
---
title: "Untitled"
output: pdf_document
header-includes:
- \usepackage{sectsty}
- \sectionfont{\color{red}}
- \subsectionfont{\color{green}}
- \subsubsectionfont{\color{blue}}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Section
This section header should be red.
## Subsection
This subsection header should be green.
### Subsubsection
This subsubsection header should be blue.
Related
In R Studio, my R Markdown document begins like this:
---
title: 'ST 412: Homework 3'
author: "Camden White"
documentclass: amsart
geometry: margin=1in
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## 1. Read Data Set and Define Variables
```{r, message=FALSE, warning=FALSE}
library(tidyverse)
library(magrittr)
```
When I do not include documentclass: amsart, everything works fine, but when I do include it, the library section is placed before the ## 1. Read Data Set and Define Variables header.
When there is text between the two components, the order is the same order in the code, but without it, the library section comes first. This does not happen with the default article document class, and I do not know why this occurs. How can I use the amsart document class and fix this ordering issue?
The problem seems to be that a subsection in amsart is basically what a paragraph is in normal classes: an unnumbered bold piece of text without an new paragraph after it. The text will just continue in the same line. As the grey box with the source code spans a whole line, it can't be placed there and shows up above. You can reproduce this with normal article class like this:
\documentclass{article}
\usepackage{framed}
\begin{document}
\paragraph{1. Read Data Set and Define}
\begin{framed}
test
\end{framed}
\end{document}
You can avoid the problem by making sure the source code isn't the first text in the subsection, e.g. by adding something invisible:
---
title: 'ST 412: Homework 3'
author: "Camden White"
documentclass: amsart
geometry: margin=1in
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## 1. Read Data Set and Define Variables
\mbox{}
```{r, message=FALSE, warning=FALSE}
library(tidyverse)
library(magrittr)
```
I'm wondering how to change font and color specifically for figure captions in Rmarkdown for a PDF output. I know how to do this for word output (creating a separate document), but often figures are submitted to journals as PDFs.
Note that this is not whether you can change the color of text in a PDF which is answered here: Changing the font size of figure captions in RMarkdown pdf output. If I try this within the fig.cap = "fig text here.\\label{...}" I get the following error:
! Undefined control sequence.
<recently read> \cellcolor
This probably comes closest: Changing the font size of figure captions in RMarkdown pdf output, but I went to CTAN and downloaded the package and am not sure whether I have to find my R libraries and drag it to there, or what. Perhaps this is the only/easiest solution, if so, can you advise on how I should proceed with the downloaded package. Haven't done a lot in latex, so it would probably be finding how colors are defined in latex as well?
Thanks much!
James
Here is my header:
output:
pdf_document:
keep_tex: true
html_document: default
header-includes:
\usepackage{placeins}
---
You could try this:
---
title: "Untitled"
author: "bttomio"
date: "6/13/2021"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r pressure, echo=FALSE, fig.cap="\\textcolor{red}{This is red} and \\textcolor{blue}{this is blue}"}
plot(pressure)
```
-output
I'm using R markdown to create a presentation, and I would really like to add a custom background on my opening slide and second slide. Currently, I have my potential themes on a separate PowerPoint document. Is there any way to add backgrounds like that?
Thanks!
To add a custom background, one can create a powerpoint template, e.g. my-styles.pptx where the background image is placed at the slide master.
Then create an Rmarkdown file like follows and place it in the same folder:
---
title: "Fancy Slides"
author: "Creative Author"
date: "2021-06-09"
output:
powerpoint_presentation:
reference_doc: my-styles.pptx
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
More about this can be found in Yihui Xie et al. (2021) R Markdown: The Definitive Guide, Section 4.4.
Tested with RStudio Version 1.4.1714 and Powerpoint 2016.
I have been searching to solve this issue for quite some time, but I cannot get it right. I use R markdown for creating a beamer presentation and I would like to include a footer by using the fancyhdr LaTeX package. The problem that I encounter is that the footer is not completely on each slide. I assume that it has to do something with the margins used by beamer, but I do not know how to change this.
Here is a MWE. This is the .rmd file:
---
title: "Untitled"
author: ""
date: "10 januari 2019"
output:
beamer_presentation:
includes:
in_header: preamble.tex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
SOME NICE TEXT
This is in the file "preamble.tex" that is specified in the YAML:
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{Text in footer}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
This is how it looks. The footer is not entirely on the slide:
Thank you in advance for your help!
When using beamer, it's much more natural to set the footline template than try to use fancyhdr like you'd use with, for example, and article class document (or a pdf_document in R Markdown world). Changing your preamble.tex to the following:
\setbeamertemplate{footline}
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd = .5\paperwidth, ht = 1ex, dp = 1ex, center]{author in head/foot}%
Text in footer
\end{beamercolorbox}%
\begin{beamercolorbox}[wd = .5\paperwidth, ht = 1ex, dp = 1ex, center]{date in head/foot}%
\insertframenumber{}
\end{beamercolorbox}
}%
\vskip3pt%
}
\addtobeamertemplate{footline}{\begin{center}\rule{0.6\paperwidth}{0.4pt}\end{center}\vspace*{-1ex}}{}
results in this output:
which I believe is pretty close to what you want (the black bar there in the middle is just space between the slides in the PDF viewer I was using); you can tweak the footline definition until you get it precisely there.
I want to produce a beamer presentation from a RMarkdown file.
I am in this case using this beautiful template: https://github.com/matze/mtheme
How in markdown can you specify that you want to insert, not a "normal" slide, by a special one, such as an appendix slide, or a standout slide?
This template contains a standout slide that I would like to use as final slide as they do in their demo slides (http://mirrors.standaloneinstaller.com/ctan/macros/latex/contrib/beamer-contrib/themes/metropolis/demo/demo.pdf)
In beamer, I would do:
\begin{frame}[standout]
Questions?
\end{frame}
What is the equivalent in Markdown?
Setting frame options is pretty straight forward:
---
title: "Untitled"
output: beamer_presentation
theme: "metropolis"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## {.standout}
Questions?