GeneralSort a list alphabetically

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Sydney
Posts: 7
Joined: Tue Apr 05, 2011 7:33 pm

Sort a list alphabetically

Post by Sydney »

Hi all, :)

How can I sort a list alphabetically?

I am doing like a dictionary, but I don't want to sort my items manually, is there a way to do it automatically?

Example:

Code: Select all

\begin{description}
\item[Bird] definition of a Bird
\item[Animal] definition of an Animal 
\item[Hello] definition of Hello
\item[Fantastic] definition of Fantastic
\item[Thanks] definition of Thanks
\end{description}
I'd like to sort the words Bird, Animal, Hello, ... automatically. How can I do that?

Thanks very much. :)

Sydney
Last edited by Sydney on Wed Apr 06, 2011 9:03 pm, edited 1 time in total.

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Sort a list alphabetically

Post by Stefan Kottwitz »

Hi Sydney,

sorting can be done using makeindex.

Instead of writing a description list, I would use a package which is capable of sorting. My choice would be the glossaries package. This package uses makeindex, just as nomencl does.

Stefan
LaTeX.org admin
User avatar
Sydney
Posts: 7
Joined: Tue Apr 05, 2011 7:33 pm

Re: Sort a list alphabetically

Post by Sydney »

Hi Stefan,

Thanks very much for your reply.

I am working on it, but I am having some issues with \printglossaries

I understand that I have to compile first, then makeglossaries myDoc (this step doesn't work for me on windows), and recompile again.

I'll let you know if I can do the step 2 on windows ...

Thanks,

Tony
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Sort a list alphabetically

Post by Stefan Kottwitz »

Hi Tony,

for the makeglossaries script a Perl installation is required. You could install ActivePerl on Windows.

However, you don't need that script. You could use makeindex directly. Have a look at 1.3.3 Using makeindex explicitly. It means calling

Code: Select all

makeindex -s ⟨style⟩.ist -t ⟨base⟩.glg -o ⟨base⟩.gls ⟨base⟩.glo
at the command prompt.

Which editor do you use? Some editors are capable of calling makeindex for you.

Stefan
LaTeX.org admin
User avatar
Sydney
Posts: 7
Joined: Tue Apr 05, 2011 7:33 pm

Sort a list alphabetically

Post by Sydney »

Hi Stefan_K, :) :) :)

That's alright. I get it! It works fine!!!!!

I just needed to install Perl so that the command makeindex from my terminal works.

Also, I used the package glossary instead of glossaries, does it matter? Are they any important differences between these 2?

Cheers mate,

For people who wants to do a glossary by using the package glossary:

1°/

Code: Select all

\usepackage{glossary}
\makeglossary
2°/

Code: Select all

\glossary{name={entry name}, description={entry description}}
%Here is an example
\glossary{name={hello}, description={an expression of greeting}}
\glossary{name={animal}, description={a living organism characterized by voluntary movement}}
3°/ Then, you have to tell Latex where to place you glossary inside the document

Code: Select all

\printglossary
4°/ Then, things get complicated

First, you need to download perl if you don't have it.
Then, open a terminal. On windows, go to your working directory containing your MyLatexDocument.tex
Type latex MyLatexDocument

Your doc is compiling, and the files MyLatexDocument.glo MyLatexDocument.ist MyLatexDocument.glg and MyLatexDocument.gls are created.

Type the command makeindex MyLatexDocument.glo -s MyLatexDocument.ist -t MyLatexDocument.glg -o MyLatexDocument.gls

Finally, compile again:
Type latex MyLatexDocument



Sydney.
User avatar
Sydney
Posts: 7
Joined: Tue Apr 05, 2011 7:33 pm

Re: Sort a list alphabetically

Post by Sydney »

Thanks Stefan, :)

Works perfectly indeed!

I am using Code::Blocks
Do you reckon it's fine?
I am not sure whether or not this editor is capable of calling makeindex for us. Do you know about this? :D

Thanks very much for your time.

Sydney
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Sort a list alphabetically

Post by localghost »

Sydney wrote:[…] I just needed to install Perl so that the command makeindex from my terminal works. […]
MakeIndex does not need Perl.


Thorsten
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Sort a list alphabetically

Post by nlct »

Sydney wrote: Also, I used the package glossary instead of glossaries, does it matter? Are they any important differences between these 2?
Yes, glossary is obsolete and no longer maintained. It was replaced by glossaries.

Regards
Nicola Talbot
Post Reply