From 403c8688c934eb7bcded9286c97985b72ecc0d0a Mon Sep 17 00:00:00 2001 From: Leon Reteig Date: Sat, 12 Dec 2020 19:33:38 +0100 Subject: [PATCH] Make compatible with pandoc 2.8 From rstudio/rticles#355 --- .../templates/thesis/skeleton/template.tex | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/inst/rmarkdown/templates/thesis/skeleton/template.tex b/inst/rmarkdown/templates/thesis/skeleton/template.tex index 607295f..3c0ae2a 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/template.tex +++ b/inst/rmarkdown/templates/thesis/skeleton/template.tex @@ -204,33 +204,39 @@ \fi $endif$ -% LS 25-11-2020 add new statement similar to thesisdown bugfix: -% https://github.com/ismayc/thesisdown/pull/79#issue-384204665 -% LS 25-11-2020 note: fix didn't work: I went to the raw pandoc version and copied and pasted the following lines. -% copied from https://github.com/jgm/pandoc/blob/master/data/templates/default.latex +% LCR fix for new required cslreferences environment in pandoc +% from https://github.com/rstudio/rticles/pull/335/commits/a9937b6 +% originally proposed by LS: https://github.com/LDSamson/amsterdown/commit/4d9841e +% Pandoc citation processing $if(csl-refs)$ -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} \newlength{\csllabelwidth} \setlength{\csllabelwidth}{3em} -\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing +\newlength{\cslhangindent} +\setlength{\cslhangindent}{1.5em} +% for Pandoc 2.8 to 2.10.1 +\newenvironment{cslreferences}% + {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% + \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% + {\par} +% For Pandoc 2.11+ +\newenvironment{CSLReferences}[3] % #1 hanging-ident, #2 entry sp {% 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 line spacing % set entry spacing \ifnum #2 > 0 - \setlength{\parskip}{#2\baselineskip} + \setlength{\parskip}{#3\baselineskip} \fi }% {} -\usepackage{calc} +\usepackage{calc} % for \widthof, \maxof \newcommand{\CSLBlock}[1]{#1\hfill\break} -\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} -\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} +\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\maxof{\widthof{#1}}{\csllabelwidth}}{#1}} +\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth}{#1}} \newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} $endif$ -% LS 25-11-2020 end of addition to solve bug %%% Use protect on footnotes to avoid problems with footnotes in titles \let\rmarkdownfootnote\footnote%