1

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).

Alvin Tan
  • 53
  • 3
  • You should include a minimal papaja Rmd document in your question. Then people who are new to papaja but not to R Markdown could help you. – user2554330 Oct 13 '22 at 19:04

1 Answers1

1

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"
```

* * * *
crsh
  • 1,699
  • 16
  • 33