Alvin Tan
Alvin Tan

Reputation: 53

Is it possible to move the abstract into a separate document for papaja?

The abstract is often the longest section in the YAML in a papaja Rmd, and I was wondering if it was possible to move this off into a separate document (e.g. another Rmd file) and include it via reference instead (just as other chapters can be).

Upvotes: 1

Views: 83

Answers (1)

crsh
crsh

Reputation: 1716

Here are two options: Text-references are built into papaja, but are a little more limited than using an external Lua-filter.

Text-references

You can use bookdown text-references for this. This way you can move the abstract into the body of the document.

---
title    : "Title"

abstract : "(ref:abstract)"

output   : papaja::apa6_pdf
---

(ref:abstract) Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Similarly, you could use an inline code chunk for the text reference to put the abstract into a separate document.

(ref:abstract) `r readlines()`

A limitation of this approach is that

The paragraph must not be wrapped into multiple lines, and should not end with a white space.

Lua-filters

A more flexible alternative is to use this Lua-filter that uses an abstract section from the document body.

---
title: "Title"

output:
  papaja::apa6_pdf:
    pandoc_args: ["--lua-filter", "path/to/abstract-to-meta.lua"]
---

# Abstract

The abstract text includes this.

* * * *

This text is the beginning of the document.

Here, the horizontal rule * * * * marks the end of the abstract. Again, here you could use a code chunk to include an external file.

# Abstract

```{r}
#| child: "path/to/abstract.md"
```

* * * *

Upvotes: 1

Related Questions