We switched to a manual approval system for registration on this forum, as this makes it easier to keep bots out of the forum. We'll approve everybody who doesn't look like a bot!

# 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 ?

Tagged:

• 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)

https://pandoc.org/releases.html#pandoc-2.8-2019-11-22

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:

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

• @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) !