mpark / wg21

Framework for Writing C++ Committee Papers
Boost Software License 1.0
125 stars 45 forks source link

New Pandoc compains about `cslreferences` #54

Closed mpusz closed 4 years ago

mpusz commented 4 years ago

While generating a PDF with citations on the latest Pandoc the following error is reported:

Error producing PDF.
! LaTeX Error: Environment cslreferences undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.384 \begin{cslreferences}

make: *** [../wg21/Makefile:6: generated/2007R0_std_from_chars_should_work_with_std_string_view.pdf] Error 43
mpusz commented 4 years ago

Example of a failing paper: https://github.com/mpusz/wg21-papers/blob/master/src/2007R0_std_from_chars_should_work_with_std_string_view.md.

allefeld commented 4 years ago

I had the same problem. It turns out that in the latest version, Pandoc's default LaTeX template (pandoc -D latex) contains this additional section

$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}
$endif$

and my old modified template did, of course, not. You can fix the problem by inserting the new section into your custom template.

mpark commented 4 years ago

@mpusz Thanks for filing / @allefeld Thanks for digging into the issue!

mercergeoinfo commented 4 years ago

This has come back again in 2.11.1.1 but can be fixed in the template by changing "cslreferences" to "CSLReferences"

MyKo101 commented 3 years ago

Since this is usually the first result when people are searching this problem, I'm going to add to it. I recently updated to RStudio 1.4.1103 and with that came an update to pandoc version 2.11.2. A similar error to the above arose when I was trying to compile a document that had worked before the update. I'd previously fixed this exact problem, but now it's back. In the template.tex, adding the following fixed the problem for me:

$if(csl-refs)$
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\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
 }%
 {}
\usepackage{calc} % for \widthof, \maxof
\newcommand{\CSLBlock}[1]{#1\hfill\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$
mpark commented 3 years ago

If you're still running into this problem, you're likely on an older version of this project. If you can, please pull the latest version which will install a local, pinned version of pandoc which I will be explicitly keeping in sync.

MyKo101 commented 3 years ago

If you're still running into this problem, you're likely on an older version of this project. If you can, please pull the latest version which will install a local, pinned version of pandoc which I will be explicitly keeping in sync.

Hi, sorry, my reply wasn't explicitly for this repo. I'm running into this issue with RMarkdown. I posted here because when searching for the cslreference problem, this Issue is the first result for me (and so I presume with many other users) and os just trying to provide the solution/workaround. Apologies again for any confusion and for using your Issue as a forum

thomas-schuster commented 2 years ago

Thanks @MyKo101 for this helpful solution! While I do not use RMarkdown, I still had this issue when using Pandoc to convert markdown files for articles.

Final remark, I had to modify one of your lines slightly (was probably just a typo):

\newenvironment{CSLReferences}[3] % #1 hanging-ident, #2 entry spacing

becomes

\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing