I have tried searching the web and this web for a solution and looked in "The LATEX Companion" without finding any hints. Any help would be appreciated.
Code: Select all
\documentclass{book}
\usepackage{tocloft}
\usepackage[english]{babel}
\newcommand{\listEXname}{List of Examples}
\newlistof{EX}{exp}{\listEXname}
\newcounter{ex}[chapter]
\renewcommand\theex{\thechapter.\arabic{ex}}
\newenvironment{EX}[1]%
{ \refstepcounter{ex}%
\noindent\ignorespaces %
{\bfseries Example~\theex~#1} %
\protect\addcontentsline{exp}{EX}{\protect\numberline{\theex}~#1}\par}%
{ ~\noindent\newline \par\nointerlineskip\ignorespacesafterend}
\begin{document}
\listofEX
\addtocounter{chapter}{10} %the problem only appears for large numbers
\chapter{Many examples}
\begin{EX}{some name}
the example
\end{EX}
\addtocounter{ex}{10} %the problem only appears for large numbers
\begin{EX}{some name}
the example
\end{EX}
\end{document}