Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I write papers, reports, etc., and frequently use the same set of acronyms, so I thought it would be useful to just keep all the acronym definitions in a single file. Seems like the sensible approach to me.

The problem is that sometimes I do want an acronym list, and sometimes I don't, and unfortunately, it seems that LaTeX doesn't provide an elegant way of doing this. If you define an acronym using \acro then latex will put it in an acronym list, and if you define it with with \acrodef then it won't.

It seems like this prevents me from keeping a single source file for all my acronyms and using it in both documents in which I would like an acronym list and documents in which I wouldn't.

Does anyone know of an elegant solution for this?

share|improve this question

migrated from stackoverflow.com Aug 12 '11 at 9:27

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

    
Welcome to TeX.sx! Your question was migrated here from another stackexchange site. 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. –  N.N. Aug 12 '11 at 9:33
1  
So what you want is a something like what bibtex does: Optionally only print the used acronyms to a list of acronyms. –  Seamus Aug 12 '11 at 10:05
2  
You can use the package glossaries with the script makeglossaries. The package has also an option for acronym. –  Marco Daniel Aug 12 '11 at 10:45
    
@Marco perhaps you could write up an answer explaining this? –  Seamus Aug 12 '11 at 10:48
    
@Seamus: I will do it –  Marco Daniel Aug 12 '11 at 10:49

3 Answers 3

I believe the acronym package option you're looking for is nolist, e.g.,

\usepackage[nolist,nohyperlinks]{acronym}

The package options aren't clearly listed in the CTAN documentation, but they're discernible from the implementation section. They are:

  • footnote
    • The option footnote makes the full name appear as a footnote.
  • nohyperlinks
    • If hyperref is loaded, all acronyms will link to their glossary entry. With the option nohyperlinks these links can be suppressed.
  • printonlyused
    • Only list used acronyms
  • withpage
    • In printonlyused-mode show the page number where each acronym was first used.
  • smaller
    • Make the acronym appear smaller.
  • dua
    • The option dua stands for “don’t use acronyms”. It leads to a redefinition of \ac and \acp, making the full name appear all the time and suppressing all acronyms but the explicity requested by \acf or \acfp.
  • nolist
    • The option nolist stands for “don’t write the list of acronyms”.
share|improve this answer
    
Or alternatively the "printonlyused" option, when using a list (that is, if I understand the question correctly). –  ienissei Jan 4 '12 at 8:13

According to the comments above I write a small answer which explain the using of the package glossaries for acronyms.

First the minimal example which uses the filecontents-environment to create an external file for the acronmys:

\RequirePackage{filecontents}
\begin{filecontents}{\jobname-acro.tex}
\newacronym{MS}{MS}{Microsoft}
\newacronym{CD}{CD}{Compact Disc}
\newacronym{Mac}{Mac}{Short form of Apple Mac}
\end{filecontents}
\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc} %Dateikodierung
\usepackage[acronym,toc]{glossaries}
\loadglsentries[\acronymtype]{\jobname-acro}

\makeglossaries
\begin{document}
\tableofcontents{}
\printglossary[type=\acronymtype,style=long]

\section{Some examples}
Some Text \gls{MS} and \gls{Mac}


\end{document}

The external file is loaded by \loadglsentries.

To create the list of acronyms you can use the script makeglossaries (need perl)

makeglossaries filename

(no extension) or by using makeindex:

makeindex -s filename.ist -t filename.alg -o filename.acr filename.acn

The examples shows that the entry CD isn't part of the list of acronyms.

The whole compilation looks like:

(pdf)latex
makeglossaries
(pdf)latex
(pdf)latex

The result

share|improve this answer

You can use package glossaries. You can place file with definition of acronyms somewhere in your local texmf tree. This will enable you to use it from different directories. (to find, where local texmf is placed, see Where is "texmf" on a Windows install?) Contents of this file (I used location ~/texmf/tex/generic/acronyms.tex on my PC)

\newacronym{hello}{hw}{hello world}
\newacronym{svm}{svm}{support vector machines}
\newacronym{nu}{nu}{not used}

and example document:

\documentclass{article}
\usepackage[acronym,smallcaps]{glossaries}

\loadglsentries{acronyms}
\makeglossaries
\begin{document}
\Gls{hello}, just use some \gls{svm}. Or are \gls{svm} only for watching?

 \printglossary[type=\acronymtype]

\end{document}

result

List of glossaries is generated with command makeglossaries documentname. For more information about available options, see glossaries manual (texdoc glossaries-user.pdf), section 13.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.