# Formatting new list of definitions with tocloft

Using the tocloft package in LaTeX, I created a List of Definitions. From the package documentation and some online examples I came up with:

\newcommand{\listdefinitionname}{My list of definitions}
\newlistof{definition}{def}{\listdefinitionname}
\newcommand{\definition}[1]{%
\refstepcounter{definition}
\par\noindent\textbf{TheDefinition \thedefinition. #1}
{\protect\numberline{\thechapter.\thedefinition}#1}\par}


...

\listofdefinition

1. In the "My list of definitions" that is created, for all definitions, the first letter of a definition name superposes the last digit in the definition number. How can I fix this?

2. The numbering seems to be wrong. If I try \newlistof[chapter]{definition}{def}{\listdefinitionname}, the definitions throughout 5 chapters are numbered smth like 1.1.1.1,.. 3.3.3.8.. etc. I would like to obtain the numbering from the List of figures, chapternumber.figurenumber, where figurenumber starts with 1 for every new chapter.

3. \listoffigures issues a list of figures, indented by about 1 cm from the left. With \listofdefinition the entries begin right at the left margin. How can I get the List of figures formatting for the list of definitions?

-

## migrated from stackoverflow.comFeb 3 '12 at 18:42

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Feb 3 '12 at 18:46

The following minimal example works for me in terms of the book document class:

\documentclass{book}
\usepackage{tocloft}% http://ctan.org/pkg/tocloft
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

\newcommand{\listdefinitionname}{My list of definitions}
\newlistof{definition}{def}{\listdefinitionname}
\newcommand{\definition}[1]{%
\refstepcounter{definition}%
\par\noindent\textbf{The Definition~\thedefinition. #1}%
{\protect\numberline{\thechapter.\thedefinition}#1}\par%
}
\makeatletter
\makeatother

\begin{document}

\listoffigures
\listofdefinition
\chapter{A chapter}
\begin{figure}\caption{Some figure}\end{figure}
\begin{figure}\caption{Some figure}\end{figure}
\definition{Some definition}
\begin{figure}\caption{Some figure}\end{figure}
\definition{Some definition}
\begin{figure}\caption{Some figure}\end{figure}
\definition{Some definition}

\chapter{A chapter}
\begin{figure}\caption{Some figure}\end{figure}
\begin{figure}\caption{Some figure}\end{figure}
\definition{Some definition}
\begin{figure}\caption{Some figure}\end{figure}
\definition{Some definition}
\begin{figure}\caption{Some figure}\end{figure}
\definition{Some definition}

\end{document}


1. I've inserted the definition entries to be type figure rather using

\addcontentsline{def}{figure}
{\protect\numberline{\thechapter.\thedefinition}#1}\par%


That way they are formatted similarly, avoiding any overlap. If you have more definitions and still overlap, you need to change the width of the column.

2. My numbering works. You could also use \arabic{chapter}.\thedefinition or even \arabic{chapter}.\arabic{definition} which should strip any inherited counters attached to \thechapter or \thedefinition.

3. Solved via (1.) above.

I've also used the etoolbox package to add a vertical space between the chapter-separated definitions, similar to that of the LoF and LoT. This was done using \preto\chapter{<stuff>} which adds <stuff> before \chapter. Here stuff is \addvspace{10\p@} which adds a maximum of 10\p@ (10pt) vertically.

-