What are my options for changing the font size of dynamically-generated output, when rendering to a PDF? My document currently looks something like this:
---
title: "Foo"
author: "Bar"
date: "`r format(Sys.time(), '%B %e, %Y')`"
output:
pdf_document: default
html_document:
df_print: paged
header-includes: \usepackage{amsmath} \usepackage{color}
---
# Introduction
```{bash echo=FALSE}
perl -le 'print for 1..50'
```
I want to decrease the font size to help more output fit on a single page of the PDF. I'm not currently also outputting to HTML, so a cross-format solution would be cool but not really necessary.
It is as simple as fontsize: 12pt (or of course fontsize: 9pt as we use in pinp)
Modified file:
---
title: "Foo"
author: "Bar"
date: "`r format(Sys.time(), '%B %e, %Y')`"
fontsize: 12pt
output:
pdf_document: default
html_document:
df_print: paged
header-includes: \usepackage{amsmath} \usepackage{color}
---
# Introduction
```{bash echo=FALSE}
perl -le 'print for 1..50'
```
If you want it just for code / result snippets I would suggested you place appropriate \begin{Large} and \end{Large} around it. I have in the past customized the default environments used here --- as I recall knitr more or less follows Sweave here. Just look at the generated .tex file.
Related
While I like the possibility to show/hide all code that is allowed by the code_folding property of the html_document output in rmarkdown, I do not like that I have to see a Code button everywhere there is some code because it creates "empty line(s)" in the document.
Is there a way to remove this/these Code button(s) with a property or some javascript magic
without altering the Rmd document (ie. not writing some additional code in the document itself)
while still allowing to show/hide all code through the Show/Hide All Code toggle
Here is an example:
---
title: "Test"
date: '`r Sys.Date()`'
output:
html_document:
code_download: true
code_folding: 'hide'
---
# Title 1
chunk 1
```{r, eval = FALSE}
1+1
```
```{r, eval = FALSE}
1+2
```
```{r}
1+3
```
Which renders like this:
You can hide the code-folding buttons with a css rule.
---
title: "Test"
date: '`r Sys.Date()`'
output:
html_document:
css: "style.css"
code_download: true
code_folding: 'hide'
---
The style.css
.code-folding-btn {
display: none;
}
---
title: "PDF Document"
author: "Sana"
date: "27-05-2022"
---
How to change the font color and style of title, author, date and make it bold or italic in yaml of Rmarkdown?
One way is to use a latex code chunk in the title.
---
title: |
```{=latex}
\textcolor{red}{\textbf{PDF Document}}
```
author: "Sana"
output: pdf_document
---
This is a slidy_presentation in R, and I want my embedded hyperlink to be red in color instead of black, so that the user knows that the word "help" is clickable.
I have referred to this post to include linkcolor: red, but it doesn't work, I'm not sure why.
R markdown link is not formatted blue when knitted to pdf
My code:
---
title: "XXX"
subtitle: "XXX"
author:
- "XXX"
date: "Last updated: `r format(Sys.time(), '%d %B, %Y')`"
output:
slidy_presentation:
font_adjustment: -2
highlight: haddock
mathjax: "default"
df_print: paged
citecolor: red
linkcolor: red
urlcolor: blue
---
Embedded hyperlink code:
[help](https://www.aihw.gov.au/suicide-self-harm-monitoring/research-information/crisis-support) is always available.
R Slidy output: the "help" word does not appear as red color.
Figured out the solution for this.
[<span style="color: red">**HELP**</span>](https://www.aihw.gov.au/suicide-self-harm-monitoring/research-information/crisis-support)
Output:
I use a custom LaTex beamer theme in an rmarkdown::beamer_presentation.
As per these SO answers (LaTex theme, colon, theme path), I used several modifications of the YAML header and beamerthemeTHEMENAME.sty.
These LaTex hacks are necessary to apply the LaTex Beamer theme smoothly in the rmarkdown::beamer_presentation.
For the foot line defined in beamerouterthemeTHEMENAME.sty, it would be very nice to have a hyperlink from the logo to the table of contents slide (like the slide numbers are linked to the appendix).
What I tried: define custom foot line in beamerouterthemeTHEMENAME.sty
\mode<presentation>
...
% Foot line
\setbeamertemplate{footline}{
\leavevmode%
\hyperlink{toc---table-of-contents}{\includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{img/my_logo.png}}
\hfill
\hyperlinkappendixstart{\insertframenumber/\inserttotalframenumber}
\vspace{3mm}
}
\mode<all>
For a complete MWE, see my SO question here.
In normal beamer code, you could simply attach a label to the frame, but Rmarkdown seems to be too stupid to correctly parse the square brackets in \begin{frame}[label=outline].... annoying!
As a workaround you could use something like a section name for which markdown will automatically insert a label:
---
subtitle: "Beamer presnetation with R-markdown"
institute: "some place"
date: "`r format(Sys.time(), '%B %d, %Y')`"
author: "Donald Duck"
output:
# beamer_presentation: default
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
# includes:
# in_header: preamble.tex
theme: "THEMENAME"
latex_engine: xelatex
toc: false
slide_level: 2
keep_tex: true
header-includes:
- \AtBeginDocument{\title{MWE}\titleframe}
- \AtEndDocument{\begin{closingframe}lalala\end{closingframe}}
- \makeatletter\beamer#ignorenonframefalse\makeatother
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Outline {.unnumbered}
\tableofcontents
# section
## Slide with Bullets
<!-- ======================================================== -->
- Bullet 1
- Bullet 2
- Bullet 3
<!-- Appendix -->
<!-- ======================================================== -->
``` {=latex}
\end{frame}
\appendix
\begin{frame}
```
and use this target in the footline
% Footline
\setbeamertemplate{footline}{
\leavevmode%
\hyperlink{outline}{\includegraphics[width=12mm,trim=0mm 0.4mm 0mm 0mm]{example-image}}
\hfill
\hyperlinkappendixstart{\insertframenumber/\inserttotalframenumber}
\vspace{3mm}
}
I would like to indent every paragraph but the first paragraph of every section in my article. The Rmd file has a pdf_output and it is referencing child files containing the sections of my article.
This is what I have:
---
bibliography: bibliography.bib
header-includes:
- \usepackage{setspace}\doublespacing
- \usepackage{float}
- \setlength{\parskip}{12pt}
#- \setlength{\parindent}{30pt}
fontsize: 12pt
indent: true
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
```
```{r 01_Introduction, child = here::here("WriteUp", "Child", "Introduction.Rmd")}
```
\newpage
# References
I would like to indent every paragraph but the first paragraph of every section in my article.
You use indent in the YAML. See this answer.
Here is an example. First the main file:
---
title: "test"
author: "me"
date: "11/3/2020"
output: pdf_document
indent: true
---
```{r, child=c('sec1.Rmd', 'sec2.Rmd')}
```
Here is the sec1.Rmd file:
## My section
Some text.
Some more text.
and here is the sec2.Rmd file:
# That other section
Even more text.
And the last line.
The result is:
Update
It is still indented after I have added:
header-includes:
- \usepackage{setspace}\doublespacing
- \usepackage{float}
- \setlength{\parskip}{12pt}
to the YAML.