The files to create an example PDF can be downloaded from https://osf.io/g7dbt/. To create the example PDF you will need to unzip the folder and open the “main.Rmd” file. Make sure that the current working directory is set to the folder in which the “main.Rmd” file is located (e.g., by opening the dissertation_example.Rproj file). All files are integrated in the “main.Rmd” file and the PDF can be created by knitting this “main.Rmd” file.

For more information on RMarkdown and papaja check out: https://libscie.github.io/rmarkdown-workshop/handout.html & https://github.com/crsh/papaja & https://crsh.github.io/papaja_man/ The following R packages (and their dependencies) need to be installed to knit the example file: papaja, afex, BayesFactor, and tidyr.

Below, some information on the “main.Rmd” file can be found. Chapter 2 serves as an example to demonstrate how to incorporate a research article into the dissertation document. To speed up the knitting process only parts of a published article were selected. If you want to read the entire article check out: https://doi.org/10.1098/rsos.160935. If you have feedback contact me: tobias.heycke@gmail.com

YAML header

Author and other information

The first few parts are not important as the first two pages need to be removed manually anyway. The running head (shorttitle) will be overwritten later.

title: "This page and the next page should be removed"
shorttitle:  "Subliminal Header"

author: 
  - name        : ""
    affiliation : ""

affiliation:
  - id          : ""
    institution : ""

Papaja settings

Most settings are self explanatory. The “class” argument is often only set to ‘doc’ or ‘man’ in papaja. A font size (11pt in this case) can be added and the page is set to twosided. This allows us to print page numbers on the left/right side of the PDF.

class: doc,11pt, twoside
lang: english
figsintext: yes
lineno: no
footnotelist: no
figurelist: no

Bibliography

I chose to combine all my sources in one Bib file. You could also add multiple Bib files by just adding them in a new line starting with a " - “.

bibliography:
  - Bibs/Diss.bib

Output and Appendix

In this section it is specified that a PDF is knitted and all appendices are added here. I had difficulties rendering appendices in the document from a RMD file. It might therefore be necessary to use the “render_appendix()” outside of this document in a different .rmd file first and add the .tex file to a folder. As you can see multiple appendices can be added from different folders. They will be named consecutively.

output:
  papaja::apa6_pdf:
    includes:
      after_body: 
      - Chapter01_files/Appendix_Chapter1.tex
      - croco/Appendix_croco.tex

Latex header

Arguments for the Latex file can be added when including them in “header-includes:”. I will write brief comments (starting with a %) about every command below each point. Check out the main Rmd file for a clean overview. Additional Latex packages or commands can of course be added.

header-includes:

    - \setcounter{tocdepth}{3} 
% change this number if you want more or less details (i.e., headers of lower or higher order) in your table of content (toc)

  - \addtolength\oddsidemargin {0.5cm}
  - \addtolength\evensidemargin {-0.5cm}
% The left pages are moved 0.5cm to the left and the right pages 0.5cm to the right so the document can be bound as a book

  - \linespread{1.2} 
% distance between lines (this number could be increased when adjusting the document to A5, just set this number and font size above higher)

  - \usepackage{setspace} 
%package loaded for the setstretch commadn below

  - \shorttitle{}
%The running head is overwritten with emtpy text here

  - \fancyheadoffset[L]{0pt}  
  - \fancyhf{}
  - \fancyhead[RO,LE]{\small\thepage} 
  - \renewcommand{\headrulewidth}{0pt}
%header settings so page numbers are displayed on the left/ right side of the page. I am not sure all settings are neccesary here but this worked for me.

  - \interfootnotelinepenalty=10000
% make sure footnotes are not divided on multiple pages

Main Text

On the following pages I use Latex to format the pages to my needs. I will give brief comments on each page:

Blank page

This commands creates a blank page without a page number.

\clearpage\mbox{}\thispagestyle{empty}\clearpage

This command tells the document to start counting at this page (page 3), as the first two pages will be removed.

\setcounter{page}{1}

Title page

Needs will be very different. This is the Layout from our Faculty. Just change the name, date and place of birth in case you need this layout. See comments behind some points for additional information.

\thispagestyle{empty}     % remove page number from this page
\begin{center}
\vspace*{10mm}            % start a bit lower on the page
\textbf{\Large An example document using RMarkdown and papaja to write your dissertation}\\

\begin{figure}[h]
\begin{center}
\includegraphics[width=!,totalheight=!,scale=0.18]{UzKSiegel.jpg}
\end{center}
\end{figure}
{\setstretch{1.7}         %set a larger distance between lines to fill the page
Inauguraldissertation\\
zur\\ 
Erlangung des Doktorgrades\\
der Humanwissenschaftlichen Fakultät\\
der Universität zu Köln  \\
nach der Prüfungsordnung vom 10.05.2010  \\
vorgelegt von  \\ 
\smallskip
\textbf{Tobias Heycke}\\      %you probably want to change this
\smallskip
aus  \\
Bergisch Gladbach  \\        %you probably want to change this
\smallskip
Tag der Abgabe: 01.01.1970\\ %you defiantely want to change this
}
\end{center}

Table of content

The table of content is created by Latex. I added a setstretch of 1 as I found that the line spacing for the main text did not look good for the toc. I added the flushleft command only so pandoc knew I was writing Latex as the “{” was otherwise evaluated as Markdown code and not Latex.

\begin{flushleft}
{\setstretch{1.0}
\tableofcontents
}
\end{flushleft}

Main text

Now all chapters can be included in the main text (see the main Rmd and Chapter Rmd files). I removed all YAML headers from the documents and just added my research articles.