rstudio / rticles

LaTeX Journal Article Templates for R Markdown
https://pkgs.rstudio.com/rticles/
1.46k stars 516 forks source link

peerj_article knitting error: Command \gather already defined #513

Closed bischrob closed 1 year ago

bischrob commented 1 year ago

The peerJ article format gives the following error when knitting:

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

Steps tried: downloaded development version of rticles, upgraded packages, restarts

Note: arxiv article format knits without error

---
title: Template for preparing your research report submission to PeerJ using RMarkdown
preprint: false
author: 
  - name: Barbara McClintock
    affiliation: 1
    corresponding: true
    email: mcclintockb@cshl.edu
  - name: Charles E. Darwin
    affiliation: 2
affiliation:
  - code: 1
    address: Cold Spring Harbor Laboratory, One Bungtown Road Cold Spring Harbor, NY 11724
  - code: 2
    address: Down House, Luxted Rd, Downe, Orpington BR6 7JT, UK
abstract: >
  The abstract of the article.
  It can also be on *multiple* lines.
bibliography: sample.bib
output:
  rticles::peerj_article: default
  bookdown::pdf_book:
    base_format: rticles::peerj_article # for using bookdown features like \@ref()
---

### session info
`xfun::session_info()`
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000), RStudio 2022.7.2.576

Locale:
  LC_COLLATE=English_United States.utf8 
  LC_CTYPE=English_United States.utf8   
  LC_MONETARY=English_United States.utf8
  LC_NUMERIC=C                          
  LC_TIME=English_United States.utf8    

Package version:
  base64enc_0.1.3 bslib_0.4.1     cachem_1.0.6   
  cli_3.3.0       compiler_4.2.1  digest_0.6.30  
  ellipsis_0.3.2  evaluate_0.18   fastmap_1.1.0  
  fs_1.5.2        glue_1.6.2      graphics_4.2.1 
  grDevices_4.2.1 highr_0.9       htmltools_0.5.4
  jquerylib_0.1.4 jsonlite_1.8.4  knitr_1.41     
  lifecycle_1.0.3 magrittr_2.0.3  memoise_2.0.1  
  methods_4.2.1   R6_2.5.1        rappdirs_0.3.3 
  rlang_1.0.6     rmarkdown_2.18  rstudioapi_0.14
  rticles_0.24.2  sass_0.4.4      stats_4.2.1    
  stringi_1.7.8   stringr_1.5.0   tinytex_0.42   
  tools_4.2.1     utils_4.2.1     vctrs_0.5.1    
  xfun_0.35       yaml_2.3.6  

# Introduction {-}

This is my intro

# References

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

cderv commented 1 year ago

Using

> packageVersion("rticles")
[1] ‘0.24.2’

I don't have any issue to render the default template for peerj_article()

Are you using the default template ? Or did you use custom packages ? I wonder where this \gather command is from

bischrob commented 1 year ago

I tried it myself on an RStudio server and it did knit without problems. Is it a Windows problem? I'm not using any extra packages. I tried it with a default rticles document. I thought it might be the tinytex software, but a reinstall didn't fix it and neither did uninstalling it and installing Miktex.

El-Nilso commented 1 year ago

I have the same problem when using the elsevier_article template. I have updated all my packages following https://yihui.org/tinytex/r/#debugging but it still does not work. In the past, I had no problems using this template. I use Windows.

I tried out other templates as well. While peerj gives the same error message, the frontiers_article, tf_article and many other templates work fine. I am not that much into coding and I might be wrong, but from googling similar error messages, I have the feeling it is because of conflicting latex packages using the same command. My guess would be that the elsevier_article and peerj template use a "problematic" latex package and the other templates don´t. Or that only users having installed a certain problematic latex package get this error.

cderv commented 1 year ago

I am using Windows too BTW. Forgot to mention.

I managed to reproduce on a clean install of TinyTeX with recent CTAN package. So one of the package used by this template is creating the issue by conflicting with another one.

Now the Game is to find which 😓 This is a LaTeX issue not a R issue.

cderv commented 1 year ago

Here is the issue: https://github.com/latex-lineno/lineno/issues/5

it comes from the lineno package which should use Hooks to tweak some function.

I don't know if they will fix this upstream - As a patch, I changed the order in our files. It should solve the issue right now for rticles users.

cderv commented 1 year ago

Please do try latest rticles dev version as this should be fixed.

Thanks a lot for the report !

El-Nilso commented 1 year ago

Thanks for the quick fix!

brophyj commented 1 year ago

Yes, using the dev version remotes::install_github("rstudio/rticles") fixed the problem

cderv commented 1 year ago

FWIW the version 5.1 of lineno package will have the fix. Updating / reinstalling from CTAN should work

github-actions[bot] commented 11 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.