Generaltocloft | Number collides with Text in custom List

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
gremlin
Posts: 1
Joined: Mon Dec 12, 2011 11:58 am

tocloft | Number collides with Text in custom List

Post by gremlin »

I created my own examples environment (EX in code below) and I manage to get a listing of my examples. The formatting of the list, however, is bad. For some reason the space between the number and the text describing the example gets too small.

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}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply