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.

Is there a way to automatically remove duplicates from the generated Nomenclature?

E.g. adding multiple times:

\nomenclature{HTML}{HyperText Markup Language}

in your TeX file should generate only one entry in the Nomenclature.

This minimal example shows what happens:

% This is test.tex
\documentclass{book}
\usepackage{nomencl}
\makenomenclature
\begin{document}

Some text \nomenclature{HTML}{HyperText Markup Language}

\newpage
\chapter{Chapter}

Some text \nomenclature{HTML}{HyperText Markup Language}

\printnomenclature
\end{document}

The nomenclature was generated with makeindex test.nlo -s nomencl.ist -o test.nls and here is the test.nls:

\begin{thenomenclature}

\nomgroup{A}

  \item [{HTML}]\begingroup HyperText Markup Language\nomeqref {0}
        \nompageref{1}
  \item [{HTML}]\begingroup HyperText Markup Language\nomeqref {1.0}
        \nompageref{3}

\end{thenomenclature}

Problem comes with lines at test.nlo are not identical:

\nomenclatureentry{aHTML@[{HTML}]\begingroup HyperText Markup Language\nomeqref {0}|nompageref}{1}
\nomenclatureentry{aHTML@[{HTML}]\begingroup HyperText Markup Language\nomeqref {1.0}|nompageref}{3}

In my real tex \nomeqref's content is \relax x.x for duplicate entries.

share|improve this question
    
I tried to use uniq command to .nls file but each entry is not a single line but 2 lines. –  juanmah Oct 27 '11 at 14:28
1  
You are misusing the nomencl package, which is made for unique entries. You probably should be using either acronym or the more general glossaries package. –  egreg Dec 22 '11 at 13:33
    
You're perfectly right @egreg, acronym package fits exactly what I need. Thanks! –  juanmah Dec 23 '11 at 10:15
add comment

4 Answers

up vote 6 down vote accepted

The nomencl package has a different purpose than what you're using it for.

The package's purpose is to write a list of symbols or abbreviation used, with a reference to the place where they're defined or first used (at the user's choice). So it's not meant to place multiple reference to a nomenclature.

For acronyms the best package around is glossaries, but the simpler acronym is often used.

share|improve this answer
add comment

I may have missed something but with the following code I get only one entry in the nomenclature.

% This is test.tex
\documentclass{article}
\usepackage{nomencl}
\makenomenclature
\begin{document}
Some text \nomenclature{HTML}{HyperText Markup Language}

\newpage

Some text \nomenclature{HTML}{HyperText Markup Language}

\printnomenclature

\end{document}

The nomenclature was generated with makeindex test.nlo -s nomencl.ist -o test.nls and here is the test.nls.

\begin{thenomenclature} 

 \nomgroup{A}

  \item [{HTML}]\begingroup HyperText Markup Language\nomeqref {0}
        \nompageref{1, 2}

\end{thenomenclature}
share|improve this answer
    
I edited the question because I couldn't show here commented the minimal example that generate multiple entries. –  juanmah Dec 22 '11 at 12:06
add comment

This is a manual and not elegant post-editing workaround to test.nlo

In command line do:

cat test.nlo | sort | uniq -w 49 > test.nlo

and then:

makeindex test.nlo -s nomencl.ist -o test.nls

uniq -w parameter is 49 because is the width of the shortest nomenclature before differences in nomeqref \nomenclatureentry{a@[{}]\begingroup \nomeqref { and can handle up to 30 characters in nomenclatures.

share|improve this answer
    
It could be shorter: cat test.nlo | sort | uniq -w 49 | makeindex -i -s nomencl.ist -o test.nls –  juanmah Dec 22 '11 at 12:37
add comment

This is a manual and not elegant post-editing workaround to test.nls

In kile/kate editor do replace whole text with the following regular expression:

Find:    (.*\[\{)(.*)\}\].*\n.*\n.*\[\{\2\}\]
Replace: \1\2\}\]
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.