# Special package combination gives “No room for new \write.”

In my special package combination I get the error No room for new \write. \tablecontents and Bad number (16). \tablecontents. The following MWE throws this error in pdflatex and lualatex with TeX Live 2015. As you can see, I add the own content register loi. I can delete nearly every package separately and the error directly vanishes.

Does anyone have an idea what is wrong with this package combination?

\documentclass{scrartcl}
\usepackage{ifluatex}
\ifluatex
\usepackage{fontspec}
\fi
\usepackage{adjustbox, amsmath, blindtext, datatool, fancybox, fixme, graphicx, marginnote, pgfplots}
\usepackage{imakeidx}
\usepackage{biblatex}
\usepackage{glossaries}
\usepackage{hyperref}
% load package for code code highlighting
\usepackage{minted}

% define Open Issue and corresponding List of Open Issues
\newcommand{\openissue}[2][Unlabeled]{%
\par%
{\refstepcounter{loicounter}%
\phantomsection% comment out if hyperref is noy used
\protect\numberline{%
\ifcsname c@chapter\endcsname%
\thechapter.%
\fi%
\theloicounter%
}{#1: #2}%
}%
\textbf{Open Issue -- #1:} #2}%
\par%
}
% define counter
\makeatletter
\ifcsname c@chapter\endcsname%
\newcounter{loicounter}[chapter]%
\else
\newcounter{loicounter}%
\fi%
\newcommand*{\listopenissuesname}{List of Open Issues}
\newcommand{\listofopenissues}{%
\ifcsname chapter\endcsname%
\chapter*{\listopenissuesname}%
\else%
\section*{\listopenissuesname}%
\fi%
\@starttoc{loi}%
}
\makeatother

\fxsetup{status = draft}
\makeglossaries
\makeindex

\begin{document}

% include open issues
\listofopenissues
% include list of corrections
\listoffixmes
% include indicies
\tableofcontents                            % Inhaltsverzeichnis einbinden

\end{document}

• Did you had a look at this answer? – Clément Jan 27 '16 at 19:58
• According to Knuth, there are only 16 IO channels, which are normally allocated using \newread and \newwrite. I don't believe they reuse closed channels automatically. – John Kormylo Jan 27 '16 at 20:47
• You may try adding \usepackage{morewrites} – egreg Jan 27 '16 at 22:33

The solution is to use \usepackage{morewrites} since basically any of the packages already loaded there grabs at least one (write) file handle, but the number of file handles is restricted to 16 registers only, unless morewrites is loaded, which extends the number of registers.

The question is: Are some of the packages really needed?

Here is a short excerpt of the \jobname.log file

\@dtl@write=\write3   % package datatool
\Verbatim@Outfile=\write4  % fancyvrb
\w@pgf@writea=\write5  % pgf
\blx@bcfout=\write6   % biblatex
\FV@OutFile=\write7   % fancyvrb again
\@xs@message=\write8  % xstring
\minted@code=\write9  % minted
\glswrite=\write10    % glossaries
\glo@main@file=\write11  % glossaries again
\noroom@idxfile=\write12  % imakeidx
\@outlinefile=\write13    % hyperref?
\tf@loi=\write14          % code itself with \addcontentsline{loi}
\tf@lox=\write15          % fixme package
! No room for a new \write.
\tf@toc=\write16  % Failure here

• Thanks for your explanation! You are right, I do not need all packages every time and will reduce them. However, I wanted to understand the problem. How do you get the file jobname.log? – Dirk Jan 29 '16 at 7:12
• @Dirk: Any TeX compilation run produces a .log file. If your file is called foo.tex, the jobname is foo and the log file is foo.log then. The information I presented in this answer is of course condensed, i.e. I took only the relevant lines with \write... – user31729 Jan 29 '16 at 16:24
• I did not realise that you condensed the information manually. Thanks! – Dirk Jan 31 '16 at 9:59
• @Dirk: Not manually. I used grep ;-) – user31729 Jan 31 '16 at 10:46
• I just realised, that you marked lox with my code. Where do I have the line \addcontentsline{lox} in my code? – Dirk Feb 5 '16 at 14:29