Knitting into a Word document in papaja - r

Probably a basic question but I can't see how to knit my RMarkdown document into a Word document. I've checked the various ReadMe's e.g. https://crsh.github.io/papaja_man/ but can't see anywhere where it is spelled out. Any help is appreciated.

If you are looking to produce a Word document in APA style using papaja you can change the default output specified in the YAML front matter to the following:
---
output: apa6_docx
---
This is also mentioned in the package manual.

I believe you have to specify it in your yaml header as such:
---
title: TITLE
author: AUTHOR
output: word_document
---
Also, the manual does note that there functions won't work when converting into word.

Related

Ouptut options ignored when using 'render_book' ('preamble'.tex' ignored)

I'm having some trouble to compile an entire document from many Rmd files by using the bookdown approach.
If I knit individual .Rmd files then 'preamble.tex' included in YAML options is taken into account.
If I render the book (with both approaches described here), then 'preamble.tex' is ignored.
To make things concrete, consider the following mwe:
preamble.tex:
\usepackage{times}
index.Rmd:
---
title: "My paper"
site: "bookdown::bookdown_site"
output:
bookdown::pdf_document2:
includes:
in_header: "preamble.tex"
---
01-intro.Rmd:
# Introduction
This chapter is an overview of the methods that we propose to solve an **important problem**.
Then, by knitting 'index.Rmd' or '01-intro.Rmd' the font indicated in 'preamble.tex' is used.
However when rendering with bookdown::render_book('index.Rmd',"bookdown::pdf_book", new_session = T) it is simply ignored.
What is more, in my actual project there are other output options that end up ignored. For example, I use toc: false and it works when knitting single files, but fails when rendering the document.
In this simple example it would be okay to use a single file, but my actual project has many chapters with R chunks within each of them. Thus, building a single file doesn't seem a good idea.
I appreciate any hints on what I am missing here.
Thanks in advance.
What you are missing here is that in your YAML header, preamble.tex is included for the bookdown::pdf_document2 output format and not bookdown::pdf_book, the format you pass to the output_format argument in bookdown::render_book(). For this reason, other YAML options (like toc: true) do not work either.
Running
bookdown::render_book('index.Rmd', "bookdown::pdf_document2", new_session = T)
instead should work.

How to translate title of `abstract` in a pandoc's markdown (e.g., Rmd) document?

In the YAML header of a pandoc's markdown file, it's possible to write an abstract. I wonder if there is a way to change the word "abstract" in the rendered document to something else like either word "summary" or equivalent in another language.
If not, what alternatives could be suggested? I'm using R Markdown.
p.s. My question is related to this comment.
Yes. But not automatically. You would have to redefine the abstract environment to start with a different header, or at least redefine the \abstractname variable as article.cls has this:
\newenvironment{abstract}{%
\titlepage
\null\vfil
\#beginparpenalty\#lowpenalty
\begin{center}%
\bfseries \abstractname %%%% This what you need to redefine
\#endparpenalty\#M
\end{center}}%
{\par\vfil\null\endtitlepage}
So you can do something like the following minimal example:
---
title: "Test Document"
author: "Some User"
output: pdf_document
abstract: >
One or two sentences describing it all.
header-includes:
\renewcommand{\abstractname}{My Very Own Summary}
---
## R Markdown
This is an R Markdown document.
which does what you desire:
If your main interest is in localization of your document, you can add an lang meta value to your document. E.g., setting lang: lt will give "Santrauka" instead of "Abstract" in the produced PDF.

How do I get a long (more than 1 page) bibliography to print in an R markdown beamer?

I have an issue rendering bibliographies covering more than one page as only the first one is printed using RMarkdown and beamer output.
The same question has been posted at http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html#comment-2398115545 but without any help.
---
title: "Sample Document"
output: beamer_presentation
bibliography: bibliography.bib
---
You can force a slide to be continued on the next one by setting its class to allowframebreaks. Just do this for your last slide. From the pandoc mailing-list:
## References {.allowframebreaks}
Edit: knitr has a setting that prevents this solution from working out of the box with rmarkdown. See this question for a solution.

First-line paragraph indenting in PDFs using R Markdown

I'm hoping this is a question with a simple answer. I am using Rmarkdown/knitr to author a PDF document (in RStudio). Many LaTeX classes (like article) automatically indent the first line of a paragraph of text, but Rmarkdown does not, nor can I figure out a way to do so.
Here's a simple example:
---
title: "minimal"
author: "prison rodeo"
output: pdf_document
---
This is an R Markdown document.
I would like this paragraph to be first-line indented, but it is not.
Using > indents the entire paragraph, which is not what I'm looking for. I've tried spaces/tabs at the beginning of each paragraph, and using \indent; neither seems to work. Any ideas?
The default Pandoc template includes an indent argument. If set to true, paragraphs start with an indentation.
----
title: "Title"
author: "Me"
output: pdf_document
indent: true
----
I believe the following in your YAML header will work the same and has the advantage of still compiling should you decide to knit your document to an HTML file (though, I haven't tested this).
----
title: "Title"
author: "Me"
header-includes:
- \setlength\parindent{24pt}
output:
pdf_document
----
If what you're after happens to be the default settings in other regards as well, you might also be interested in setting the \parskip option to its default setting, since it is otherwise set to {6pt plus 2pt minus 1pt}
header-includes:
- \setlength\parindent{24pt}\setlength{\parskip}{0.0pt plus 1.0pt}

How can I change paper size when using Knit PDF in RStudio?

By default the PDF documents created by the Knit PDF are US Letter size. Instead I would like to create A4 size documents. I have a feeling this should simple to change, either in the RStudio GUI or by adding an option to the metadata at the top of the Rmd file. Unfortunately I can't find any instructions how to do this. Is there a way to specify paper size, preferably within the Rmd file itself? I am still using RStudio version 0.98.953 but can upgrade if it would help.
I'd be grateful if someone could point me in the right direction.
OK, so I figured it out. In the .Rmd file's header, options documentclass and classoption get written into the preamble of the resulting .tex file. The article document class accepts a number of paper size options including a4paper. The header in the .Rmd file will then look something like this:
---
title: "Title"
author: "Name"
date: "Date"
output:
pdf_document
documentclass: article
classoption: a4paper
---
For more information see: http://rmarkdown.rstudio.com/pdf_document_format.html
At least in newer versions of the rmarkdown R package (and Pandoc) you can just set:
---
output: pdf_document
papersize: a4
---

Resources