I'm trying to follow this pandoc example to add multiple authors to an Rmarkdown file in the yaml metadata block. The pdf will generate in RStudio (Version 0.98.932), but there is no author information.
---
title: 'This is the title: it contains a colon'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
I'd also like to customize the heading a bit more and add a subtitle. Possible?
I just found out that it is possible to add subtitles to R markdown PDF output. I am using R 3.2.2 and RStudio 0.99.473 in Ubuntu 14.04.
---
title: 'This is the title: it contains a colon'
subtitle: 'This is the subtitle'
output: pdf_document
---
The default latex template in rmarkdown does not support author affiliations or subtitles. It does support multiple authors however, the correct yaml syntax is
---
title: 'This is the title: it contains a colon'
author:
- Author One
- Author Two
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output:
pdf_document:
template: NULL
---
If you want to customize your header, the best approach is to modify the latex template, found here to suit your needs. Then copy it to your local directory and pass it to the header in the template field.
As explained in the main answer, the default R Markdown template does not support author affiliations. While users can edit the template file to add their own custom YAML fields, there are easier some workarounds you can use for PDF or HTML outputs.
HTML Outputs
You can use the recently released radix template. First you must install the package:
install.packages("radix")
Once installed, you must set the
---
title: "Radix for R Markdown"
description: |
Scientific and technical writing, native to the web
date: May 4, 2018
author:
- name: "JJ Allaire"
url: https://github.com/jjallaire
affiliation: RStudio
affiliation_url: https://www.rstudio.com
- name: "Rich Iannone"
url: https://github.com/rich-iannone
affiliation: RStudio
affiliation_url: https://www.rstudio.com
output: radix::radix_article
---
Your content
PDF Outputs
You can use premade templates, and there are some good examples within the rticles package. First we must install the package:
install.packages("rticles")
Once Installed, you can use one of the templates, such as the Journal of Statistical Software:
---
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \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
---
If you render a pdf, LaTex use authors' footnote for affiliations (i.e. converting numbering in symbles). Try
---
title: 'This is the title: it contains a colon'
subtitle: 'This is the subtitle'
author:
- Author One^[University of Somewhere]
- Author Two^[University of Nowhere]
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
I've found a solution to your subtitle part of the question here: https://stackoverflow.com/a/41444545/14027216
You can add subtitle by adding subtitle: to your code and multiple subtitles can be added as follow:
---
title: 'This is the title: it contains a colon'
subtitle: |
| 'subtitle 1'
| 'subtitle 2'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
You can add more than two subtitles, but I don't know the maximum amount. Each subtitle will be displayed in new line.
I've also had this problem. Following the suggestion from #tmpname12345 I modified the latex template (default.tex) and the html template (default.html) to render subtitles. This pull request is on github rstudio/rmarkdown if you want the code quickly, and looks like it will be standard in rmarkdown next time they push to CRAN.
Add to the answer by Ze Grisi, i just discovered adding html heading tags into the yaml works to adjust the font in the title and subtitle. Note the quotation marks are no longer needed.
---
title: 'This is the title: it contains a colon'
subtitle: <h1>This is the subtitle</h1>
output: pdf_document
---
For a more dramatic effect add an underline to the subtitle
---
title: 'This is the title: it contains a colon'
subtitle: <h1><u>This is the subtitle</u></h1>
output: pdf_document
---
Using a solution for latex here enter link description here by #greg. I put the latex code into rmarkdown yaml header with some changes and it does the job.
---
title: 'Some Title'
author: Author One$^1$ \and
Author Two$^2$ \and
Author Three$^3$
date: $^1$Organization 1 \newline
$^2$Organization 2 \newline
$^3$Organization 3
\newline
\newline
\today
output:
---
The trick is to put the affiliations into date tag.
Related
I am working on a project in RStudio that takes in multiple rmd files and a yml file and uses the bookdown render_book() function to produce paginated output that can be converted to pdf.
The bookdown code is as follows:
bookdown::render_book("prog1.Rmd", "bookdown::gitbook", config_file = config_yml)
bookdown::render_book("prog1.Rmd", "pagedown::html_paged", config_file = config_yml)
The config_yml file:
book_filename: "Report Output"
delete_merged_file: true
new_session: yes
rmd_files: ["Start.Rmd", "prog1.rmd", "appendix.rmd"]
output_dir: ./fakedir/
language:
label:
fig: "FIGURE "
tab: "TABLE "
before_chapter_script: "./fakename.R"
The specifications from the Start.rmd:
---
title: "Report"
subtitle: "`r text`"
date: "`r datetext`"
site: bookdown::bookdown_site
classoption: oneside
documentclass: book
link-citations: yes
description: "My Report"
---
Historically this has caused no issues, with the first bookdown call creating an html doc and the second creating a paginated version. Recently, with no code changes, the paginated version will not open properly once created. It only shows the title page followed by two blank pages. I have thus far been unable to find a reason for this. I am hoping for either a solution to this issue or an alternative method to producing a paginated document. Let me know if more info/code is needed.
I recently installed the "rticles" package in R to automatically set up a journal article template in RMarkdown. I've been pretty impressed with it so far, but I'd like to be able to change the font. Surely this is possible somehow, but I have been unable to find any online resource explaining how to do it.
I am interested in knitting to PDF.
Here is the YAML at the top of my RMarkdown script:
---
title: This title
author:
- name: This author
email: t.author#thisPlace.com
affiliation: This institute
address:
- code: This institute
address: Street, City, State, etc.
abstract: |
This is the abstract.
It consists of two paragraphs.
keywords: "fun, happiness"
journal: "This Elsevier Journal"
date: "`r Sys.Date()`"
output: rticles::elsevier_article
---
I generated this by running the following line of code in R:
rmarkdown::draft("Test.Rmd", template = "elsevier_article", package = "rticles")
So where in all of this can I control font? Before using "rticles" I used to change the font by changing the latex engine and then specifying the font as follows:
---
title: This title
author: "This author"
date: "`r Sys.Date()`"
output:
pdf_document:
toc: yes
toc_depth: 4
fig_caption: TRUE
df_print: kable
latex_engine: xelatex
mainfont: Calibri Light
---
Is it possible to do something analogous to this in "rticles"?
The way you control fonts is analogous to what you did before:
---
title: This title
author:
- name: This author
email: t.author#thisPlace.com
affiliation: This institute
address:
- code: This institute
address: Street, City, State, etc.
abstract: |
This is the abstract.
It consists of two paragraphs.
keywords: "fun, happiness"
journal: "This Elsevier Journal"
date: "`r Sys.Date()`"
output:
rticles::elsevier_article:
latex_engine: xelatex
mainfont: Calibri Light
---
I am using a r-markdown rticles journal template to prepare a manuscript. Almost all rticles templates place the abstract in the YAML header section. I am not able to insert inline r code to the abstract in YAML. I could move the abstract to the text section to insert inline r code. However, the final format would also change. In biomedical field, abstracts often include some numbers from data. What is the best way to add r inline code to the abstract with a rticles journal template? Thanks
Edit: I have just realized that r code for analysis can be placed before the YAML header section. This will solve my problem. Here is a shorten version using Elsevier Journal template:
```{r, echo=FALSE, include=FALSE}
n <- length(mtcars$mpg)
```
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice#example.com
affiliation: Some Institute of Technology
footnote: Corresponding Author
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
abstract: |
There are `r n` observations.
journal: "An awesome journal"
date: "`r Sys.Date()`"
bibliography: mybibfile.bib
csl: elsevier-harvard.csl
output: rticles::elsevier_article
---
However, the journal template in the YAML header is no longer working. Now, I am back to where I started.
Input data
I prepared an example Rmd file with references to figure, table and equation, setting as an output 'bookdown::pdf_document2'. It compiles without errors to PDF.
I placed it on dropbox:
https://www.dropbox.com/sh/zmu0a4wq95ywssv/AAD-nHlkDiLknLk2NVR4Xup3a?dl=0
Question
Now I wish to set as an output format 'rticles::elsevier_article'
How can I do that?
Issue
When I change output line from:
bookdown::pdf_document2
to
rticles::elsevier_article
I'm receiving an error message.
Even if I remove other parameters from output:
I still receive an error message:
! Undefined control sequence.
Accented characters when input "as is" do not appear to behave well with elsevier_article. See suggestions below.
Bare-bones document
Here is a bare-bones document using rticles::elsevier_article:
---
title: "Sample document"
author:
- name: "Mateusz Kędzior"
affiliation: Some Institute of Technology
email: Mateusz#example.com
footnote: Corresponding Author
- name: Żąćł Źęń
csl: https://www.zotero.org/styles/geoderma
output:
rticles::elsevier_article:
citation_package: natbib
keep_tex: yes
number_sections: yes
toc: no
keywords: keywordA, keywordB
abstract: This is a sample abstract \newline This is the second line of abstract.
---
Hello world.
which renders with no complaints:
Reference with accents
Now, we wish to add a reference with accents. We follow the answer here: https://tex.stackexchange.com/questions/57743/how-to-write-%C3%A4-and-other-umlauts-and-accented-letters-in-bibliography. I imported your bibliography into Zotero, and then exported the item with a "Central European (ISO)" encoding (not UTF-8) to obtain
#article{kedzior_this_2018,
title = {This is sample title only {\k A} {\L }},
volume = {99},
url = {http://megooglethat.com/},
journal = {Some journal},
author = {K{\k e}dzior, Mateusz and {\'Z}{\k e}{\'n}, {\.Z}{\k a}{\'c}{\l }},
year = {2018},
keywords = {keywordC},
pages = {21 -- 31}
}
The R Markdown document now becomes
---
title: "Sample document"
author:
- name: "Mateusz Kędzior"
affiliation: Some Institute of Technology
email: Mateusz#example.com
footnote: Corresponding Author
- name: Żąćł Źęń
csl: https://www.zotero.org/styles/geoderma
output:
rticles::elsevier_article:
citation_package: natbib
keep_tex: yes
number_sections: yes
toc: no
biblio-files: bibliography2.bib
keywords: keywordA, keywordB
abstract: This is a sample abstract \newline This is the second line of abstract.
---
## Citations and references
Let me cite an article: [#kedzior_this_2018]
# References
I then knited this in RStudio, but realised that I had to get the tex output and rebuild it (outside of RStudio) to get the desired output
Other problems
For accented characters in figure captions, encode them accordingly (as with the bibliography). You may find http://w2.syronex.com/jmr/latex-symbols-converter helpful. In addition, to the best of my knowledge bookdown style cross-referencing does not work with rticles. If you have follow-up questions, you may get more helpful answers if you break your question down into smaller chunks.
I've added a bit of updated material to the commenthttps://github.com/rstudio/rticles/issues/92#issuecomment-402784283 where it states (may be updated):
output:
bookdown::pdf_document2:
base_format: rticles::elsevier_article
number_sections: yes
such that the way I've had this work is using pdf_book versus pdf_document2:
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
number_sections: yes
This allows for figure and table referencing within an rticles document.
How to add author affiliation in a new line in an rmarkdown beamer presentation?
---
title: "This is the title"
author: "Author"
date: "Thursday, April 09, 2015"
output: beamer_presentation
---
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
The desire title slide should be
This is the title
Author
Affiliation
Thursday, April 09, 2015
If you use pipes | you can break the author line into multiple lines:
---
title: "The title"
author: |
| The author
| The affiliation
date: "9 April 2015"
output: beamer_presentation
---
Output:
Edit (can we play with the title and author/affiliation fonts?):
If you want to change the different font sizes, I recommend playing with the includes: in_header option of your presentation's header (check this RStudio link for specifics).
This points to a simple .tex file on your computer where you can add LaTeX commands specifically for your presentation's preamble. You could therefore have a file called preamble.tex in your Desktop, and use the \setbeamerfont{XX}{size={\fontsize{YY}{ZZ}}} command, where XX is the specific thing you want to change (title, author); YY is the font size to apply; and ZZ is the skip line (in pt) (also see this link for more details).
So for your example, we have:
preamble.tex file at your Desktop (or wherever you want) containing just two lines:
\setbeamerfont{title}{size={\fontsize{30}{25}}}
\setbeamerfont{author}{size={\fontsize{5}{20}}}
Your foo.Rmd file:
---
title: "The title"
author: |
| The author
| The affiliation
output:
beamer_presentation:
includes:
in_header: ~/Desktop/preamble.tex
---
## R Markdown
This is an R Markdown presentation.
Markdown is a simple formatting syntax for
authoring HTML, PDF, and MS Word documents.
And the output will be:
and you should be able to have multiple authors and institutions
title: This is the title
author:
- Author Juan$^1$
- Author Tu$^2$
institute:
- $^1$Juans Casa
- $^2$Tus Place
date: "Thursday, April 09, 2015"
output:
beamer_presentation
The proper way to deal with affiliation in beamer is through \institute{} (see this answer on tex.SE).
Current solution (pandoc version >= 1.17)
Starting with pandoc 1.17, the institute field is present in the default beamer template, so all you need to do if you have the proper version is:
---
title: "This is the title"
author: "Author"
institute: "Affiliation"
date: "Thursday, April 09, 2015"
---
Old answer
Might be needed if you use an older pandoc version (< 1.17) or while rmarkdown's default beamer template has not been updated.
To make this work with pandoc, you could edit your beamer template. If you have not edited it yet, you can create it with:
pandoc -D beamer > ~/.pandoc/templates/default.beamer
Then, open the file and add this after the author information:
$if(institute)$
\institute[]{$institute$}
$endif$
Finally, add the institute option to your yaml:
---
title: "This is the title"
author: "Author"
institute: "Affiliation"
date: "Thursday, April 09, 2015"
---
If you are using rmarkdown, you may have to specify the template:
---
title: "This is the title"
author: "Author"
institute: "Affiliation"
date: "Thursday, April 09, 2015"
output:
beamer_presentation:
template: ~/.pandoc/templates/default.beamer
---
There are two advantages to using this over a multiline author.
some beamer theme use the author field and/or the institute field, for instance to repeat it at the bottom of each slide. A multiline author would mess this up.
this allow for a finer control of the title slide elements: you can have a different font family and size for author and affiliation information for instance:
\setbeamerfont{institute}{size={\fontsize{5}{20}}}