1

I have a weird problem that has now been localised to either of the lines:

\usepackage[minted]{tcolorbox} 
\makeglossaries{}

in my preamble. I am using luatex with shell-escape enabled (for minted).

I am using a custom document class PhDthesiscustomCls for my PhD thesis (available to download in this gist here.)

The class file loads tikz, pgfplots and a few other tikz/pgf related libraries, and sets up tikz externalisation.

Everything works fine if I exclude the minted option from the tcolorbox package usage. Things also work if I comment out the makeglossaries command. However, when including both of these, the code runs without error only if tikzexternalisation is disabled locally, i.e

  • Works without the minted option when loading tcolorbox
  • Works without makeglossaries
  • But when we desire to have both the above features, the code compiles only when tikz externalization is disabled locally.

Why is this happening and how do I fix it?

Here is minimum example to replicate the problem.

\documentclass[oneside,12pt,online,a4paper,pdfa1,biblatex,fontC]{PhDthesiscustomCls}
%\tikzset{external/force remake}

\usepackage[minted]{tcolorbox} % problematic with the "minted" option

\usepackage{graphics} % for improved inclusion of graphics
\usepackage{csquotes}
\usepackage{xcolor}

\loadglsentries{glossary}
\makeglossaries{}

%%%%%%%%%%% Document %%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage

% \printglossaries{}

\tikzexternaldisable % force disable externalisation to compile without errors
\begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{example1.tikz}
    \caption{\LaTeX contributions}
\end{figure}

Hello world

\end{document}

The example1.tikz file here is

\begin{tikzpicture}
  \begin{axis}[title  = Contributions per category
                          at LaTeX-Community.org,
    xbar,
    y axis line style = { opacity = 1 },
    axis x line       = none,
    tickwidth         = 0pt,
    enlarge y limits  = 0.2,
    enlarge x limits  = 0.02,
    symbolic y coords = {LaTeX, Tools, Distributions, Editors},
    nodes near coords,
  ]
  \addplot coordinates { (57727,LaTeX)         (5672,Tools)
                         (2193,Distributions)  (11106,Editors) };
  \addplot coordinates { (14320,LaTeX)         (1615,Tools)
                         (560,Distributions)   (3075,Editors)  };
  \legend{Topics, Posts}
  \end{axis}
\end{tikzpicture}
13
  • 2
    can you not replicate with article.cls does it depend on that thesis class? Jun 5, 2018 at 20:10
  • @DavidCarlisle I seriously tried for a couple of hours before giving up. Jun 5, 2018 at 20:13
  • 2
    \usepackage{graphics} % for improved inclusion of graphics seems a strange comment, graphics is the basic interface (that you are not using) you want graphicx for the [width=..] syntax (also it seems odd to use \includegraphics to include a tikz file rather than \input is that really the syntax defined somewhere? Jun 5, 2018 at 20:15
  • 1
    You shouldn't use h as the sole specifier for a float.
    – cfr
    Jun 6, 2018 at 2:36
  • 1
    I have some concerns with that class file: it loads the deprecated epsfig and has a lot of \makeatletter ... \makeatother instances (which shouldn't be in a class). It also loads glossaries before hyperref. Jun 6, 2018 at 11:12

1 Answer 1

7

The problem can be pulled down to the following example.

\documentclass{book}

\newwrite\blubi
\newwrite\blubii
\newwrite\blubiii
\newwrite\blubiv
\newwrite\blubv
\newwrite\blubvi
\newwrite\blubvii
\newwrite\blubviii
\newwrite\blubix
\newwrite\blubx
\newwrite\blubxi
\newwrite\blubxii


\RequirePackage{tikz}
\usetikzlibrary{external}
\tikzexternalize

\tikzset{external/system call={lualatex
\tikzexternalcheckshellescape -halt-on-error -interaction=batchmode
                              -jobname "\image" "\texsource"}}

\begin{document}

\tableofcontents % \tf@toc=\write16

\begin{tikzpicture}
 \draw(0,0)--++(1,1);
\end{tikzpicture}

Hello world

\end{document}

This example opens a lot of write streams (as does your own example: the minted option of tcolorbox and \makeglossaries both open streams).

With pdflatex you would get at \tableofcontents which tries to open stream 16 the well-known error

  ! No room for a new \write.

lualatex has more write streams and so won't complain. But now you get problems with pgf: the package uses in various places \immediate\write16 for its log messages.

And this means that you get in the toc suddenly lines like

  ===== Image 'test-utf8-figure0' is up-to-date. ======

which can lead to various errors. Imho this is a bug in pgf and should be reported there.

As a work-around you can try \newwrite\blub before \tableofcontents. Then the log-messages will no longer end in the toc. Be aware that every change in your document which changes the number of write stream can again led to errors.

I added a bug report for pgf: https://sourceforge.net/p/pgf/bugs/488/

13
  • thank you for the explanation. Unfortunately, I did not understand enough since this is a bit too technical for my level of TeX knowledge. What is a blub? I don't use it? In practise, does it mean I will face more problems with Tikz externalisation? Would you recommend moving to standard classes such as book to avoid these issues? I am not sure if I can afford to debug future problems like these. Jun 6, 2018 at 12:14
  • blub is an arbitrary name. You can also use \newwrite\someothername. The problem is not related to your class. You can get it also with book if you load a number of packages. And it is imho not only related to externalisation, also a command from the math parser uses write16. This needs a proper solution. I will ask the latex team about it. Jun 6, 2018 at 12:19
  • thank you. Just one more question (I am feeling rather stupid here). I don't explicitly use newwrite in my document. What is the source of this error in my doc? Jun 6, 2018 at 12:25
  • 1
    As I wrote: Your packages open them, e.g. every glossary has to open a write stream for the output files for makeindex, minted, has an output stream, tcolorbox, biblatex etc. I will make a bug report at the correct place. Jun 6, 2018 at 12:38
  • 1
    Did you actually read my answer? Jun 6, 2018 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .