# minilot and minilof with tex4ht

I'm working on an ebook and i'd like to have a list of figures/tables at the end of every chapter and only for that chapter (so just like minilot and minilof, but unfortunately minitoc doesn't work with tex4ht). The config.cfg for the TOC looks like this so far:

\let\origincludegraphics\includegraphics
\Preamble{xhtml,pic-tabular}

\TocAt{chapter,section,subsection}
\Configure{tableofcontents*}{chapter,section}
\Configure{NavSection}{%
\booltrue{tocnoempty}
\HCode{<li>}}{\HCode{<ol>\Hnewline}}{}{\Tg</ol>\Tg</li>}
\Css{nav\#toc ol{list-style: none;}}

\begin{document}
\CssFile[custom.css]
/* css.sty */
\EndCssFile
\Configure{CoverMimeType}{image/jpg}
\DeclareGraphicsExtensions{.eps,.png,.jpg,.gif,}
\EndPreamble


MWE:

\documentclass{book}

\usepackage{mwe}

\usepackage[ngerman]{babel}

\usepackage{hyperref}
\hypersetup{%
citecolor=black,
urlcolor=black,
pdfpagemode=UseThumbs,
pdftitle={thetitle},
pdfauthor={theAuthor},
pdfsubject={thetitle},
pdfkeywords={thekeywords},
}

\makeatletter
\do\j\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w%
\do\x\do\y\do\z\do\&\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0}
\def\do@url@hyp{\do\-}
\makeatother

\def\subsectionautorefname{Kap.}
\def\figureautorefname{Abb.}
\def\tableautorefname{Tab.}
\def\chapterautorefname{Kap.}
\def\sectionautorefname{Kap.}
\def\subsectionautorefname{Kap.}
}

\usepackage[nohints]{minitoc}
\mtcselectlanguage{german}
\mtcsettitle{minitoc}{}
\mtcsettitle{minilof}{}
\mtcsettitle{minilot}{}
\mtcsetfeature{minitoc}{open}{\vspace{1cm}}
\nomtcrule
\nomlfrule
\nomltrule
\tightmtctrue

\begin{document}
\dominitoc
\dominilof
\dominilot
\doparttoc

\fakelistoffigures
\fakelistoftables
\ifdefined\HCode\else
\tableofcontents
\fi

\chapter{chapter 1}
\minitoc
\section{Table}

\begin{table}[ht!]
\centering
\caption{a table}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}

\begin{table}[ht!]
\centering
\caption{a table2}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}

\begin{table}[ht!]
\centering
\caption{a table3}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}

\begin{figure}
\caption{Sample figure}
\end{figure}

\begin{figure}
\caption{Sample figure2}
\end{figure}

\begin{figure}
\caption{Sample figure3}
\end{figure}

\section{LOT}
\minilot

\section{LOF}
\minilof

\end{document}


Is there a way to accomplish what i described above?

• Could you also post a TeX sample? Nov 22 '18 at 14:21
• i've added an MWE Nov 22 '18 at 14:51

The issue with the minitoc package is that it redefines lot of internal LaTeX commands, which interferes with tex4ht, which redefines them as well. In particular, it seems that table and figure information isn't saved. Fortunately, it works if the information had been saved in the normal LaTeX run. So before tex4ebook compile the document with normal LaTeX when tables or figures changed.

There is also one more issue.\minilot and \minilof commands use tabular environment internally and it causes a problem because you use the pic-tabular option, which instructs tex4ht to convert tables to images. To fix this, we need to provide alternative version of these commands, which don't use tabular. They also don't use spacing and page breaking commands that were originally uses, as these don't have any sense in the HTML code. It is generally better to just add some code to the commands redefined by tex4ht, but in this case we need to alter them heavily, as the original definition causes too much trouble.

Save this code as minitoc.4ht:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% minitoc.4ht                           2009-05-21-09:32 %
% Copyright (C) 1997--2009       Eitan M. Gurari         %
%                                                        %
% This work may be distributed and/or modified under the %
% conditions of the LaTeX Project Public License, either %
% version 1.3c of this license or (at your option) any   %
% in                                                     %
%   http://www.latex-project.org/lppl.txt                %
% and version 1.3c or later is part of all distributions %
% of LaTeX version 2005/12/01 or later.                  %
%                                                        %
% This work has the LPPL maintenance status "maintained".%
%                                                        %
% This Current Maintainer of this work                   %
% is Eitan M. Gurari.                                    %
%                                                        %
% If you modify this program your changing its signature %
% with a directive of the following form will be         %
% appreciated.                                           %
%            \message{signature}                         %
%                                                        %
%                             gurari@cse.ohio-state.edu  %
%                 http://www.cse.ohio-state.edu/~gurari  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\immediate\write-1{version 2009-05-21-09:32}

\NewConfigure{minitoc}{4}
\NewConfigure{parttoc}{4}
\NewConfigure{secttoc}{4}
\NewConfigure{minilof}{4}
\NewConfigure{partlof}{4}
\NewConfigure{sectlof}{4}
\NewConfigure{minilot}{4}
\NewConfigure{partlot}{4}
\NewConfigure{sectlot}{4}

\let\minitoc:\minitoc@
\def\minitoc@[#1]{%
\a:minitoc@
\minitoc:[#1]
\b:minitoc@
}
\NewConfigure{minitoc@}{2}

\def\minilot@[#1]{%
\global\@minilot@used@true
\if@mtc@longext@%
\def\@tocfile{mlt\The@mtc}%
\else
\def\@tocfile{T\The@mtc}%
\fi
\mtc@CkFile{\jobname.\@tocfile}
\if@mtc@FE
\mtcPackageInfo[I0006]{minitoc}%
{\jobname.\@tocfile\space is empty}
\@mtc@empty@minilot@true
\else
\beforeminilot
\begingroup
\makeatletter
\@ifundefined{mlt@pgno}%
{\let\@dottedtocline\@undottedtocline}{}
\@fileswfalse\mtc@hook@beforeinputfile
\mlt@setform
\global\openminilot\inminilottrue
\@input{\jobname.\@tocfile}%
\global\inminilotfalse\closeminilot
\global\@nobreakfalse\endgroup
\par\afterminilot\fi}%

\NewConfigure{minilot@}{2}

\let\minilot:\minilot@
\def\minilot@[#1]{%
\a:minilot@
\minilot:[#1]
\b:minilot@
}

\def\minilof@[#1]{%
\global\@minilof@used@true
\if@mtc@longext@%
\def\@tocfile{mlf\The@mtc}%
\else
\def\@tocfile{F\The@mtc}%
\fi
\mtc@CkFile{\jobname.\@tocfile}
\if@mtc@FE
\mtcPackageInfo[I0006]{minitoc}%
{\jobname.\@tocfile\space is empty}
\@mtc@empty@minilof@true
\else
\beforeminilof
\begingroup
\makeatletter
\@ifundefined{mlf@pgno}%
{\let\@dottedtocline\@undottedtocline}{}
\@fileswfalse\mtc@hook@beforeinputfile
\mlf@setform
\global\openminilof\inminiloftrue
\@input{\jobname.\@tocfile}%
\global\inminiloffalse\closeminilof
\leavevmode\mtc@strut
\global\@nobreakfalse\endgroup
\par\afterminilof\fi}%
\Hinput{minitoc}
\endinput


The TeX file doesn't need all the conditional code, just disable the \tableofcontents, which is handled by tex4ebook:

\documentclass{book}

\usepackage{mwe}

\usepackage[nohints]{minitoc}
\mtcselectlanguage{german}
\mtcsettitle{minitoc}{}
\mtcsettitle{minilof}{}
\mtcsettitle{minilot}{}
\mtcsetfeature{minitoc}{open}{\vspace{1cm}}
\nomtcrule
\nomlfrule
\nomltrule
\tightmtctrue

\begin{document}
\dominitoc
\dominilof
\dominilot
\doparttoc

\fakelistoffigures
\fakelistoftables
\ifdefined\HCode\else
\tableofcontents
\fi

\chapter{chapter 1}
\minitoc
\section{Table}

\begin{table}[ht!]
\centering
\caption{a table}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}

\begin{figure}
\caption{Sample figure}
\end{figure}

\section{LOT}
\minilot

\section{LOF}
\minilof

\end{document}


The \minitoc can be disabled in the .cfg file, just redefine it to \relax:

\let\minitoc\relax


This is the result:

• sorry for the late reply. It's working so far, but in front of every entry it says "figure.caption.6 ..." "figure.caption.7..." do you know what could cause it? I'm using the caption package with "compatibility=false" option and the supcation package. If you need any more infos let me know Jan 11 '19 at 14:48
• @Jonas I think I will need a full example of this behaviour. Jan 11 '19 at 15:07
• i edited the MWE. I played a bit around with the texfile and it seems it has something to do with the hyperref package. Im not quite sure what all the options are good for and if i really need them though, the preambel was just given to me to work with Jan 17 '19 at 11:22