Pandoc's environment cslreferences undefined when knitting RMarkdown to PDF in RStudio

后端 未结 1 969
迷失自我
迷失自我 2021-01-14 12:51

Knitting (in RStudio version 1.2.1335) an RMarkdown file to PDF fails when trying to create citations (for pandoc version 2.8.0.1, and R version 3.6.1). (This does not happe

相关标签:
1条回答
  • 2021-01-14 13:16

    According to the release notes you linked, cslreferences was introduced in version 2.8, including a suitable definition of this environment in the pandoc template. However, Rmarkdown is using its own template (C:\Users\gcb7\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex in your case), which does not have this definition. This has been fixed on GitHub, c.f. https://github.com/rstudio/rmarkdown/issues/1649.

    One workaround would be to copy the relevant lines to a local copy of Rmarkdown's template and specify that via the template field. Alternatively you could add

    \newlength{\cslhangindent}
    \setlength{\cslhangindent}{1.5em}
    \newenvironment{cslreferences}%
      {\setlength{\parindent}{0pt}%
      \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces}%
      {\par}
    

    or

    \newenvironment{cslreferences}%
      {}%
      {\par}
    

    to the resulting tex file via header-includes or similar. Or you could use the pandoc that comes with RStudio, if you have that installed. This can be accomplished by prepending <rstudio-dir>/bin/pandoc/ to the PATH, possibly within .Renviron to make it R specific.

    Everything untested, since I do not have pandoc 2.8 ...

    0 讨论(0)
提交回复
热议问题