# How to make the list of listings to work properly in tex4ebook?

How to make the list of listings to work properly in tex4ebook?

Commands \tableofcontents and \listoffigureswork correctly.

The pdf result

The epub result

I didn't found any suggestion to lstlistoflistings in tex4ebook in the internet.

A MWE follows

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mcode}

\renewcommand{\lstlistingname}{Algorithm}
\renewcommand{\lstlistlistingname}{List of Algorithms}

\begin{document}
\lstlistoflistings

\lstinputlisting[label = {alg:alg_01}, caption = {alg 01}]
{alg_01.m}

\lstinputlisting[label = {alg:fc_alg_02}, caption = {fc alg 02}]
{fc_alg_02.m}
\end{document}

• @michal.h21, I'm sorry calling you here and asking again for help, but I didn't find any hint to solve this problem. And as I also don't understand the syntax to create a config file as I've seen to solve other issues, I only have the option to ask someone I know might solve it. – FHZ Feb 7 at 15:11
• I've posted an answer. I am slowly trying to work on all tex4ht bug reports, there were too many of them in the past few months, so I was bit exhausted :( – michal.h21 Feb 13 at 16:40

Try the following configuration:

\Preamble{xhtml}
\makeatletter
\ConfigureToc{lol} {}{\empty}{}{\newline}
\lst@UserCommand\lstlistoflistings{\bgroup
\ifdefined\chapter\chapter*{\lstlistlistingname}\else\section*{\lstlistlistingname}\fi
\TableOfContents[lol]
\egroup}
\makeatother
\begin{document}
\EndPreamble


The commands that use the TOC mechanism needs a configuration. The \TableOfContents[list of types]. The \lstlistoflistings writes entries to the filename.lol file, so \TableOfContents[lol] will print these entries. It is also necessary to configure TOC type, using \ConfigureToc{lol}. I've used the configuration that tex4ht uses for all other types. It just prints the entries on separate lines.

This is the result:

• It worked perfectly! I don't have words to express my gratitude. I only hope some day tex4ebook will be able to fully convert all LaTeX features to epub. The issue with equation/split/align I made a workaround. I can finally publish a epub version of my book. Once again thanks. – FHZ Feb 13 at 19:07
• @FHZ I hope to look at the split issue soon. the ideal would be if Epub readers supported MathML, as images are not ideal solution anyway. but the support is non-existent, so we will always get not good results – michal.h21 Feb 13 at 20:23