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}
  • 2
    can you not replicate with article.cls does it depend on that thesis class? – David Carlisle Jun 05 '18 at 20:10
  • @DavidCarlisle I seriously tried for a couple of hours before giving up. – Dr Krishnakumar Gopalakrishnan Jun 05 '18 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? – David Carlisle Jun 05 '18 at 20:15
  • @DavidCarlisle Unless the OP is using tikzscale, but I don't think that is compatible with externalisation (if I remember correctly) and I'm not sure that syntax is appropriate for a pgfplots figure, also if I remember correctly. (I think both dimensions are needed for plots.) – cfr Jun 06 '18 at 02:35
  • 1
    You shouldn't use h as the sole specifier for a float. – cfr Jun 06 '18 at 02:36
  • The glossaries.tex file is missing. You don't write which error you actually get. And you don't tell the versions of your tex system and the files -- with lualatex this can matter a lot. – Ulrike Fischer Jun 06 '18 at 08:45
  • The glossaries.tex is a single entity. \acr{adc}{ADC}{Analog to Digital Converter}. I am using TL2018 with latest LuaTeX 1.07 I believe. The error is something's missing. Perhaps a missing \item and in the line where documentclass is defined this is only allowed in the preamble. Everything works fine when disabling externalisation of Tikz. – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 08:50
  • @cfr Yes. The class file uses ```\RequirePackage{tikzscale}
    
    
    – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 08:54
  • 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. – Nicola Talbot Jun 06 '18 at 11:12
  • @Krishna Acronyms are defined using \newacronym (or \newabbreviation, since glossaries-extra has been loaded) not with \acr. – Nicola Talbot Jun 06 '18 at 11:13
  • What happens if you move \makeglossaries before \usepackage[minted]{tcolorbox}? – Nicola Talbot Jun 06 '18 at 11:14
  • @NicolaTalbot that results in an error. ./main.toc|5 error| Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. ... ...entsline {chapter}{Title Page}{i}{section*.1}. Furthermore the acr file is not created. – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 11:52
  • @Krishna Ulrike's answer indicates that the problem is too many write registers, so have a look at debug No room for a new \write problem. You can reduce the number of write registers required by switching from glossaries.sty+\makeglossaries to glossaries-extra.sty+bib2gls. – Nicola Talbot Jun 07 '18 at 11:28

1 Answers1

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/

Ulrike Fischer
  • 327,261
  • 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. – Dr Krishnakumar Gopalakrishnan Jun 06 '18 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. – Ulrike Fischer Jun 06 '18 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? – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 12:25
  • You also said that this is a bug in pgf. I am confused if I should report it in pgfplots sourceforge page by Dr Christian Feuersanger, or somewhere else. (I thought pgf was developed originally by Till Tantau but don't see a development page/repo). – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 12:27
  • 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. – Ulrike Fischer Jun 06 '18 at 12:38
  • Thank you again. In the meantime, is there a workaround? I mean, it should be a very common use case to have glossaries, code listings, bibliography and externalised Tikz in a thesis document ? How does it work for all other people? Are they using some recommended workaround? – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 12:41
  • 1
    Did you actually read my answer? – Ulrike Fischer Jun 06 '18 at 12:41
  • Yes.,..".As a work-around you can try \newwrite\blub before \tableofcontents"... But I am not sure how using more newwrites can help an already overloaded stream. – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 12:42
  • luatex has enough streams. But you need to avoid that stream16 used by pgf is also used by something else. So you should move the toc to 17. – Ulrike Fischer Jun 06 '18 at 12:46
  • this workaround did not succeed for me. I now get the error no file main.acr, i.e. makeglossaries is not producing the acr file. – Dr Krishnakumar Gopalakrishnan Jun 06 '18 at 17:01
  • @cfr i doubt it. Luatex has enough streams. – Ulrike Fischer Jun 06 '18 at 22:37
  • @cfr There a perhaps other reasons for luatex. Also morewrites can slow down the compilation a lot. – Ulrike Fischer Jun 06 '18 at 22:40
  • Just realised the OP is already using LuaTeX. Sorry. – cfr Jun 06 '18 at 22:44