Customizing the output of rticles::elsevier_article document class in r - 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 {-}

Related

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
---

Delete abstract from rticles::elsevier_article

I'd like to knit an article to a PDF document without an abstract. If I just leave out the abstract part in the YAML header, the Abstract headline is still produced in the document. Is there a way to drop this without changing the underlying function or document class?
I've tried such approaches as abstract: false or none which seem to work for some of the other YAML header arguments.
A reproducible YAML header which is a slightly modified version of the rticles package example:
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice#example.com
affiliation: Some Institute of Technology
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: "Corresponding Author"
- code: 2
text: "Equal contribution"
journal: "An awesome journal"
date: "`r Sys.Date()`"
bibliography: mybibfile.bib
#linenumbers: true
#numbersections: true
csl: elsevier-harvard.csl
output: rticles::elsevier_article
---
So the resulting document looks like this (the Abstract headline is what I'd like to get rid of):
The intermediate LaTex file generated by Pandoc has the following code in it:
\documentclass[]{elsarticle} %review=doublespace preprint=single 5p=2 column
%%% Begin My package additions %%%%%%%%%%%%%%%%%%%
\usepackage[hyphens]{url}
\journal{An awesome journal} % Sets Journal name
\usepackage{lineno} % add
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\usepackage{graphicx}
\usepackage{booktabs} % book-quality tables
%%%%%%%%%%%%%%%% end my additions to header
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\usepackage{fontspec}
\ifxetex
\usepackage{xltxtra,xunicode}
\fi
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
\fi
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
\bibliographystyle{elsarticle-harv}
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex]{hyperref}
\else
\usepackage[unicode=true]{hyperref}
\fi
\hypersetup{breaklinks=true,
bookmarks=true,
pdfauthor={},
pdftitle={Short Paper},
colorlinks=false,
urlcolor=blue,
linkcolor=magenta,
pdfborder={0 0 0}}
\urlstyle{same} % don't use monospace font for urls
\setcounter{secnumdepth}{0}
% Pandoc toggle for numbering sections (defaults to be off)
\setcounter{secnumdepth}{0}
% Pandoc citation processing
% Pandoc header
\begin{document}
\begin{frontmatter}
\title{Short Paper}
\author[Some Institute of Technology]{Alice Anonymous\corref{1}}
\ead{alice#example.com}
\author[Another University]{Bob Security}
\ead{bob#example.com}
\author[Another University]{Cat Memes\corref{2}}
\ead{cat#example.com}
\author[Some Institute of Technology]{Derek Zoolander\corref{2}}
\ead{derek#example.com}
\address[Some Institute of Technology]{Department, Street, City, State, Zip}
\address[Another University]{Department, Street, City, State, Zip}
\cortext[1]{Corresponding Author}
\cortext[2]{Equal contribution}
\begin{abstract}
\end{abstract}
\end{frontmatter}
\end{document}
Add
\renewenvironment{abstract}{}{}
to your header-includes. This will nullify the abstract environment.

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.

Customising R markdown pdf document

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

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