Renaming LaTeX file to index.tex causes tex4ht to give error when using minitoc

>cat t2.tex
\documentclass[titlepage]{report}%
\usepackage{minitoc}
\begin{document}
foo
\end{document}


now

htlatex t2.tex "html,4"


No errors. Now I name it to index.tex and try again:

>cp t2.tex index.tex
>htlatex index.tex "html,4"
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
....
(/usr/share/texmf/tex/generic/tex4ht/html4-math.4ht))
(/usr/share/texmf/tex/generic/tex4ht/index.4ht
! Undefined control sequence.
<argument> \printindex

l.41 ...name{\the\@nameuse{idxtitle@\@indextype}}}

?


any other name seems to work ok

cp index.tex indexx.tex
htlatex indexx.tex


no errors. Only when the name is index.tex. And this is ONLY when I include minitoc. If I remove minitoc, then it compiles ok:

>cat index.tex
\documentclass[titlepage]{report}%
%\usepackage{minitoc}
\begin{document}
foo
\end{document}

>htlatex index.tex


No error (just need to make sure to remove all old index.aux and other index.* stuff before trying again. but no error.

So. why is including package minitoc causes tex4ht error ONLY when the source LaTeX file is called index.tex?

specs:

>tex4ht -v
tex4ht.c (2009-01-31-07:33 kpathsea)

>latex -v
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)

>uname -a
Linux 3.5.0-17-generic #28-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

-
For some reason, including minitoc causes tex4ht to input index.4ht, which is when the error happens. – egreg Jan 16 '13 at 23:54

TeX4ht overloads the LaTeX macros for file input to support configuration files. These files are named with the base name and extension .4ht. Package minitoc generates and loads a file \jobname.mtc0. Thus TeX4ht loads \jobname.4ht if this file exists. In case of \jobname equals index the file index.4ht exists, because TeX4ht supports the package index. Therefore index.4ht assumes that package index is loaded, where \printindex is defined. Since other packages also might generate such auxiliary files like minitoc, the solution would be to avoid job names that are packages or classes, if htlatex is used.
@egreg The cause is \input{\jobname.mtc0} in minitoc.sty that triggers tex4ht to load \jobname.4ht. The extension .mtc0 does not matter. – Heiko Oberdiek Jan 17 '13 at 0:33
hi, when you say he solution would be to avoid job names that are packages or classes, if htlatex is used. So this translates to, in terms new users like me can understand, is to not to use minitoc when running tex4ht? OK. Just wanted to make sure I understood. That is fine. Will do that. I removed minitoc package since I want to always use tex4ht as well. – Nasser Jan 17 '13 at 4:38
@Nasser no, you only need not to give your tex file same name as is the name of some package, because then tex4ht includes config file for this package and this may cause some problems. – michal.h21 Jan 17 '13 at 7:34