Customising R markdown pdf document - r

I am trying to accommodate multiple authors and affiliations as follows.
---
title: "Title"
author: |
| Author1^1^, Author2^2^, Author3^1^ and Author4^2^
| 1. Affiliation1
| 2. Affiliation2
date: "Wednesday, April 10, 2015"
output:
pdf_document
---
With above I am getting
How to modify the default R markdown Yaml header to get customised output in the author field? I would like to.
Avoid italics for affiliation.
Have some space between author and affiliation (Empty line with | does not work).
Reduced font size for affiliation alone.

I was looking a good way to add different affiliations with an elsevier template within 'rticles' and i could do it like this:
---
title: Title
author:
- name: Sergio Ibarra Espinosa^a^
email: sergio.ibarra#iag.usp.br
- name: María de Fátima Andrade^a^
- name: Seaghán Mhartain^b^
- name: Rita Yuri Ynoue^a^
address:
- code: 1
address: Instituto de Astronomía, Geofísica e Ciências Atmosféricas, Universidade de São Paulo
- code: 2
address: Faculdade de Medicina, Universidade de São Paulo
abstract: abstract
It consists of two paragraphs.
bibliography: mybibfile.bib
output: rticles::elsevier_article
---
which produced the following result:
I hope it can help

Related

How to add multiple authors and multiple affiliations with Quarto and export it to MS Word?

I am looking for a way to produce something like this with Quarto in Rstudio. I would appreciate it if the output can be in docx format
Quarto extension authors-block does exactly what you want.
---
title: "Authors-block Example"
authors:
- name: Eric Scott
affiliations:
- ref: uf
corresponding: true
email: myemail#institute.edu
- name: Author Two
affiliations:
- ref: uf
- ref: eu
affiliations:
- id: uf
name: University of Florida, Gainesville, Florida 32611-0430 USA
- id: eu
name: Example University 123 Center Avenue, New York, New York 10027 USA
filters:
- authors-block
format:
docx: default
---

Customizing the output of rticles::elsevier_article document class in r

I am trying to set margins in elsevier_article with little success. This post suggests using geometry to set the margins but I am getting the following error:
! LaTeX Error: Option clash for package geometry.
I also tried adding the following latex commands in the preamble but none does change the margins in the output PDF:
header-includes:
- \PassOptionsToPackage{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}{geometry}
header-includes:
- \PassOptionsToPackage{margin=2.5cm}{geometry}
I need 2.5 cm on either sides of the pages. Below is something to work with. It is just the default template that one can access from Rstudio (I removed a few things that are not necessary):
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice#example.com
affiliation: Some Institute of Technology
correspondingauthor: true
footnote: 1
- name: Bob Security
email: bob#example.com
affiliation: Another University
- name: Cat Memes
email: cat#example.com
affiliation: Another University
footnote: 2
- name: Derek Zoolander
email: derek#example.com
affiliation: Some Institute of Technology
footnote: 2
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
footnote:
- code: 1
text: "This is the first author footnote."
- code: 2
text: "Another author footnote."
abstract: |
This is the abstract.
It consists of two paragraphs.
keywords:
- keyword1
- keyword2
journal: "An awesome journal"
date: "`r Sys.Date()`"
classoption: preprint, 3p, authoryear
# bibliography: mybibfile.bib
linenumbers: false
numbersections: true
# Use a CSL with `citation_package = "default"`
# csl: https://www.zotero.org/styles/elsevier-harvard
# geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
output:
rticles::elsevier_article:
keep_tex: true
citation_package: natbib
# geometry: margin=2.54cm
# header-includes:
# - \PassOptionsToPackage{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}{geometry}
# - \PassOptionsToPackage{margin=2.5cm}{geometry}
---
Please make sure that your manuscript follows the guidelines in the
Guide for Authors of the relevant journal. It is not necessary to
typeset your manuscript in exactly the same way as an article,
unless you are submitting to a camera-ready copy (CRC) journal.
For detailed instructions regarding the elsevier article class, see <https://www.elsevier.com/authors/policies-and-guidelines/latex-instructions>
# References {-}
The header-includes are too late to use \PassOptionsToPackage{...}, this macro needs to used before the documentclass, which would be a bit difficult to do in rmarkdown.
Instead you can use \geometry{...} to change the settings after the package is already loaded.
Full code:
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice#example.com
affiliation: Some Institute of Technology
correspondingauthor: true
footnote: 1
- name: Bob Security
email: bob#example.com
affiliation: Another University
- name: Cat Memes
email: cat#example.com
affiliation: Another University
footnote: 2
- name: Derek Zoolander
email: derek#example.com
affiliation: Some Institute of Technology
footnote: 2
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
footnote:
- code: 1
text: "This is the first author footnote."
- code: 2
text: "Another author footnote."
abstract: |
This is the abstract.
It consists of two paragraphs.
keywords:
- keyword1
- keyword2
journal: "An awesome journal"
date: "`r Sys.Date()`"
classoption: preprint, 3p, authoryear
# bibliography: mybibfile.bib
linenumbers: false
numbersections: true
# Use a CSL with `citation_package = "default"`
# csl: https://www.zotero.org/styles/elsevier-harvard
# geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
output:
rticles::elsevier_article:
keep_tex: true
citation_package: natbib
# geometry: margin=2.54cm
header-includes:
- \geometry{hmargin=2.5cm}
---
Please make sure that your manuscript follows the guidelines in the
Guide for Authors of the relevant journal. It is not necessary to
typeset your manuscript in exactly the same way as an article,
unless you are submitting to a camera-ready copy (CRC) journal.
For detailed instructions regarding the elsevier article class, see <https://www.elsevier.com/authors/policies-and-guidelines/latex-instructions>
# References {-}

How to add new yaml headers in Rmarkdown (pagedown)?

I've seen these header in the thesis template's yaml header that comes with pagedown package Can I add some other categories like: period, surname, deadline, any? Are these predefined with the thesis template? Can I create my own template with some particular yaml headers?
author
degree
institute
faculty
etc
title: A paged html thesis template for R Markdown users
subtitle: A {pagedown} template.
author:
- name: William Brent Thorne
edu: BSc
degree: Master of Documentation
institute: Typeset University
faculty: Reproducibility and FOSS
department: Templates
location: St. Catharines, ON
date:
- year: 2019
month: August
sign_page: true
dedication: A dedication line or two goes here.
abstract: This is the abstract.
preface: A preface to the thesis.
acknowledge: Put the ackknowledgements here.
committee:
- name: Jane Doe III
prefix: Dr
position: Chair of Department
- name: John Smith
prefix: Dr
position: Faculty Advisor
lof: true
lot: true
toc-title: Contents
output:
pagedown::thesis_paged:
toc: true
number_sections: yes
pandoc_args: --mathjax
self_contained: no
bibliography: packages.bib
link-citations: yes
# uncomment this line to produce HTML and PDF in RStudio:
knit: pagedown::chrome_print
---

How to prevent for hyphenated words in pdf output with Rmarkdown?

I'm working with Rmarkdown and my output is a pdf document. When reading the pdf, I noticed that so many words are printed incomplete (hyphenated) such as "ar- rojan" and "progra- mación" (which should be "arrojan" and "programación").
Note: My words are complete in my Rmd file
This is how text appears in the pdf output:
Los operadores <, >, <=, >=, == y != se denominan “lógicos” o “booleanos” porque nos ar­-
rojan como resultado TRUE si se cumple la condición o comparación o FALSE en caso contrario.
Sin embargo, R, al igual que la mayoría de los lenguajes de progra­-
mación distingue entre mayúsculas y minúsculas (“case sensitive”),
Based on my little experience with Rmarkdown, I guess in the YAML section I must include some option to prevent that kind of behaviour. (What I need is something like the Microsoft Word function "Justify"). I found that ragged2e should help in this kind of situations so I included it in my YAML and then I use the \justify command before my text as follows:
---
title: "--"
author: ""
date: "Abril 2020"
output:
pdf_document:
latex_engine: xelatex
html_document:
df_print: paged
mainfont: Times New Roman
header-includes:
- \usepackage{titling}
- \pretitle{\begin{flushleft}\huge\bfseries}
- \posttitle{\end{flushleft}}
- \preauthor{\begin{flushleft}\Large}
- \postauthor{\end{flushleft}}
- \predate{\begin{flushleft}\large}
- \postdate{\end{flushleft}}
- \usepackage[document]{ragged2e}
fontsize: 12pt
urlcolor: blue
linestretch: 1.15
---
\justify
Rest of the document
My problem is that this is not printing my output as expected so I appreciate any suggestion or comment.

RMarkdown: citecolor LaTeX option not being used

I am trying to create a JSS article using RMarkdown, but am not able to get options that typically get used with pdf_document, in particular, the citecolor option.
Here is an MWE, which is the standard JSS template that ships with the rticles package:
---
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: name#company.com
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \\pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
output: rticles::jss_article
citecolor: blue
references:
- id: fenner2012a
title: One-click science marketing
author:
- family: Fenner
given: Martin
container-title: Nature Materials
volume: 11
URL: 'http://dx.doi.org/10.1038/nmat3283'
DOI: 10.1038/nmat3283
issue: 4
publisher: Nature Publishing Group
page: 261-263
type: article-journal
issued:
year: 2012
month: 3
---
# Introduction
[#fenner2012a]
# References
This does not highlight the reference to be blue. Do I have to adapt the entire template to change the one parameter?

Resources