Add space between Author, Date, and Abstract in YAML header - r

My YAML header looks like this, and I would like to change only the space between the author/date, and abstract.
How can I achieve this? I have tried using \vspace{1cm} after the date (failed), and also at the start of the abstract text, but that only spaces the text, and not "Abstract" itself.
Any ideas?
---
title:
subtitle:
author: "Me "
date: "`r format(Sys.time(), '%B %d, %Y')`"
abstract: "The document shows the answer to all questions & the output (as it relates to each)"
output:
pdf_document:
keep_tex: false
toc: false
---

With an up-to-date latex installation, you can use the hook system to add a bit of space before the abstract environment or the \#date macro which inserts the date:
---
title: "test"
subtitle:
author: "Me "
date: "`r format(Sys.time(), '%B %d, %Y')`"
abstract: "The document shows the answer to all questions & the output (as it relates to each)"
output:
pdf_document:
keep_tex: false
toc: false
header-includes:
- \AddToHook{env/abstract/before}{\vspace*{4cm}}
- \makeatletter\AddToHook{cmd/#date/before}{\vspace*{4cm}}\makeatother
---
\maketitle
test

Related

Using custom LaTeX class changes numbering in R Markdown

I recently discovered that you can include your own LaTeX class in an R-Markdown doc to change the appearance of the PDF. Here is a minimal example:
R Markdown
---
title: "Test"
date: "`r format(Sys.time(), '%d %B, %Y')`"
documentclass: book
output:
pdf_document:
citation_package: natbib
toc: yes
toc_depth: 3
number_sections: true
fontsize: 12pt
---
# A
## AA
### AAA
### AAA
## AB
# B
This works as intended.
But when I define my own class, the numbering is preceded by 0s and the page numbering is off.
myclass.cls
I place a file called "myclass.cls" in the same direcoty as the RMD file above and change documentclass: myclass:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{glasgowthesis}
\LoadClass{book}
My understanding is that this should simply call the same class as above but the file now looks like this:
Maybe somebody can give me a hint what I'm doing wrong. I would like to copy the book class 1:1 before starting to change things.
I found the solution in the bookdown book and wanted to share it in case anyone wanders off to this question through google etc.
Note that when you change documentclass, you are likely to specify an
additional Pandoc argument --top-level-division=chapter so that Pandoc
knows the first-level headers should be treated as chapters instead of
sections (this is the default when documentclass is book)
So this YAML header solved the issue:
---
title: "Test"
date: "`r format(Sys.time(), '%d %B, %Y')`"
documentclass: myclass
output:
pdf_document:
pandoc_args: --top-level-division=chapter
citation_package: natbib
toc: yes
toc_depth: 3
number_sections: true
fontsize: 12pt
---
# A
## AA
### AAA
### AAA
## AB
# B

rticles and rmarkdown not removing table of contents

I cannot seem to remove the table of contents from my RMarkdown pdf document. I have tried a number of different things such as.
Changing toc: no to false
using differrent base_format: rticles::ieee_article artiles from the getNamespaceExports("rticles").
removing csl: elsevier-harvard.csl
Nothing seems to work and everytime I compile the table of contents appears - what am I missing?
Markdown:
---
title: some title
author:
- name: some name
email: some email
affiliation: some department
footnote: some footnote
- name: some name
email: some email
affiliation: some department
footnote: 2
footnote:
- code: 1
text: "Corresponding Author"
- code: 2
text: "Corresponding Author"
abstract: |
some abstract here
journal: "An awesome journal"
date: "`r Sys.Date()`"
bibliography: mybibfile.bib
#linenumbers: true
#numbersections: true
csl: elsevier-harvard.csl
output:
bookdown::pdf_document2:
base_format: rticles::ieee_article
number_sections: no
toc: no
tables: true
header-includes:
- \usepackage{floatrow}
- \floatplacement{figure}{H}
- \usepackage{booktabs}
- \usepackage{array}
---
Try to format your output section of the YAML header as follows:
output:
bookdown::pdf_document2:
number_sections: no
toc: no
tables: true
base_format: rticles::ieee_article
Then the TOC should disappear. I hope that the base_format argument will be taken into consideration. Please try and report.

How to add .sty file to rmarkdown pdf_output

I'm not sure if I have the right approach here, I've been searching all day for a way to do this, none of the documents are explicit enough in their instruction.
I would like to use a template style which looks like this:
Which I have the .sty file for. I've tried to connect that file in my rmarkdown, with a header like this:
---
title: "title"
author: "author"
date: "`r format(Sys.time(), '%d %B, %Y')`"
mainfont: Arial
output:
pdf_document:
latex_engine: xelatex
includes:
template: analysis_orax.sty
---
However, this isn't adding the style. If I add the .tex file, it adds all of the body text, which isn't what I'm going for.
I don't quite care for using .tex or .sty; all I want is to have a nicely formatted .pdf for reporting!!
The .sty:
\usepackage{titlesec}
\usepackage{tikz}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage[left=4cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}
%------------------Main Font-------------------------
\setmainfont{Fira Sans}
%Make sure you have the compiler "XeLaTeX" activated on your settings for your LaTeX document in order to see the font
%------------------Color Set--------------------------
\definecolor{LightBlue}{RGB}{66, 163, 251}
\definecolor{DarkBlue}{RGB}{36, 100, 176}
\definecolor{LightGray}{gray}{.94}
\definecolor{DarkGray}{gray}{.172}
\definecolor{Orange}{RGB}{229, 133, 3}
\definecolor{MediumBlue}{RGB}{38, 119, 193}
%------------------Section Default Setting-------------
\titleformat*{\section}{\color{DarkBlue}\normalfont\bfseries\Huge}
\titleformat*{\subsection}{\color{LightBlue}\normalfont\bfseries\LARGE}
\titleformat*{\subsubsection}{\color{MediumBlue}\normalfont\bfseries\LARGE}
%-------------------Section Numbers Removal------------
\setcounter{secnumdepth}{0}
%-------------------------Header & Footer------------------------
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{
\begin{tikzpicture}[remember picture,overlay] \node[anchor=north west, yshift=1.5mm, xshift=-1.5mm] at (current page.north west) {\includegraphics[height=25mm]{figures/header_corner.png}};
\end{tikzpicture}
}
\fancyfoot[C]{
\begin{tikzpicture}[remember picture,overlay] \node[anchor=south east, yshift=-1.5mm, xshift=1.5mm] at (current page.south east) {\includegraphics[height=29mm]{figures/banner.png}};
\end{tikzpicture}
\textcolor{LightGray}{\thepage}
}
Though I am not sure which yaml structure you have tried, the page you might see has the right answer. However, the indentation of that answer was not correct. Just try the yaml below, in which we need to indent by two spaces to specify the arguments of output.
---
title: "title"
author: "author"
date: "`r format(Sys.time(), '%d %B, %Y')`"
mainfont: Arial
output:
pdf_document:
latex_engine: xelatex
includes:
in_header:
- analysis_orax.sty
---
The section
in_header:
- analysis_orax.sty
is equivalent to
in_header: analysis_orax.sty
in your case, but if you have more files (.sty or .tex etc.) to include in header, you can use - and line breaks to indicate the file names, as shown below.
in_header:
- analysis_orax.sty
- another_one.sty

R Markdown affiliation doesn't appear in the pdf-document

I want to add the affiliation and the e-mail adress in a pdf-article in r-markdown. But with my code the affiliation and the e-mail adress doesn't appear.
Can someone tell me what I'm doing wrong?
---
title: "title"
subtitle: "subtitle"
date: "`r format(Sys.time(), '%B %d, %Y')`"
keywords: "keywords"
author:
-name: My Name
affiliation: University of somewhere
email: test#e-mail.com
output:
pdf_document:
fig_cap: yes
keep_tex: yes
bibliography: references.bib
biblio-style: "apalike"
link-citations: true
documentclass: article
capsize: normalsize
fontsize: 11pt
geometry: margin=1in
spacing: doublespacing
footerdate: yes
abstract: 'Insert abstract here'
---
Here is the Output with the help of the BiocManager-package.
Two things :
Space between "-" and "name" ?
Did you import BiocStyle 2.11.0 ?
src : https://www.bioconductor.org/packages/devel/bioc/vignettes/BiocStyle/inst/doc/AuthoringRmdVignettes.html
It's only a supposition, hope it'll do the job !
The regular pdf_document output format doesn't support affiliation etc. You need to output to BiocStyle::pdf_document. You also have the formatting for the author specification wrong, which causes troubles.
---
title: "title"
subtitle: "subtitle"
date: "`r format(Sys.time(), '%B %d, %Y')`"
keywords: "keywords"
author:
- name: My Name
affiliation: University of somewhere
email: test#e-mail.com
output:
BiocStyle::pdf_document:
fig_cap: yes
keep_tex: yes
bibliography: references.bib
biblio-style: "apalike"
link-citations: true
documentclass: article
capsize: normalsize
fontsize: 11pt
geometry: margin=1in
spacing: doublespacing
footerdate: yes
abstract: 'Insert abstract here'
---
To install BiocStyle if you haven't already got it, you first need to install BiocManager in the regular way, then use it to install BiocStyle:
install.packages("BiocManager")
BiocManager::install("BiocStyle")

Change the caption title of a figure in markdown

I'm currently writing a small report in German. Hence I want my figure caption titles to be changed from Figure 1 to Abbildung 1 and so on.
---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
pdf_document: default
---
```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```
Question: How can I change the default figure title (not sure if it's actually called that way) in R Markdown?
If you are writing in any language other than English, you can change the language options of the outputted pdf with the lang YAML option. This will override all the captions, labels, table of contents etc.
---
output: pdf_document
lang: de
---
```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```
Other language options include fr (French), it (Italian) etc. See http://pandoc.org/MANUAL.html#language-variables for more details.
Following the example from this question, you can define your own tex file where you can change figure caption defaults.
header.tex:
\usepackage{caption}
\captionsetup[figure]{name=Abbildung}
This is the main .Rmd file:
---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
pdf_document:
includes:
in_header: header.tex
---
```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```

Resources