Is there any way to alphabetize a list in LaTeX without using \makeindex?
Personally i suddenly find there ought to be an alphabetical variant or option to i.e. the \description itemize environment.
Graphics, Figures & Tables ⇒ List alphabetization in LaTeX
NEW: TikZ book now 40% off at Amazon.com for a short time.

List alphabetization in LaTeX
You could use the datatool package to create a database of your items and then sort it. For example:
Regards
Nicola Talbot
Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{datatool}\newcommand{\sortitem}[2]{%\DTLnewrow{list}%\DTLnewdbentry{list}{label}{#1}%\DTLnewdbentry{list}{description}{#2}%}\newenvironment{sortedlist}%{%\DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}%}%{%\DTLsort{label}{list}%\begin{description}%\DTLforeach*{list}{\theLabel=label,\theDesc=description}{%\item[\theLabel] \theDesc}%\end{description}%}\begin{document}\begin{sortedlist}\sortitem{banana}{A yellow fruit}\sortitem{pear}{An oddly shaped fruit}\sortitem{apple}{A roundish fruit}\end{sortedlist}\end{document}
Nicola Talbot
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Re: List alphabetization in LaTeX
Magnificent! Thanks a lot!
Re: List alphabetization in LaTeX
But, hey!
It seems i can only put one \sortedlist in my document. Using more than one i get an error message that says:
./test.tex:37: Undefined control sequence.
<argument> \DTLcleardb
{list}
l.37 \begin{sortedlist}
Do i need to clear the sorting prosess before starting a new \sortedlist or something?
Many thanks in advance.
christoi
It seems i can only put one \sortedlist in my document. Using more than one i get an error message that says:
./test.tex:37: Undefined control sequence.
<argument> \DTLcleardb
{list}
l.37 \begin{sortedlist}
Do i need to clear the sorting prosess before starting a new \sortedlist or something?
Many thanks in advance.
christoi
List alphabetization in LaTeX
You need to update your version of datatool. (\DTLcleardb was new to version 2.03)./test.tex:37: Undefined control sequence.
<argument> \DTLcleardb
{list}
l.37 \begin{sortedlist}
Regards
Nicola Talbot
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/