Set and resize image as footer Rmarkdown title page - r

I'm trying to set and resize an image as a footer in the title page of a markdown document.
I got the desired results in LaTex with:
\documentclass{article}
\title{Test}
\author{}
\date{}
\usepackage{graphicx}
\usepackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\lfoot{\includegraphics[width=400px]{footer.png}}
}
\begin{document}
\maketitle
\end{document}
But when I try to do the same thing in the Markdown document I get the following error:
Error in yaml::yaml.load(string, ...) :
Scanner error: while scanning a plain scalar at line 6, column 5 found a tab character that violate intendation at line 7, column 1
Calls: ... parse_yaml_front_matter -> yaml_load_utf8 ->
Execution halted
The code I have is:
---
title: "Test"
author: ""
header-includes:
- \usepackage{graphicx}
- \usepackage{fancyhdr}
- \fancypagestyle{plain}{
- \fancyhf{}
- \renewcommand{\headrulewidth}{0pt}
- \renewcommand{\footrulewidth}{0pt}
- \lfoot{\includegraphics[width=400px]{footer.png}}}
output: pdf_document
---
I've tried solutions like Creating a footer for every page using R markdown but it does't do the job for the title page.

Try:
---
title: "Test"
author: ""
header-includes: |
\usepackage{graphicx}
\usepackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\lfoot{\includegraphics[width=400px]{footer.png}}}
output: pdf_document
---

Yaml is a beast for escaping quotes and suchlike. You might want to create a separate file containing your latex header and just include that.
---
header-includes: yourfile.tex
---

Related

Section header and landscape-oriented figure on same PDF page

Inside a knitr-generated PDF, I want to have the section title on the same page as a figure displayed in landscape format.
If I do this
---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
- \usepackage{pdflscape}
---
# Section title
\begin{landscape}
```{r pressure, out.extra= 'angle=0', echo = F}
plot(pressure)
```
\end{landscape}
The plot appears on a different page than "Section title" as \begin{landscape} apparently starts a new page
But if I do this
---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
- \usepackage{pdflscape}
---
\begin{landscape}
# Section title
```{r pressure, out.extra= 'angle=0', echo = F}
plot(pressure)
```
\end{landscape}
I am getting an error message
! You can't use `macro parameter character #' in vertical mode.
l.74 #
Section title
Error: LaTeX failed to compile sectionTitle.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See sectionTitle.log for more info.
Execution halted
Edit: this syntax, leaving empty lines around the section heading, is not working
---
title: "Untitled"
output: pdf_document
date: '2022-06-21'
header-includes:
- \usepackage{pdflscape}
---
\begin{landscape}
# Section title
```{r pressure, echo=FALSE}
plot(pressure)
```
\end{landscape}

How to put final dot after closing quotes in RMarkdown

I'm writing an essay in RMarkdown and I'd like to display the dot at the end of the sentence.
I'm using the " character both for open and close the quote. Obviously, I'm inserting the dot after the closing quotes but what is shown is this:
This is my preamble:
\documentclass[12pt, a4paper, twoside, openright]{report}
\usepackage{sectsty}
\usepackage[style=authoryear, sorting=nyt, backend=bibtex]{biblatex}
\usepackage[italian]{babel}
\usepackage{float}
\usepackage{paralist}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{dcolumn}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{subfiles}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{bm}
\usepackage{wasysym}
\usepackage{amstext}
\usepackage{array}
\usepackage{hhline}
\usepackage[labelfont=bf]{caption}
\usepackage{csquotes}
\renewcommand{\baselinestretch}{1.4}
\geometry{left = 3cm, right = 3cm, top = 3cm, bottom = 2.5cm}
\graphicspath{{img}}
\setcounter{chapter}{0}
\renewcommand{\thesection}{\thechapter.\arabic{section}}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries\raggedright}{\thechapter}{40pt}{\huge}
\sectionfont{\bfseries\Large\raggedright}
\subsectionfont{\raggedright}
\subsubsectionfont{\itshape\raggedright}
\newcommand{\R}{\mathbb{R}}
\newcolumntype{L}{>{$}l<{$}}
\bibliography{bibliografia.bib}
And this is my code (text) that shows what is reported in the previous image:
"...tutto sia correlato con tutto il resto, ma oggetti vicini siano piĆ¹ correlati di oggetti lontani".
How can I fix it?
Try this solution:
---
title: "Test Table"
date: '2021-11-11'
header-includes:
- \usepackage{csquotes}
output:
pdf_document
---
\enquote{I love StackOverflow}.
Addition
\setquotestyle[quotes]{french}
\enquote{I love StackOverflow}.

How to delete the number page in the title in a document Rmarkdown?

I am working on a document with Rmarkdown with latex output, the file compiles well and delivers the document correctly, however I want to delete the page number that appears in the document title, that is, number 1. I have tried the alternatives of latex such as \thispagestyle {empty}, but I don't find it. My code is as follows:
---
title: |
| \vspace{5cm} \Huge [My title][1]
| \vspace{0.5cm} \LARGE My subtitle
author: "xxx"
date: "`r Sys.Date()`"
output:
pdf_document:
citation_package: natbib
fig_caption: yes
keep_tex: yes
number_sections: yes
highlight: zenburn
csl: ajpa.csl
bibliography: bibliography.bib
header-includes:
- \usepackage{draftwatermark}
- \usepackage{fancyhdr}
- \usepackage{xcolor, hyperref}
- \usepackage{lipsum}
- \usepackage{appendix}
- \setlength{\headheight}{47pt}
- \setlength{\footskip}{25pt}
- \renewcommand{\headrulewidth}{0.5pt}
- \renewcommand{\footrulewidth}{0.5pt}
- \rhead{\thepage}
- \hypersetup{colorlinks = true, linkcolor = black, urlcolor = blue, citecolor
= blue}
- \fancypagestyle{plain}{\pagestyle{fancy}}
- \pagestyle{fancy}
- \lhead{\includegraphics[width=7cm,height=1cm]{C:/mypath/stack.jpg}}
---
The result of the code is that document format for all the sheets, but I need to delete the number 1 and the top image only from the front page of the document (see attached image)enter image description here, and that the number 1 start on the next sheet.
Thank you very much for your time and advice.
The solution was easier than I thought, but it took me a little while to understand the structure in Rmarkdown. \pagenumbering{gobble} should be placed inside the YAML to delete the page number on the title page and then add \pagenumbering{arabic} outside the YAML metadata.
header-includes:
- \usepackage{draftwatermark}
- \usepackage{fancyhdr}
- \usepackage{xcolor, hyperref}
- \usepackage{lipsum}
- \usepackage{appendix}
- \setlength{\headheight}{47pt}
- \setlength{\footskip}{25pt}
- \renewcommand{\headrulewidth}{0.5pt}
- \renewcommand{\footrulewidth}{0.5pt}
- \pagenumbering{gobble}
- \hypersetup{colorlinks = true, linkcolor = black, urlcolor = blue, citecolor
= blue}
- \pagestyle{fancy}
- \lhead{\includegraphics[width=7cm,height=1cm]{C:/mypath/stack.jpg}}
- \rhead{\thepage}
---
\newpage
\pagenumbering{arabic}
\renewcommand\contentsname{Contents}
I hope it serves others who have this same problem. regards.

R Markdown with Tex Header

I have created a LaTeX header file for assignments to make my R Markdown convert to PDF as desired. The header file works perfectly but has a couple of defined commands to give my name, assignment number/name and the class name.
\newcommand{\hmwkAuthorName}{Joe Bloggs}
\newcommand{\hmwkClass}{CompSci 101}
\newcommand{\hmwkTitle}{Assignment Numero Uno}
I want to be able to define these in the YAML section of my R Markdown but always getting "Undefined Control Sequence" and error 43 when converting which is remedied by putting these sections back in the header file.
This is what the YAML section looks like currently (not working):
---
title: "Assignment Numero Uno"
author: "Joe Bloggs"
header-includes:
- \newcommand{\hmwkAuthorName}{Joe Bloggs}
- \newcommand{\hmwkClass}{CompSci 101}
- \newcommand{\hmwkTitle}{Assignment Numero Uno}
output:
pdf_document:
includes:
in_header: header_temp.tex
---
How can I achieve this?
EDIT: The full header file is
\usepackage{fancyhdr}
\usepackage{lastpage}
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in
\linespread{1.1}
\pagestyle{fancy}
\lfoot{\hmwkAuthorName}
\chead{\hmwkClass:\ \hmwkTitle}
\lhead{}
\cfoot{}
\rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}}
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
\setlength\parindent{0pt}
\title{
\vspace{2in}
\textmd{\textbf{\hmwkClass:\ \hmwkTitle}}\\
\vspace{3in}
}
\author{\textbf{\hmwkAuthorName}}
\date{}

How to make part of rmarkdown document without section numbering?

I have an rmarkdown document (.Rmd) that I want to knit into a pdf document. number_sections has been put to 'yes' and toc to 'true'. How can I add appendix sections that appear in the table of contents but don't have a section number?
Here is an example .Rmd code. How can I let appendix A and appendix B be numberless sections and let them appear in the table of contents at the same time?
---
title: "Test"
author: "test test"
geometry: margin=1in
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
number_sections: yes
toc: yes
toc_depth: 3
header-includes:
- \usepackage[dutch]{babel}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyfoot[LE,RO]{this is a fancy foot}
- \usepackage{dcolumn}
- \usepackage{here}
- \usepackage{longtable}
- \usepackage{caption}
- \captionsetup{skip=2pt,labelsep=space,justification=justified,singlelinecheck=off}
subtitle: test test test
fontsize: 12pt
---
# start
# second
```{r results="asis",eval=TRUE,echo=FALSE,message=FALSE, error=FALSE, warning=FALSE, comment = NA,fig.height=4}
cat("and here some R")
```
# appendix A
# appandix B
Just add {-} after the section name. Thus, for your appendices, you should do something like:
# appendix A {-}
# appendix B {-}
For more details, see this section of the docs.
Result:

Resources