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

Bibliography in papaja::revision_letter_pdf gives LaTeX Error: Lonely \item--perhaps a missing list environment. #587

Closed
cjvanlissa opened this issue Jun 12, 2024 · 8 comments · Fixed by #593
Assignees
Labels

Comments

@cjvanlissa
Copy link

I'm sorry, this won't be a reproducible example. If it's not a bug, feel free to ignore.

I'm unable to render a revision_letter_pdf with references, because the bibliography entries each give this error:

LaTeX Error: Lonely \item--perhaps a missing list environment.

The entries look like this:

\bibitem[\citeproctext]{ref-benjaminRedefineStatisticalSignificance2017}
Benjamin, D. J., Berger, J. O., Johannesson, M., Nosek, B. A., Wagenmakers, E.-J., Berk, R., \ldots{} Johnson, V. E. (2017). Redefine statistical significance. \emph{Nature Human Behaviour}, \emph{2}(1), 6--10. \url{https://doi.org/10.1038/s41562-017-0189-z}

Which seems to be the same as the entries from my papaja::apa6_pdf manuscript:

\bibitem[\citeproctext]{ref-benjaminRedefineStatisticalSignificance2017}
Benjamin, D. J., Berger, J. O., Johannesson, M., Nosek, B. A., Wagenmakers, E.-J., Berk, R., \ldots{} Johnson, V. E. (2017). Redefine statistical significance. \emph{Nature Human Behaviour}, \emph{2}(1), 6--10. \url{https://doi.org/10.1038/s41562-017-0189-z}

Maybe some package is missing from the revision_letter template?

@cjvanlissa
Copy link
Author

Just changing output : papaja::revision_letter_pdf to output : papaja::apa6_pdf allows me to render successfully, so I do think something might be missing from the revision_letter_pdf template.

@jvcasillas
Copy link
Contributor

Adding that I am also getting this error.

@crsh
Copy link
Owner

crsh commented Jul 1, 2024

Thanks for reporting this. I'll take a look as soon as possible.

@crsh crsh added the bug label Jul 1, 2024
@crsh crsh self-assigned this Jul 1, 2024
@jvcasillas
Copy link
Contributor

Any update or workaround for this error?

@jvcasillas
Copy link
Contributor

jvcasillas commented Sep 17, 2024

Following @cjvanlissa comment, I notice that if I try to render the Rmd file, get the LaTeX Error: Lonely \item--perhaps a missing list environment error, and then inspect the .tex file, this section appears to be incomplete:

\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
 {% don't indent paragraphs
  \setlength{\parindent}{0pt}
  % turn on hanging indent if param 1 is 1
  \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi
  % set entry spacing
  \ifnum #2 > 0
  \setlength{\parskip}{#2\baselineskip}
  \fi
 }%
 {}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}

If I switch to papaja::apa6_pdf and rerender, it works fine. So, I can copy and paste the relevant section of the CSL code into the .tex file (after trying to render with papaja::revision_letter_pdf) and it works correctly. The code I am copy/pasting is the following:

% definitions for citeproc citations
\NewDocumentCommand\citeproctext{}{}
\NewDocumentCommand\citeproc{mm}{%
  \begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
\makeatletter
 % allow citations to break across lines
 \let\@cite@ofmt\@firstofone
 % avoid brackets around text for \cite:
 \def\@biblabel#1{}
 \def\@cite#1#2{{#1\if@tempswa , #2\fi}}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing
 {\begin{list}{}{%
  \setlength{\itemindent}{0pt}
  \setlength{\leftmargin}{0pt}
  \setlength{\parsep}{0pt}
  % turn on hanging indent if param 1 is 1
  \ifodd #1
   \setlength{\leftmargin}{\cslhangindent}
   \setlength{\itemindent}{-1\cslhangindent}
  \fi
  % set entry spacing
  \setlength{\itemsep}{#2\baselineskip}}}
 {\end{list}}

I assume this needs to be added to the template to fix this issue, which appears to be lines 173-194 of https://github.com/crsh/papaja/blob/main/inst/rmarkdown/templates/revision_letter/resources/revision_letter.tex.

@cjvanlissa
Copy link
Author

@crsh thanks for fixing this! While you're at it: I had the same error when rendering an APA6 document recently; might have been a problem with my bib file, but if it happens again I will open an issue.

@jvcasillas
Copy link
Contributor

jvcasillas commented Oct 18, 2024

I think that some change posterior to #593 has affected this, as I am not getting this error again.

Edit: I notice that if I reinstall the CRAN version the error is not present.

@crsh
Copy link
Owner

crsh commented Oct 22, 2024

Thanks for letting us know! I plan to submit an update to CRAN shortly.

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

Successfully merging a pull request may close this issue.

3 participants