Chapter 8 R Markdown
8.1 YAML
: "TITLE"
title: "AUTHOR"
author: "`r format(Sys.time(), '%d %B, %Y')`" # current date
date-includes:
header- \usepackage{xcolor} # allows to add color to text
- \usepackage{fancyhdr} # define footer and header (package)
- \pagestyle{fancy}
- \fancyhead[C]{SPGRow Individual Report}
- \fancyfoot[R]{Ana Maria Esteves} # PARTICIPANT NAME
- \fancyfoot[C]{\thepage}
# logo in the bottom left (can take any format, .png, .jpg, and .pdf)
- \fancyfoot[L]{\includegraphics[width = .2\textwidth]{LOGO.png}}
- \usepackage[default]{sourcesanspro} # define font (package; step 1/2)
- \usepackage[T1]{fontenc}
# logo in the 1st page
- \usepackage{titling}
- \pretitle{\begin{center}
=5cm]{LOGO.png}\\[\bigskipamount]}
\LARGE\includegraphics[width- \posttitle{\end{center}}
# prevent figures from floating
- \usepackage{float}
- \floatplacement{figure}{H}
: SourceSansPro # define font (step 2/2)
mainfont:
output:
pdf_document:
includes: header.tex # allows page break code
in_header: yes # numbers sections, use {-} to pass
number_sections: yes # tables of contents
toc: 4
toc_depth-title: Contents
toc: FALSE # list of tables lot
8.2 Text Formatting
8.2.1 text color and highlight
Examples:
- \colorbox{red}{highlight in red}
for
- \colorbox[rgb]{1,0.71,0.71}{highlight in rgb defined color}
for
- \textcolor{red}{text in red}
for
- \textcolor[rgb]{1,0.71,0.71}{text in rgb defined color}
for
8.3 In Line Coding
- requires
header.tex
file \newpage
for a page break\hfill\break
for a line break\newpage
and\blandscape
starts landscape,\elandscape
and\newpage
ends landscape
8.4 Knirt
- to create tables to be printed:
::
knitrkable(DF, longtable = T, booktabs = T, caption = "CAPTION",
linesep = "\\addlinespace", digits = 2, col.names = NULL) %>%
kable_styling(latex_options = c("repeat_header", "striped"), # for some reason "striped" does not work with `full_width = T`
font_size = 10, full_width = T) %>%
column_spec(1, width = "25em") %>%
footnote(general = "FOOTNOTE)