-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Issue Description
With recent pandoc updates, I had to update my LaTeX templates to properly support citations. This change is necessary since the old templates throw errors on the old command \cslreferences
.
However, the change in the template has resulted in output that is has lost the bibliographic links and formatting. Previously refs were properly presented in "apalike" format, but they are now shown in an un-transformed format, for example: ([ref-coull_dopamine_2012])
.
To get refs working, I updated the template.tex
with the following change in the csl-refs
section, which was sourced from the pandoc templates: https://github.com/jgm/pandoc-templates/blob/master/common.latex
$if(csl-refs)$
% 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}}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$
previously I was using this (which no longer renders):
$if(csl-refs)$
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newenvironment{CSLReferences}%
{$if(csl-hanging-indent)$\setlength{\parindent}{0pt}%
\everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%
{\par}
\newenvironment{cslreferences}%
{$if(csl-hanging-indent)$\setlength{\parindent}{0pt}%
\everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%
{\par}
$endif$
Question
I am guessing that the template needs to be updated or maybe a filter is no longer working as \cslreferences
has changes to \CSLReferences
. Some advice on how to get these references working in the PDF would be great.
Example (run script build.R
or command rmarkdown::render('Article/Article.Rmd', output_format ="all")
to render.
minimal.zip
p.s. the included example also renders out to html and .doc just to show what the references should look like.
Checklist
When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:
-
formatted your issue so it is easier for us to read?
-
included a minimal, self-contained, and reproducible example?
-
pasted the output from
xfun::session_info('bookdown')
in your issue? -
upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
-
installed and tested your bug with the development version of the bookdown package using
remotes::install_github("rstudio/bookdown")
?
R version 4.5.1 (2025-06-13)
Platform: x86_64-pc-linux-gnu
Running under: Debian GNU/Linux forky/sid
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
Locale:
LC_CTYPE=en_AU.UTF-8
LC_NUMERIC=C
LC_TIME=en_AU.UTF-8
LC_COLLATE=en_AU.UTF-8
LC_MONETARY=en_AU.UTF-8
LC_MESSAGES=en_AU.UTF-8
LC_PAPER=en_AU.UTF-8
LC_NAME=C
LC_ADDRESS=C
LC_TELEPHONE=C
LC_MEASUREMENT=en_AU.UTF-8
LC_IDENTIFICATION=C
Package version:
base64enc_0.1.3 bookdown_0.44.2
bslib_0.9.0 cachem_1.1.0
cli_3.6.5 digest_0.6.37
evaluate_1.0.5 fastmap_1.2.0
fontawesome_0.5.3 fs_1.6.6
glue_1.8.0 graphics_4.5.1
grDevices_4.5.1 highr_0.11
htmltools_0.5.8.1 jquerylib_0.1.4
jsonlite_2.0.0 knitr_1.50
lifecycle_1.0.4 memoise_2.0.1
methods_4.5.1 mime_0.13
R6_2.6.1 rappdirs_0.3.3
rlang_1.1.6 rmarkdown_2.29.2
sass_0.4.10 stats_4.5.1
tinytex_0.57 tools_4.5.1
utils_4.5.1 xfun_0.53
yaml_2.3.10