class: center, middle, inverse, title-slide .title[ # 07 R Markdown Advanced ] .subtitle[ ## Elements of R e R Markdown ] .author[ ### Claudio Zandonella ] --- class: size-small # Advanced HTML .pull-left-50[ ```r --- output: html_document: css: ["default.css", "custom.css"] includes: in_header: header.html before_body: before.html after_body: after.html --- ``` #### Raw HTML https://www.w3schools.com/html/ ```html <div class="class-name" id="idname"> <h1>My title</h1> <p> Color <span style="color:red;">red</span> </p> <code>x = 2</code> </div> ``` ] .pull-right-50[ #### CSS https://www.w3schools.com/css/ ```css .class-name { /*class properties */ } .class-name h1 { /*class element properties*/ } #idname { /* ID properties*/ } ``` #### Extra - `<br>` line break - ` ` non-breaking space ] --- class: size-small # `\(\LaTeX\)` .pull-left-50[ ```r --- output: pdf_document: latex_engine: pdflatex includes: in_header: preamble.tex before_body: header.tex after_body: after.tex --- ``` #### Raw `\(\LaTeX\)` ```latex \documentclass{article} % preamble \begin{document} % body \section{My title} Color \textcolor{red}{word} \texttt{x = 2} \end{document} ``` ] .pull-right-50[ #### `\(\LaTeX\)` Syntax https://www.overleaf.com/learn Load packages:<br> `\usepackage[<options>]{<name-pkg>}` Formatting .pull-left-50[ - `\section{}` - `\subsection{}` - `\subsubsection{}` ] .pull-right-50[ - `\textbf{}` - `\textit{}` - `\underline{}` ] Environments ```latex \begin{figure}[<options>] \centering \includegraphics[<options>]{<path-fig>} \caption{<text>} \label{fig:<tag-fig>} \end{figure} ``` ] --- class: size-small .pull-left-50[ ## Managing Different Outputs - Choose the output at the beginning - Different syntax according to output ```r colorize <- function(x, color) { if (knitr::is_latex_output()) { sprintf("\\textcolor{ %s }{ %s }", color, x) } else if (knitr::is_html_output()) { sprintf("<span style='color: %s;'>%s</span>", color, x) } else x } ``` `` `r colorize("some words in red", "red")` `` ] .pull-right-50[ ## Papaja - APA Articles http://frederikaust.com/papaja_man/ ```r devtools::install_github("crsh/papaja") ``` *“File” > “New File” > “R Markdown ...”* <img src="images/papja.png" width="70%" style="display: block; margin: auto;" /> ] --- class: size-small # trackdown - Collaborative Wrinting https://claudiozandonella.github.io/trackdown/ ```r install.packages("trackdown") ``` <img src="images/trackdown-workflow.png" width="75%" style="display: block; margin: auto;" /> --- class: end, middle, center # Thanks!