RMarkdown: citecolor LaTeX option not being used - r

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?

Related

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

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.

Can't use PLOS rticles template with bookdown

Following this post, I'm trying to put #YihuiXie 's answer in practice with the PLOS template of rticles but it doesn't work. Any help would be very appreciated!
Below in a minimal example:
---
title: Title of submission to PLOS journal
author:
- name: Me
affiliation: Here
# output: rticles::plos_article
output:
bookdown::pdf_document2:
base_format: rticles::plos_article
---
# Introduction
Some text \#ref(fig:fig1)
# References {#references .unnumbered}
The error message reads
Error in pdf_book(..., base_format = rmarkdown::pdf_document) : formal argument "base_format" matched by multiple actual arguments
Calls: <Anonymous> -> create_output_format -> do.call -> <Anonymous>
Execution halted
You cannot change the base_format for bookdown::pdf_document2. You can do so for bookdown::pdf_book, though:
---
title: Title of submission to PLOS journal
author:
- name: Me
affiliation: Here
#output: rticles::plos_article
output:
bookdown::pdf_book:
base_format: rticles::plos_article
---
# Introduction
Some text \#ref(fig:fig1)
# References {#references .unnumbered}
Note to other readers: Make sure that .../rticles/rmarkdown/templates/plos_article/skeleton/PLOS-submission.eps is present in that directory.

remove facebook and twitter links in `bookdown` in R, Rmarkdown

I am using the bookdown package in R to write a gitbook, but I don't want the final book to have the sharing links to facebook, twitter. I am using something like this in the YAML
---
title: "A Minimal Book Example"
author: "SN"
date: "`r Sys.Date()`"
output:
bookdown::gitbook
gitbook_config:
sharing:
facebook: false
twitter: false
documentclass: book
link-citations: yes
description: "This book ... ."
---
but I am getting an error
Error in yaml::yaml.load(enc2utf8(string), ...) :
Scanner error: mapping values are not allowed in this context at line 6, column 19
Calls: <Anonymous> ... yaml_load_utf8 -> mark_utf8 -> <Anonymous> -> .Call
Execution halted
Can anyone help me in setting options in YAML so that no sharing options show up in the final rendering?
thanks!
SN
Two mistakes:
You omitted a colon after bookdown::gitbook;
gitbook_config should be config.
---
title: "A Minimal Book Example"
author: "SN"
date: "`r Sys.Date()`"
output:
bookdown::gitbook:
config:
sharing:
facebook: false
twitter: false
documentclass: book
link-citations: yes
description: "This book ... ."
---

Resources