Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APA 7th edition template #342

Open
2 of 11 tasks
crsh opened this issue Jan 16, 2020 · 45 comments
Open
2 of 11 tasks

Add APA 7th edition template #342

crsh opened this issue Jan 16, 2020 · 45 comments
Milestone

Comments

@crsh
Copy link
Owner

crsh commented Jan 16, 2020

To summarize the previous discussion, for those who urgently need APA 7th edition: With the current version of papaja you can get most of the way like this:

  1. Make sure you are using the latest development version of papaja (remotes::install_github("crsh/papaja@devel"))
  2. (Install the apa7 LaTeX document class, unless your LaTeX distribution, like tinytex is setup to do this on the fly.)
  3. Make the following settings in the YAML front matter:
header-includes:
  - |
    \makeatletter
    \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}%
      {0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
      {-1em}%
      {\normalfont\normalsize\bfseries\typesectitle}}
    
    \renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}%
      {0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
      {-\z@\relax}%
      {\normalfont\normalsize\bfseries\itshape\hspace{\parindent}{#1}\textit{\addperi}}{\relax}}
    \makeatother

csl               : "`r system.file('rmd', 'apa7.csl', package = 'papaja')`"
documentclass     : "apa7"
output            : papaja::apa6_pdf

Note, that you currently cannot include the ORCID in the author note, as suggested in the apa7-manual, those YAML fields are currently not parsed.


Properly implementing support for APA 7th edition will require a little more work. I'll gather the required steps that I have identified, as of now, here. If I'm missing anything necessary adjustments, or if anyone has thoughts or suggestions about the implementation feel free to discuss. Also, this would be the time to rethink any design decisions regarding the R Markdown template (such as the setup of the font matter or naming of the options).

General

  • It seems unnecessary to add another "APA article (7th edition)" entry to the template list because the templates would be almost identical.
  • Create an R functions, such as apa7_*(), that generate the rmarkdown format. It may be worth considering, whether specialized functions for each edition are necessary. It seems easier and less confusing to just keep apa_*() and specify the version via the documentclass field in the front matter. Of course, the old functions would be kept for backward compatibility.
  • Ship a APA 7th edition CSL file (see Automate updating APA CSL #314)

PDF format

  • Add support for a ORCID element in the YAML author list and automatically add this information to the author note. This should be fairly straight forward for PDF (use \addORCIDlink{}{}) if I can make pandoc parse the contents of the author_note field.
  • Check how the definitions of \subsubsection{} and \paragraph{} have changed and adjust the default header includes accordingly.
  • Always position figure captions above the corresponding figure (for LaTeX approaches see this, this, and this SO post; for Rmarkdown see [this(https://stackoverflow.com/a/26743812/914024)]). This will be easy to do in Quarto.
  • Don't add & to author name concatination on title page and use \authornames and \authorsaffiliations (Add APA 7th edition template #342 (comment))

Word format

  • Create a pandoc word template for APA 7th edition.
  • Add support for a ORCID element in the YAML author list and automatically add this information to the author note. This will require to ship an ORCID icon with the template.
  • Adjust formatting of table captions generated by apa_table()
  • Adjust formatting of figure captions in docx_fixes-Lua-filter, i.e. create an version of the filter for APA 7th edition
@crsh crsh mentioned this issue Jan 16, 2020
@crsh crsh pinned this issue Jan 16, 2020
@jrennstich
Copy link

For some reason, folks who use the TeX package csquotes now need to add the following line in YAML for it to work:

csquotes          : true

It would be very useful to add this to the YAML options in the template.

@cjvanlissa
Copy link

Not sure how far this is, but the APA Publication Manual for the 7th edition is temporarily available for free during the Corona isolation period: https://apastyle.apa.org/blog/coronavirus-response?fbclid=IwAR2n0C1tz1xyG0420lMGFEvTmIT9Tz8lqoCRTJYY1v7ayldMg_ZxO-0AyK4

Maybe this is helpful to anyone currently contributing to this issue.

@raybecker
Copy link

raybecker commented Mar 26, 2020 via email

@cjvanlissa
Copy link

I apologize. It just reached me now.

@nikshl
Copy link

nikshl commented Sep 2, 2020

Thanks for this package and the work already invested in APA7 version. In my case the titles of tables and figures are written in serif font. For figures, the title is also written below the figure, which is different in APA7 (sans serif and above the figure). As a user, can I somehow adapt this myself or are updates planned?

@jlt10f
Copy link

jlt10f commented Sep 3, 2020

how do I install the apa7 Latex document class?

@nikshl
Copy link

nikshl commented Sep 4, 2020

You can find the necessary file here.
There may be easier ways, but I installed it manually with this instruction (see "Installing sty or cls files" in the most popular response on that page).

@crsh
Copy link
Owner Author

crsh commented Sep 7, 2020

In my case the titles of tables and figures are written in serif font. For figures, the title is also written below the figure, which is different in APA7 (sans serif and above the figure). As a user, can I somehow adapt this myself or are updates planned?

Are you looking to knit PDF or Word files?

@nikshl
Copy link

nikshl commented Sep 7, 2020

PDF.

@crsh
Copy link
Owner Author

crsh commented Sep 7, 2020

It's been a while since I found time to look at this more closely, but could you point me to where the new manual states that figure titles should be in a sans serif font? As far as I can tell it's set in the same font used for the text, no? Either way, you should be able to control the caption font using the caption package (see for example here).

As for the placement of the figure title: This should be controlled by the apa7 document class. The example in the documentation suggests that titles should be printed above the figure. If you can provide a minimal reproducible example I'd be happy to take a closer look at what's going on.

@nikshl
Copy link

nikshl commented Sep 7, 2020

It's been a while since I found time to look at this more closely, but could you point me to where the new manual states that figure titles should be in a sans serif font? As far as I can tell it's set in the same font used for the text, no? Either way, you should be able to control the caption font using the caption package (see for example here).

As for the placement of the figure title: This should be controlled by the apa7 document class. The example in the documentation suggests that titles should be printed above the figure. If you can provide a minimal reproducible example I'd be happy to take a closer look at what's going on.

Thank you! In fact, it seems to me that the font is not explicitly defined. On page 225, the manual for the title states: "The figure title appears one double-spaced line below the figure number in italic title case". On page 232, the figure checklist says: "Is the font sans serif within the image portion of the figure [...]?", which does not necessarily exclude other font types for the headline. However, in all examples of the manual, the headlines are set without serifs and therefore in a different font than the text. Anyway, the solution suggested above works fine for me.

Here a minimal reproducible example:

---
title             : "My Title"
csl               : "apa.csl" 
documentclass     : "apa7"
classoption       : doc 
output            : papaja::apa6_pdf

header-includes:
- \usepackage[font=sf]{caption}
---

```{r Example, fig.cap="Example Caption."}
boxplot(c(1,2,3))
```

@crsh
Copy link
Owner Author

crsh commented Sep 8, 2020

Regarding the placement of the figure caption below rather than above the figure I'm a little bit at a loss. rmarkdown automatically places \caption{} after \includegraphics{}. If you edit the TeX file and move the caption up, it will be displayed above the figure. It was my understanding, however, that this sort of behavior can be controlled via the caption package by setting position=above or figureposition=above without moving code around. However, from playing with the apa7-example it seems that this option is set but has no effect. When I log the caption setup I get

Caption Info: Option list on `figure'
Caption Data: {position=above,skip=0pt,labelformat=figurelabel,labelsep=apalabelsep,textfont=it,skip=10pt} on input line 4.

So this suggests that the figure caption should be displayed above the figure. This is the TeX example I used:

\documentclass[man]{apa7}
\title{Figure caption test}

\showcaptionsetup{figure}

\begin{document}
\maketitle

\section{Method}
\subsection{Participants}
We had a lot of people in this study, show in Figure \ref{fig:Figure1}.

\begin{figure}[htbp]
    \includegraphics[bb=0in 0in 2.5in 2.5in, height=1.4in, width=1.4in]{Figure1.pdf}
    \caption{This is my figure caption.}
    \label{fig:Figure1}
\end{figure}

\end{document}

Maybe @dan-weiss can help?

@dan-weiss
Copy link

@crsh I struggled with the caption placement as well when developing the package. It turns out the caption LaTeX package describes this exact case:

(Please note that position=top does NOT mean that the caption is actually placed at the top of the figure or table. Instead the caption is usually placed where you place the \caption command.) Caption package manual, page 15

@crsh
Copy link
Owner Author

crsh commented Sep 8, 2020

Huh, thanks for that; that's news to me. It seems a different fix is needed. I just tried out floatrow:

\usepackage{floatrow}
\floatsetup[figure]{capposition=top}

This get's the job done but seems to create some problems with the setup of endfloat, i.e., floats are placed in text. The endfloat manual advises to load floatrow before endfloat. Is there some way to do this with apa7? Any other ideas how to address this issue?

@dan-weiss
Copy link

@crsh See if this helps:
I'm supposed to load some packages BEFORE the document class?

For pure latex documents, the caption command need to be moved before the figure/table manually in the code.

@crsh
Copy link
Owner Author

crsh commented Sep 18, 2020

Unfortunately, floatrow does not seem to play well with \RequirePackage. Thanks for the suggestions, anyway! I have opend a question on SO. Maybe someone over there has an idea how to solve this.

@crsh
Copy link
Owner Author

crsh commented Sep 22, 2020

@nikshl We got a nice answer at SO. This will require postprocessing of the TeX file, so it's a little inconvenient but can be done. You may need to do this by hand until I get around to it.

@nikshl
Copy link

nikshl commented Sep 24, 2020

Great! Many thanks to all who have contributed to the solution so far.

crsh added a commit that referenced this issue Oct 19, 2020
- Semi-automates updating of CSL files
- Ads options to not disambiguate author names and annotated references (e.g., meta-analysis)
- Adds APA 7th edition #342
@jrennstich
Copy link

I found a very easy solution to adding the ORICD logo and link based on the APA rules.

In the YAML header, add

authornote: |
  Firstname M. Lastname, \orcidlink{0000-0000-0000-0000} [https://orcid.org/0000-0000-0000-0000]()https://orcid.org/0000-0000-0000-0000.

and

header-includes   : 
  - \usepackage{orcidlink}

If you have installed tinytex (which you should because it's awesome 😎) it will install the orcidlink package the first time you render a PDF.

@dan-weiss
Copy link

@jrennstich FYI, the apa7 class includes the \addORCIDlink command natively. It can be used as follows:

\addORCIDlink{First M. Last}{0000-0000-0000-0000}

@jrennstich
Copy link

@jrennstich FYI, the apa7 class includes the \addORCIDlink command natively. It can be used as follows:

\addORCIDlink{First M. Last}{0000-0000-0000-0000}

Great! Thanks

@sbw78
Copy link

sbw78 commented Feb 23, 2021

@nikshl We got a nice answer at SO. This will require postprocessing of the TeX file, so it's a little inconvenient but can be done. You may need to do this by hand until I get around to it.

I cannot get the fix described in SO to work when manually postprocessing the TeX file. I am still getting conflicts with \RequirePackage and the figure captions are still below the figure. The only fix I have been able to work out is to manually move the \caption statement to before the figure placement, after \begin{figure}. Any update on a better solution? Thanks.

@crsh
Copy link
Owner Author

crsh commented Feb 24, 2021

Sorry, not at this point. If you can share a minimal working example, this may help to develop a more robust solution.

@mschrein
Copy link

mschrein commented Mar 3, 2021

I think @sbw78 's point refers to what @dan-weiss mentioned previously:

For pure latex documents, the caption command need to be moved before the figure/table manually in the code.

This shows the caption below the figure:

\begin{figure}[htbp]
    \includegraphics[bb=0in 0in 2.5in 2.5in, height=1.4in, width=1.4in]{Figure1.pdf}
    \caption{This is my figure caption.}
    \label{fig:Figure1}
\end{figure}

When moving the \caption statement before the \includegraphics statement, the caption is now displayed above the figure.

\begin{figure}[htbp]
    \caption{This is my figure caption.}
    \includegraphics[bb=0in 0in 2.5in 2.5in, height=1.4in, width=1.4in]{Figure1.pdf}
    \label{fig:Figure1}
\end{figure}

I think this is currently the easiest solution and it requires no postprocessing if you use the LaTeX code directly.

@crsh
Copy link
Owner Author

crsh commented Mar 3, 2021

Sure, but his is complicated by the fact that the figure code is generated automatically by rmarkdown when you make plots in R. As far as I'm aware, there is no way to change this behavior in rmarkdown. I find the solution to manually alter the LaTeX code rather unsatisfactory, especially if you have many figures in your manuscript.

@mschrein
Copy link

mschrein commented Mar 4, 2021

Indeed. As a workaround you could export the generated figures to (for example) pdf and then load them back in with \includegraphics but, well, this is quite unsatisfactory too.

@mdkraemer
Copy link

First of all, a huge thank you for developing and maintaining this package! A small error I caught when switching to APA 7th for my current manuscript was that the author list on the title page displays both "and" and "&" if I include more than two authors. I did not see this bug reported elsewhere. Here is a reproducible example:

---
title             : "My Title"

author: 
  - name          : "Author1"
  - name          : "Author2"
  - name          : "Author3"
  - name          : "Author4"

csl               : "apa.csl"
documentclass     : "apa7"
classoption       : "man"
output            : papaja::apa6_pdf
---

@crsh
Copy link
Owner Author

crsh commented Apr 2, 2021

Interesting. The automatic addition of "and" seems to be a new feature in the apa7 latex class.

@leahymr
Copy link

leahymr commented Apr 5, 2021

I am trying to get the apa7 latex class to operate in student mode so I can write documents with RMarkdown, but I can't figure out how to do it (I'm new at papaja, but have only used RMarkdown for a few months).

I have installed the latest dev version of papaja and installed apa.csl from http://www.zotero.org/styles/apa.csl. I have added the csl, documentclass, classoption and output YAML tags from the previous post. With classoption : "stu" I can see the Course Title, Professor Name, and Due Date on the first page, but can't figure out how to modify them (I've tried LaTex commands and straightforward YAML tags). I'd also like to understand how to change the font and font size.

Ultimately, I'm interested in trying to build a RMarkdown version of the reference documents on the APA web site, so that people can see what papaja can do and what commands are required to generate the documents.

@dan-weiss
Copy link

Interesting. The automatic addition of "and" seems to be a new feature in the apa7 latex class.

@crsh Starting with version 2.00, the apa7 class now expects a comma separated list for authors to allow for flexible affiliation superscripting (per APA 7th edition style). It will localize the last author separator (e.g. 'and') into the supported languages:

\authorsnames[⟨comma separated list of superscripts⟩]{⟨comma separated list of authors name(s)⟩}: Authors names (if more than 1 author)

There are examples on page 6 of the manual

@crsh crsh added this to the paper milestone Jul 8, 2021
@nickhaf
Copy link

nickhaf commented Jul 14, 2021

Another workaround for placing figure captions above the plot (and also including figure notes) that can be directly included in rmarkdown and doesn't require postprocessing of the TeX file:
https://stackoverflow.com/questions/61344827/how-to-create-a-figure-note-below-the-figure-caption-in-r-markdown-and-bookdown

@pablobernabeu
Copy link

pablobernabeu commented Jul 15, 2021

Interesting. The automatic addition of "and" seems to be a new feature in the apa7 latex class.

@crsh Starting with version 2.00, the apa7 class now expects a comma separated list for authors to allow for flexible affiliation superscripting (per APA 7th edition style). It will localize the last author separator (e.g. 'and') into the supported languages:

\authorsnames[⟨comma separated list of superscripts⟩]{⟨comma separated list of authors name(s)⟩}: Authors names (if more than 1 author)

There are examples on page 6 of the manual

Hello @dan-weiss: I'm using the very helpful apa7 class as well as papaja, and I have run into the same issue with the redundant ' and & ' characters. I have tried to solve it by deleting the author in the YAML, and setting \authorsnames and \authorsaffiliations within header_includes, as below:

header-includes   : 
  - \authorsnames[1, 2, 1]{first author, second author, third author}
  - \authorsaffiliations{{first affiliation}, {second affiliation}}

Unfortunately, I get the following error:

! LaTeX Error: Command \c@NumberOfAuthors already defined.
               Or name \end... illegal, see p.192 of the manual.

Alternative errors precluded

I have ascertained that the error is not caused by alternative reasons, such as the lack of the default author field in the YAML, or by an erroneous use of header-includes. When I do not add the \authorsnames and \authorsaffiliations fields, I can knit the document with the apa7 class without a problem. Other parameters passed to header-includes work fine.

Reproducing the error

The error can be reproduced by opening an APA 6 template from the papaja package in RStudio, applying the apa7 class as described above, and adding the header-includes field that I pasted above to the YAML.

Thank you very much for your attention. I would be very grateful if you could provide some help.

@dan-weiss
Copy link

@pablobernabeu It sounds like both \authorsnames{} and \author{} are getting defined in the latex file. Make sure that an \author{} command is not being generated as the latex cls maps that to \authorsnames{} to maintain some backwards compatibility (and the \authorsnames{} command can be called only once).

I am not personally a user of papaja/R. If this doesn't resolve the issue, you can send me a .tex file that demonstrates the issue and I would be happy to troubleshoot.

@pablobernabeu
Copy link

pablobernabeu commented Jul 19, 2021

UPDATED

The phantom parameters can be disabled in advance (instead of manually editing the .tex file) by adding three lines to the header-includes preamble. See: https://stackoverflow.com/a/70658799/7050882



PREVIOUSLY:

@dan-weiss: Thanks a lot! Please find the .tex file below (this was automatically generated by the failed knit command in R). The document doesn't compile as it is below. However, when both \author{\phantom{0}} and \affiliation{\phantom{0}} are manually deleted, it does compile well. This is helpful. However, to allow my colleagues to reproduce my analyses, I would be very grateful indeed for your help troubleshooting--i.e., with the aim of automatically disabling \author and \affiliation when \authorsnames and \authorsaffiliations are present.

% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
  12pt,
  english,
  man,floatsintext]{apa7}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{setspace}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  pdftitle={Long title},
  pdflang={en-EN},
  pdfkeywords={keywords},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
  \let\oldparagraph\paragraph
  \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
  \let\oldsubparagraph\subparagraph
  \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
% Manuscript styling
\usepackage{upgreek}
\captionsetup{font=singlespacing,justification=justified}

% Table formatting
\usepackage{longtable}
\usepackage{lscape}
% \usepackage[counterclockwise]{rotating}   % Landscape page setup for large tables
\usepackage{multirow}		% Table styling
\usepackage{tabularx}		% Control Column width
\usepackage[flushleft]{threeparttable}	% Allows for three part tables with a specified notes section
\usepackage{threeparttablex}            % Lets threeparttable work with longtable

% Create new environments so endfloat can handle them
% \newenvironment{ltable}
%   {\begin{landscape}\begin{center}\begin{threeparttable}}
%   {\end{threeparttable}\end{center}\end{landscape}}
\newenvironment{lltable}{\begin{landscape}\begin{center}\begin{ThreePartTable}}{\end{ThreePartTable}\end{center}\end{landscape}}

% Enables adjusting longtable caption width to table width
% Solution found at http://golatex.de/longtable-mit-caption-so-breit-wie-die-tabelle-t15767.html
\makeatletter
\newcommand\LastLTentrywidth{1em}
\newlength\longtablewidth
\setlength{\longtablewidth}{1in}
\newcommand{\getlongtablewidth}{\begingroup \ifcsname LT@\roman{LT@tables}\endcsname \global\longtablewidth=0pt \renewcommand{\LT@entry}[2]{\global\advance\longtablewidth by ##2\relax\gdef\LastLTentrywidth{##2}}\@nameuse{LT@\roman{LT@tables}} \fi \endgroup}

% \setlength{\parindent}{0.5in}
% \setlength{\parskip}{0pt plus 0pt minus 0pt}

% Overwrite redefinition of paragraph and subparagraph by the default LaTeX template
% See https://github.com/crsh/papaja/issues/292
\makeatletter
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}%
  {0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries\itshape\typesectitle}}

\renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}%
  {0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
  {-\z@\relax}%
  {\normalfont\normalsize\itshape\hspace{\parindent}{#1}\textit{\addperi}}{\relax}}
\makeatother

% \usepackage{etoolbox}
\makeatletter
\patchcmd{\HyOrg@maketitle}
  {\section{\normalfont\normalsize\abstractname}}
  {\section*{\normalfont\normalsize\abstractname}}
  {}{\typeout{Failed to patch abstract.}}
\patchcmd{\HyOrg@maketitle}
  {\section{\protect\normalfont{\@title}}}
  {\section*{\protect\normalfont{\@title}}}
  {}{\typeout{Failed to patch title.}}
\makeatother
\shorttitle{SHORTTITLE}
\keywords{keywords}
\usepackage{csquotes}
\authorsnames[1, 2, 1]{first author, second author, third author}
\authorsaffiliations{{first affiliation}, {second affiliation}}
\ifxetex
  % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
  \usepackage{polyglossia}
  \setmainlanguage[]{english}
\else
  \usepackage[main=english]{babel}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
\fi
\ifluatex
  \usepackage{selnolig}  % disable illegal ligatures
\fi

\title{Long title}
\author{\phantom{0}}
\date{}


\authornote{

note note note note note note note note note note note note

}

\affiliation{\phantom{0}}

\abstract{
abstract abstract abstract abstract abstract abstract abstract
}



\begin{document}
\maketitle

\setstretch{1.5}
test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text


\end{document}

@padpet
Copy link

padpet commented Oct 30, 2021

I found that the apa7 is available as a package in the MikTex Console and installed it. However, following the 3 steps at the top of this page, I keep getting an error.

This is a shortened version of my code which still produces the error.

---
title             : "My Title"

author: 
  - name          : "Author1"
  - name          : "Author2"
  - name          : "Author3"
  - name          : "Author4"

header-includes:
  - |
    \makeatletter
    \renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}%
      {0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
      {-1em}%
      {\normalfont\normalsize\bfseries\typesectitle}}
    
    \renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}%
      {0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
      {-\z@\relax}%
      {\normalfont\normalsize\bfseries\itshape\hspace{\parindent}{#1}\textit{\addperi}}{\relax}}
    \makeatother

csl               : `r system.file("rmd", "apa7.csl", package = "papaja")`
documentclass     : "apa7"
output            : papaja::apa6_pdf`
---

And this is the error:

Fehler in yaml::yaml.load(..., eval.expr = TRUE) : 
  Scanner error: while scanning for the next token at line 23, column 21 found character that cannot start any token at line 23, column 21
Ruft auf: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous>

Does anybody have an idea what the problem is? The rmd folder in the papaja folder includes the apa7.csl and other apa7 files equivalent to the apa6 files in there if this is important.

Also, does this this workaround only work for pdf's or also for word documents? I couldn't figure that out from the discussion.

Thanks in advance!

@crsh
Copy link
Owner Author

crsh commented Nov 2, 2021

Ah, sorry, my bad. I just updated the instructions. If you use the following it should work:

csl               : "`r system.file('rmd', 'apa7.csl', package = 'papaja')`"

Also, does this this workaround only work for pdf's or also for word documents?

This will only work for PDF documents at this point.

@padpet
Copy link

padpet commented Nov 30, 2021

Thanks for your previous reply. This is really great work to advance reproducibility in psychology!
I wonder whether I am doing something wrong, but level 1 - 3 headings produce a lot too much space in the pdf file.

grafik

While this is no problem for levels 4-5.
grafik

Is there any code to adapt this directly at the beginning of the RMD file?

@crsh
Copy link
Owner Author

crsh commented Jan 10, 2022

@padpet, sorry I somehow missed your comment. Have you tried this solution?

@pablojvarela
Copy link

I have installed the latest dev version of papaja and installed apa.csl from http://www.zotero.org/styles/apa.csl. I have added the csl, documentclass, classoption and output YAML tags from the previous post. With classoption : "stu" I can see the Course Title, Professor Name, and Due Date on the first page, but can't figure out how to modify them (I've tried LaTex commands and straightforward YAML tags). I'd also like to understand how to change the font and font size.

@leahymr did you find a solution for this?

@leahymr
Copy link

leahymr commented Apr 13, 2022 via email

@ValentinCh14
Copy link

@help

I am trying to get the apa7 latex class to operate in student mode so I can write documents with RMarkdown, but I can't figure out how to do it (I'm new at papaja, but have only used RMarkdown for a few months).

I have installed the latest dev version of papaja and installed apa.csl from http://www.zotero.org/styles/apa.csl. I have added the csl, documentclass, classoption and output YAML tags from the previous post. With classoption : "stu" I can see the Course Title, Professor Name, and Due Date on the first page, but can't figure out how to modify them (I've tried LaTex commands and straightforward YAML tags). I'd also like to understand how to change the font and font size.

Ultimately, I'm interested in trying to build a RMarkdown version of the reference documents on the APA web site, so that people can see what papaja can do and what commands are required to generate the documents.

help!!!!

@crsh
Copy link
Owner Author

crsh commented Oct 27, 2022

Sorry, just so I know I understand. You are using the document class apa7 and you want change font and font size?

@leahymr
Copy link

leahymr commented Oct 28, 2022 via email

@colerehbein
Copy link

It has been 18 months since my original message, so it is hard to remember clearly, but I think I was trying to customize the Professor’s name, the course title, and the due date, but couldn’t figure out how to provide those values (though the placeholders are on the rendered page). I also had trouble figuring out how to change the font and font size for the document. I have not checked since I was taking my class, but one of the things I longed for was an example document that had the various markup tags coupled with the generated output, so that I could more easily follow along. As a student, I didn’t need to use all the power of the system, but the options for students didn’t seem to be well documented. —Michael

I would love an answer to this same question! I'm using quarto instead of rmarkdown but the solution (plugging the proper yaml into the latex class template) should translate exactly between the two

@crsh
Copy link
Owner Author

crsh commented Nov 22, 2022

There currently is no proper apa7 format for Quarto, as far as I know. We are currently working on this, see #531. Unfortunately, I don't have the capacity to answer questions about custom solutions to use the apa7 document class in Quarto at this point. Also, a more specific question (What exactly are you trying to achieve? What is the result supposed to look like?) would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests