LaTeX forum ⇒ Text FormattingList of Acronyms with alphabetical Ordering

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
hbaromega
Posts: 48
Joined: Mon Mar 07, 2011 8:21 pm

List of Acronyms with alphabetical Ordering

Postby hbaromega » Mon Nov 28, 2011 7:52 pm

I want to make a list of acronyms for my thesis. I see an acronym package installed in my system.

I want to make a list of acronyms that will automatically take care of alphabetical ordering as we see in a dictionary.

Say, if I define:

TF: Text Formatting

and then
LC : Latex Community

we should see LC to appear first and then TF.

How can I do this? Also if some elegance can be made in display, it would be appreciated.

Thanks.

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

Postby nlct » Fri Dec 02, 2011 11:47 am

As far as I know, the acronym package doesn't sort the acronyms alphabetically. You can use the glossaries package for a sorted list of acronyms. In addition to the documentation, there's an article in the Know How section on how to use it.

Regards
Nicola Talbot

hbaromega
Posts: 48
Joined: Mon Mar 07, 2011 8:21 pm

Postby hbaromega » Fri Dec 02, 2011 4:27 pm

Thank you, Ma'am.

But it seems that I have to label each time and I need to refer them to make it appear in my final document.

Can I make just a list of acronyms without labelling and referring?

Suppose I want to have the following structure.


  1. \documentclass{article}
  2.  
  3. \usepackage{glossaries}
  4.  
  5. \begin{document}
  6. \begin{itemize}
  7. \item {\bf LED:} {Light emitting diode}
  8. \item {\bf FET:} {Field effect transistor}
  9. \end{itemize}
  10.  
  11. \end{document}



How can I use glossary to sort the items alphabetically? And I also don't want to type \bf every time if possible.


Thanks once again.
Last edited by cgnieder on Fri Oct 05, 2012 12:33 am, edited 2 times in total.
Reason: added code markup

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

Postby nlct » Sat Dec 03, 2011 1:38 pm

But it seems that I have to label each time and I need to refer them to make it appear in my final document.

Can I make just a list of acronyms without labelling and referring?

You can just use \glsaddall to add all entries.
How can I use glossary to sort the items alphabetically? And I also don't want to type \bf every time if possible.

Don't use \bf it's obsolete. Use \bfseries (or \textbf) instead.

However, if you don't plan to reference any of the acronyms, you might find this message of use. Adapting that example:
  1. \documentclass{article}
  2.  
  3. \usepackage{datatool}
  4.  
  5. \begin{filecontents*}{test.csv}
  6. Acronym,Description
  7. LED,Light emitting diode
  8. FET,Field effect transistor
  9. \end{filecontents*}
  10.  
  11. \DTLloaddb{acronyms}{test.csv}
  12.  
  13. \DTLsort{Acronym}{acronyms}
  14.  
  15. \begin{document}
  16.  
  17. \section*{List of Acronyms}
  18.  
  19. \begin{itemize}
  20. \DTLforeach*{acronyms}{\thisAcronym=Acronym,\thisDesc=Description}%
  21. {\item \textbf{\thisAcronym} \thisDesc}%
  22. \end{itemize}
  23. \end{document}


Regards
Nicola Talbot
Last edited by cgnieder on Fri Oct 05, 2012 12:34 am, edited 1 time in total.
Reason: added inline code markup

hbaromega
Posts: 48
Joined: Mon Mar 07, 2011 8:21 pm

Postby hbaromega » Sat Dec 03, 2011 3:43 pm

Thanks. What does this test.csv file do?

Can I use this inside \begin{document} and \end{document}?

I mean, can I put the list inside the main .tex document, not in the preamble (like the way we do for bibliography) ?

Thanks.
Last edited by cgnieder on Fri Oct 05, 2012 12:35 am, edited 1 time in total.
Reason: added inline code markup

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

Postby nlct » Mon Dec 05, 2011 12:16 pm

Thanks. What does this test.csv file do?

The csv file contains the acronyms. The lines:
  1. \begin{filecontents*}{test.csv}
  2. Acronym,Description
  3. LED,Light emitting diode
  4. FET,Field effect transistor
  5. \end{filecontents*}

create a file called test.csv that contains the contents of the filecontents* environment. This file is then loaded into a database called "acronyms" using:
  1. \DTLloaddb{acronyms}{test.csv}

This command may occur in the document environment if you like, but you can only reference the database after it's been loaded. Once the database is loaded, it can be sorted according to the key "Acronym" (the first column of test.csv) using:
  1. \DTLsort{Acronym}{acronyms}


You can dispense with an external csv file if you like:
  1. \documentclass{article}
  2.  
  3. \usepackage{datatool}
  4.  
  5. % Define a convenient command to add a line
  6. % to the database
  7. \newcommand*{\addacronym}[2]{%
  8. \DTLnewrow{acronyms}%
  9. \DTLnewdbentry{acronyms}{Acronym}{#1}%
  10. \DTLnewdbentry{acronyms}{Description}{#2}%
  11. }
  12.  
  13. \begin{document}
  14.  
  15. % Create the database
  16. \DTLnewdb{acronyms}
  17. \addacronym{LED}{Light emitting diode}
  18. \addacronym{FET}{Field effect transistor}
  19.  
  20. \section*{List of Acronyms}
  21.  
  22. % Sort the database
  23. \DTLsort{Acronym}{acronyms}
  24.  
  25. % Display the contents of the database
  26. \begin{itemize}
  27. \DTLforeach*{acronyms}{\thisAcronym=Acronym,\thisDesc=Description}%
  28. {\item \textbf{\thisAcronym} \thisDesc}%
  29. \end{itemize}
  30. \end{document}


Regards
Nicola Talbot


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 3 guests