We are currently planning to migrate to a different platform for the forum. We will announce this fact both here and on Twitter, once we have settled on a solution.

problem PDF export with citations or images

Hello everbody.
Everything work fine (thanks for tutorials !) but I have a little problem with the pdf export. I installed Pandoc and Miktex and add the BetterBibTex plug-in for Zotero (it works). If my file is only text, no problem to export in pdf. But if there's citations or images, I can't obtain a pdf version. I receive this kind of error mesage :

I tried to reinstal Pandoc, but didn't solve the problem.
Anybody have an idea to fix this ?
Thanks in advance.



  • I precise I'm working with Windows 10 OS

  • Hi BMarquebielle,

    I have exactly the same problem, althought I am working with Linux Peppermint 5.0

    After installing Zettlr, TinyTeX, LiveTeX, Pandoc, and Zotero, I experienced a lot of problems when I tried to export to PDF, not when exporting to other formats, though.

    Most of the error messages looked like the image above. I finally solved the problem when I found this exchange of tweets:


    Except on Windows, you need to manually install some packages. Whenever pandoc produces errors like “file .sty not found”, you can easily solve them by running the command “tlmgr install ”
    The Zettlr default template only relies upon default packages

    I had to repent the part of the process that sends command “tlmgr install .sty” for 30 or 40 .sty missing files.

    Finally I got to export very large markdown documents (full books) to PDF.

    I was really happy, because the last part of my project was to include bibliography.

    Yet, as I imported my bibliography in Better CSL JSON from Zotero to Zettlr and included a couple of citations, the LaTeX Error reapeared:

    ! LaTeX Error: Environment cslreferences undefined.

    I have been unable to solve it.

  • edited January 1

    I figure out that this error has something to do with Pandoc / CiteProc 2.8 update (2019/11/26)


    A user/developer of digra-latex-md reports the same issue:

    Pandoc 2.8 requires a cslreferences environment to be defined in a LaTeX template for CSL bibliographies. This results in the following error:

    ! LaTeX Error: Environment cslreferences undefined.

    njbart, a user/developer of Rmarkdown comments also about a modification in Pandoc 2.8, that causes Rmarkdown to produce the same LaTeX error:

    pandoc now requires a cslreferences environment to be defined in the latex template (see jgm/pandoc@0fe635d).

    This would require the addition of:


  • @eooloh thanks for the research. Adding the given code by njbart to the .tex file for export has solved the issue for me.

  • Hello, @roland. Thank you very much for the solution. But tell me please a little bit. Should I use the code myself? Where can I find the file to add it? Excuse my ignorance, but I han only been using Pepperlint Linux for a couple of months.

  • @roland , can you mention the exact .tex file for export that you added the code to? In which folder it is, and where in it did you add njbart's code? Thanks.

  • @eooloh The template you'd need would be a custom one, that is: Download the official Zettlr template (in the app itself it's contained in the app.asar-archive), save it somewhere, add the code and then point Zettlr to use this template instead of the built-in (in the preferences). Then it should work!

    As for the other issues: Thank you all for contributing, I will distill this thread into an FAQ-entry so that others don't need to search for ages until they find the solution! And concerning the issue with the CSL-Environment, I'll try to test this with Pandoc 2.8 and see if the error is fully reproducible. If so, I'll be adding the above mentioned snippet of code permanently to the template so that the bug is mitigated!

    Cheers, and Happy New Year y'all!

  • I just opened a bug report to track the progress: https://github.com/Zettlr/Zettlr/issues/455

  • @hendrik thank you very much. I did just as you described, and the problem was solved, although I should mention that only when I introduced the code by njbart at the beginning of the .tex export template (lines 20-27), not when I copied it at the end of the template (line 199).

  • @eooloh Yes, the code needs to be put before the \begin{document}-command.

    LaTeX-files are to some extend like HTML pages. First, you have a "header" where you specify some general stuff that the template needs, such as an author (for PDF metadata), certain styles (such as fonts for paragraphs, spacing, etc.), and variables like cslenvironment. Then, in the body (from \begin{document} to \end{document}) the actual contents are placed.

  • Thank you very much all for these research and informations ! I understand the problem and how to solve it... but I have some gaps in these LateX code world, I'm discovering with Windows10. @hendrik I can download and open the official Zettlr template with TeXworks. But where shall I add the njbart code ? Thanks in advance and Happy New Year of course.

  • Rather easy: Open the default template and search for that "begin document" thing I mentioned earlier. Then, you can put njbart's code piece directly above it. It should work!

  • edited January 10


  • Short update: We've just merged a PR that includes a permanent fix to that, so next version will include that one!

  • Great news!

  • Thank you for all (sorry for the delay of answer) !

  • @hendrik
    Hallo und vielen Dank für all deine Arbeit mit Zettlr!

    It was a couple of months that I hadn't compiled a paper via Zettlr using the CSL option and now the CSL issue seems to be back again. The error "Environment CSLReferences undefined" is raised no matter if I compile on Debian Stretch or on Debian Buster both with pandoc installed. Two months ago I had no issues on Debian Stretch, though...

    Thus it seems that the above quoted njbart's code snippet does not work anymore, since I have it inserted within my custom zettlr-pandoc template.

    This is why I have checked also for possible changes within the pandoc default template and in fact I now find the following quite different snippet:

    \newenvironment{CSLReferences}[3] % #1 hanging-ident, #2 entry spacing
     {% don't indent paragraphs
      % turn on hanging indent if param 1 is 1
      \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi
      % set entry spacing
      \ifnum #2 > 0
    \usepackage{calc} % for \widthof, \maxof

    However, the substitution of njbart's code snippet with this new one within my custom template leads to another error, complaining about the lack of a closing tag for the CSLReferences new environment. I'm not able to get rid of all this!

    Vielen Dank

  • @alex81

    The issue is related to Pandoc 2.11.
    Changing one line in Zettlr's default template fixed it for me:

    Change \newenvironment{cslreferences}% to \newenvironment{CSLReferences}%.

    That's it!
    I have also opened an issue on GitHub: https://github.com/Zettlr/Zettlr/issues/1414

  • @Doctorados

    Yeah! I've missed this minimal difference..., it works now, thanks.

  • Well, in fact it compiles without errors, but finally the bibliography does not appear, because references are not resolved... Is it another new pandoc issue? Till now using Zettlr and pandoc I never had to compile multiple times like while directly using LaTeX...

    See attached pic.

Sign In or Register to comment.