Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update .sty files for latest Pandoc citeproc approach #236

Closed
seananderson opened this issue Sep 22, 2023 · 4 comments
Closed

Update .sty files for latest Pandoc citeproc approach #236

seananderson opened this issue Sep 22, 2023 · 4 comments

Comments

@seananderson
Copy link
Member

seananderson commented Sep 22, 2023

The latest Pandoc has changed how references are handled by the default 'citeproc' method. Argh!

You can verify this is an issue by trying to build the unit tests. I tried with the tech report.

See https://tex.stackexchange.com/questions/695228/undefined-control-sequence-using-citeproc-to-convert-md-to-pdf-with-a-template
And an example of extra code now needed in the preamble here: jgm/pandoc#9031 (comment)

However, it's more complicated than this for us and I'm out of time to try fixing this right now. So, I'm documenting where I left off. Working on the tech report, here is what I've found:

  • I added the above code
\NewDocumentCommand\citeproctext{}{}
\NewDocumentCommand\citeproc{mm}{%
  \begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
\makeatletter
% 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}
\newlength{\cslentryspacing}
\setlength{\cslentryspacing}{0em}
\usepackage{enumitem}
\newlist{biblist}{itemize}{1}
\setlist[biblist]{label={},leftmargin=\cslhangindent,itemindent=-1\cslhangindent,itemsep=\cslentryspacing}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
  • Need to remove % \RequirePackage[authoryear]{natbib} % Citations
  • Need to remove % \bibpunct{(}{)}{;}{a}{}{,} % Punctuation for citations
  • Need to remove (or maybe better, edit)
\newenvironment{CSLReferences}[3] % #1 hanging-ident, #2 entry spacing
 {% 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 entry spacing
  \ifnum #2 > 0
  \setlength{\parskip}{#2\baselineskip}
  \fi
 }%
 {}
  • If removing that, need to stop adding (or remove?) from the .tex:
%Defines cslreferences environment
%Required by pandoc 2.8
% %Copied from https://github.com/rstudio/rmarkdown/issues/1649
% \newlength{\cslhangindent}
% \setlength{\cslhangindent}{1.5em}
% \newenvironment{cslreferences}%
%   {}%
%   {\par}

Then in reference list, need to stop injecting CSLReferences at beginning and end of bibliography. I forget if we're doing that or pandoc was. Replace with biblist?

e.g. \begin{CSLReferences} becomes \begin{biblist}

@jdunic first flagged this

@seananderson
Copy link
Member Author

Hit the Blame button on this file: https://github.com/jgm/pandoc-templates/blame/master/default.latex
and start at line 338 % definitions for citeproc citations. That's what needs to change (keeping in mind we need formatting to match CSAS requirements).

seananderson added a commit that referenced this issue Sep 22, 2023
res-doc-b not done
note sometimes (for French?) have to use bookdown::render_book()
@seananderson
Copy link
Member Author

This is all done (except resdoc-b). Note, however, that for some document types I had to change the default rendering back to bookdown::render_book() for the French version to build. You can see which ones in the 2 commits linked above in this issue with their TODO. I couldn't quickly figure out what was going wrong with the csasdown::render() versions.

@cgrandin
Copy link
Contributor

On the server we have Pandoc version:

pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.2, skylighting 0.8.5

With this, the English techreport fails for me as it is now using either csasdown::render() or bookdown::render_book(). I can fix it (maybe the indents etc are wrong though) by changing the code starting here

\usepackage{enumitem}
to this:

\usepackage{enumitem}
\newenvironment{CSLReferences}%
  {}%
  {\par}
% \newlist{CSLReferences}{itemize}{1}
% \setlist[CSLReferences]{label={},
%   leftmargin=\cslhangindent,
%   itemindent=-1\cslhangindent,
%   parsep=\parskip,
%   itemsep=\cslentryspacing}
\usepackage{calc}

Appears it cannot be a list the way it is now...

@seananderson
Copy link
Member Author

This should now be working with pandoc < 3.1.7 and with pandoc >= 3.1.8. Pandoc 3.1.7 requires its own template, so csasdown checks for it and stops. I check the pandoc version on the fly and uncomment/comment sections of the .sty file as needed. 417f88c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants