Closed phargarten2 closed 3 years ago
I also cited this issue in the YAML package as the error is from a yaml function.
If it's in quotes and properly escaped it works fine.
---
title: "\\pkg{Foo}: A Package About Foo"
author: "Someone"
date: "1/4/2021"
output: html_document
---
Thank you. It sure does (though the output suggested is using rmarkdown::html_document()
rather than
rticles::rjournal_article()`). The same sort of logic though works in this case (see below).
---
title: "\\pkg{foo}: A Package About Foo" #Adding \pkg{Foo} throws an error in yaml.
author:
# see ?rjournal_article for more information
- name: Author One
affiliation: Affiliation
address:
- line 1
- line 2
url: https://journal.r-project.org
orcid: 0000-0002-9079-593X
email: author1@work
- name: Author Two
url: https://journal.r-project.org
email: author2@work
orcid: 0000-0002-9079-593X
affiliation: Affiliation 1
address:
- line 1 affiliation 1
- line 2 affiliation 1
affiliation2: Affiliation 2
address2:
- line 1 affiliation 2
- line 2 affiliation 2
- name: Author Three
url: https://journal.r-project.org
email: author3@work
affiliation: Affiliation
address:
- line 1 affiliation
- line 2 affiliation
abstract: >
An abstract of less than 150 words.
preamble: |
% Any extra LaTeX you need in the preamble
# per R journal requirement, the bib filename should be the same as the output
# tex file. Don't forget to rename the bib file and change this example value.
bibliography: RJreferences.bib
output: rticles::rjournal_article
When using a special command like '\pkg{}' in the title, what language are you thinking of? Is the syntax (the quotes and escape character "\") as if you are in LaTex, @spgarbet? It is interesting as the title in the YAML header is usually not quoted.
Once you get into special characters, like the colon in YAML, it needs to be escaped or quoted.
From this page: https://bookdown.org/yihui/rmarkdown/output-formats.html
If you are not sure if a string should be quoted or not, test it with the yaml package
and you can try:
> cat(yaml::as.yaml(list(title = "\\pkg{Foo}: A Package About Foo")))
title: '\pkg{Foo}: A Package About Foo'
Special characters lose their special meanings inside single quotes. You can also use double quotes, but backslashes need to be escaped (hence \\
).
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
Thank you for allowing me to compose an article for the R Journal without leaving the Markdown environment. I wanted to bring a matter to your attention as I was going over the journal's formatting instructions.
Frequently, the title of an article in the R Journal includes the name of the package. According to [the journal's instructions] (https://journal.r-project.org/share/proofreading-checklist.pdf),
For instance, I am writing an article in the R Journal about the package foo. I created a new R Journal Template with the filename
foo
and the title "Foo: A Package About Foo." Below is the header from the sample Rmarkdown document.Per the journal requirements, I need to change the text-style of
foo
in the title. So, if I add the tag "\pkg{}" in the title field of the YAML header such that the title now reads\pkg{Foo}: A Package About Foo
, I get the errorA simple solution is to add
\pkg{}
in the generated LaTex file, but such an approach is against the spirit of this package.More details can be found here: foo.zip
Thanks for your help!
By filing an issue to this repo, I promise that
xfun::session_info('rticles')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/rticles')
.I understand that my issue may be closed if I don't fulfill my promises.
Package Information: