Adding line number when using rticles::elsevier_article

Viewed 262

I am using rticles::elsevier_article to write a manuscript. I am not able to add the linenumber properly. What I did:

      header-includes:
         - \usepackage{lineno}
         - \linenumbers
     output: 
        bookdown::pdf_book:
        base_format: rticles::elsevier_article

But, in this case when having equations the line numbers are not added, and neither the sections where the equations are embedded. Any suggestion?

1 Answers

Seems like your YAML is malformatted. Better to do it like this:

bookdown::pdf_book:
  base_format: rticles::elsevier_article
  includes:
    in_header: "preamble.tex"

Then add additional LaTeX header lines to preamble.tex:

\usepackage{booktabs}
\usepackage{lineno}
\linenumbers

Example

index.Rmd

--- 
title: "A Minimal Book Example"
author: "You"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output:
  bookdown::pdf_book:
    base_format: rticles::elsevier_article
    includes:
      in_header: "preamble.tex"
abstract: "This is your awesome abstract"
---

# Introduction

```{r, results='asis'}
cat(
  stringi::stri_rand_lipsum(1)
)
```

(The code chunk requires the stringi package to be installed.)

enter image description here

Related