@maycca please make sure to open the RMarkdown by choosing New Files from Template and select the Elsevier Journal version/template. The template(s) will be available after the rticles installation.
This will setup the article "infrastructure" (in particular the respective cls and other files). This also includes a mybibfile.bib example (thus, I would have not needed to comment the biblio out).
If you choose to save this in a sub-folder, make sure that your Rmd file is saved in that sub-folder.
As presented above/below change the output:
tag of the YAML to include the bookdown and baseformat rticles::elsevier_article pointer.
Check the use of colons and tabs carefully.
Based on the example above, you can then use the bookdown cross-referencing as shown below. I used
(i) an external (bookdown) figure caption defined before the code chunk using (ref:awesomeplotcaption)
. This is useful to keep the chunk options short(er).
(ii) a (bookdown) cross-reference to the figure \@ref(fig:awesomeplot)
. Please note that the \@ref(fig:...)
uses the chunk-name to make the pointer work. Thus, make sure your chunk-name comes with standard letters, numbers, and dashes, i.e. no underscore!
Hitting the knit button will do the magic!
---
title: Short Paper
author:
- name: Alice Anonymous
email: [email protected]
affiliation: Some Institute of Technology
footnote: Corresponding Author
- name: Bob Security
email: [email protected]
affiliation: Another University
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
abstract: |
This is the abstract.
It consists of two paragraphs.
journal: "An awesome journal"
date: "`r Sys.Date()`"
#bibliography: mybibfile.bib
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
---
# First Heading
Some cool introductory text.
And an even more fascinating plot.
(ref:awesomeplotcaption) A simple demo plot
```{r awesomeplot, fig.cap="(ref:awesomeplotcaption)"}
x <- -5:5
y <- x^2
plot(x,y)
```
More explanatory text.
Using bookdown cross-referencing, have again a closer look at Fig. \@ref(fig:awesomeplot).
This results in the following:
P.S. Focus on the cross-reference and ignore the code-chunk, this could be hidden with echo = FALSE
. The figure follows below (in this example, placed via LATEX). I truncated it to keep the figure manageable :)