Bioconductor / BiocStyle

Issues and pull requests for BiocStyle should go here.
12 stars 19 forks source link

`LaTeX Error: Environment CSLReferences undefined` when knitr pdf with BiocStyle #94

Open YulongNiu opened 2 years ago

YulongNiu commented 2 years ago

I got errors when I tried to add references in aRmd file:

This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2022/dev) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
I was unable to find any missing LaTeX packages from the error log test.log.
! LaTeX Error: Environment CSLReferences undefined.

Error: LaTeX failed to compile test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test.log for more info.
Execution halted

Example Rmd file:

---
title: "Test BiocStyle"
author: 
- New Author
date: "`r Sys.Date()`"
bibliography: test.bib
header-includes:
  - \usepackage{amsmath}
  - \usepackage{mathtools}
output:
  BiocStyle::pdf_document:
    toc: true
    latex_engine: pdflatex
  BiocStyle::html_document:
    toc: true
    toc_float: true
vignette: |
  %\VignetteIndexEntry{Global ETF}
  %\VignetteEncoding{UTF-8}
  %\VignetteEngine{knitr::rmarkdown}
---

Bron-Kerbosch's algorithm [@bron1973algorithm] that operating three disjoint sets.

The test.bib file is:

@article{bron1973algorithm,
  title={Algorithm 457: finding all cliques of an undirected graph},
  author={Bron, Coen and Kerbosch, Joep},
  journal={Communications of the ACM},
  volume={16},
  number={9},
  pages={575--577},
  year={1973},
  publisher={ACM New York, NY, USA}
}

Environment:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin21.1.0 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /usr/local/Cellar/r/4.1.2/lib/R/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rmarkdown_2.11.22 BiocStyle_2.23.1  tidyr_1.2.0       tinytex_0.37     

loaded via a namespace (and not attached):
 [1] knitr_1.37          magrittr_2.0.2      tidyselect_1.1.2   
 [4] R6_2.5.1            rlang_1.0.1         fastmap_1.1.0      
 [7] fansi_1.0.2         stringr_1.4.0       dplyr_1.0.8        
[10] tools_4.1.2         xfun_0.29           utf8_1.2.2         
[13] DBI_1.1.2           cli_3.2.0           htmltools_0.5.2    
[16] ellipsis_0.3.2      assertthat_0.2.1    yaml_2.3.5         
[19] digest_0.6.29       tibble_3.1.6        lifecycle_1.0.1    
[22] bookdown_0.24       crayon_1.5.0        purrr_0.3.4        
[25] BiocManager_1.30.16 vctrs_0.3.8         glue_1.6.2         
[28] evaluate_0.15       stringi_1.7.6       compiler_4.1.2     
[31] pillar_1.7.0        generics_0.1.2      tufte_0.12.1       
[34] pkgconfig_2.0.3  
grimbough commented 2 years ago

Hi @YulongNiu

Thanks for the report and the nice reproducible example. I can confirm I see the same issue on my system. I think it's related to requirements in more recent versions of pandoc, which is now shipping with Rstudio. Can you provide the output from rmarkdown::pandoc_version() ?

YulongNiu commented 2 years ago

Thanks your reply @grimbough

I repeated the same example above, and got the same issue.

> rmarkdown::pandoc_version()
[1] ‘2.17.1.1’
grimbough commented 2 years ago

This is actually pretty interesting. We don't have a citation in the BiocStyle R Markdown vignette, and if I try to include one it fails in the same way.

I tested with some much older versions of Pandoc (e.g. Version 2.8) and you get a different but similar error: "! LaTeX Error: Environment cslreferences undefined." so this problem has been around for a while.

I also took a look at the packages currently in Bioconductor and there are 34 R Markdown vignettes that use citations and mention BiocStyle::pdf_document(). However all of them have the html_document() output listed first and that's what gets built - I guess that for some of those packages this error is the reason they're not using PDF.

I'm going to see if I can replicate what other packages are doing to get this to work.

bschilder commented 1 year ago

@grimbough I think I have a somewhat related issue happening : https://github.com/neurogenomics/rworkflows/issues/69

Trying to sort out whether it's something that needs to addressed on the side of BiocStyle, the r-lib/actions/setup-tinytex@v2 action, or some additional deps I'm not accounting for in rworkflows.