# MiKTeX’s LuaLaTeX and minitoc: “I can't write on file …mtc”

When compiling the code below with LuaLaTeX I get the error: "I can't write on file 'test.mtc'". Any ideas on how to resolve this? (Btw, the file test.mtc is there and contains the word "Contents")

\documentclass{report}
\usepackage{lipsum}

\usepackage[tight]{minitoc}
\dominitoc[n]

\begin{document}

\tableofcontents
\chapter{Test}
\minitoc
\lipsum
\section{Test}
\lipsum
\subsection{Test}
\lipsum
\subsubsection{Test}
\lipsum

\end{document}

• Are you sure you're allowed to write files in the working directory? I have no problem with the example. What OS are you using? – egreg May 17 '13 at 13:46
• Window XP 64bit. It works with pdflatex but not with lualatex... And I can write files in the working directory. – Wox May 17 '13 at 14:12
• The same (pdfLaTeX yay, LuaLaTeX nay) happens to me with MiKTeX 2.9 on Win7-64, but not with TeX Live 2012. – doncherry May 17 '13 at 14:29
• I'm also using MiKTeX 2.9 (with TeXnicCenter). – Wox May 17 '13 at 15:00

There is a lonely \closein\@inputcheck\relax in minitoc.sty which imho belongs in the definition above it:

\documentclass{report}
\usepackage{lipsum}

\usepackage[tight]{minitoc}

\makeatletter
\def\mtc@CkFile#1{%
\@mtc@LItrue\@mtc@FEtrue
\if@mtc@checkfiles
\IfFileExists{#1}{%
\immediate\openin\@inputcheck #1\relax
\mtc@While{}{\if@mtc@LI\relax}{\mtc@Body}\mtc@EndWhile
%
}%
{\@mtc@FEtrue}%
\else
\@mtc@FEfalse%
\fi
\closein\@inputcheck\relax}%moved in the definition
\makeatother

\dominitoc[n]
\begin{document}
\tableofcontents
\chapter{Test}
\minitoc
\lipsum
\section{Test}
\lipsum
\subsection{Test}
\lipsum
\subsubsection{Test}
\lipsum

\end{document}

• Thanks Ulrike! One should choose Latex for this community alone. – Wox May 17 '13 at 15:56
• It's quite funny that only MiKTeX's LuaLaTeX chokes on this. The example runs well on my machine. Of course \immediate before \openin is superfluous. – egreg May 17 '13 at 16:00
• @egreg: It works for me with TL too. But as I realized as I looked into this luatex bug tracker.luatex.org/view.php?id=827 there are slight differences regarding openin between the various engines and systems so I knew where to look. – Ulrike Fischer May 17 '13 at 16:11