I'm not aware of a way to do this with nomencl
. However, there are other packages which can be used. I'll give two examples, one for my package acro
and one for glossaries
.
acro
The acro
package allows to assign acronyms to a class and print lists for each class (also for combined classes...). This fact can be used for the task. Entries are defined with the following syntax:
\DeclareAcronym{<ID>}{
short = <short> ,
long = <long> ,
class = <class>
}
Here is a full example:
\documentclass{article}
\usepackage{acro}
% probably a good idea for the nomenclature entries:
\acsetup{first-style=short}
% class `abbrev': abbreviations:
\DeclareAcronym{ny}{
short = NY ,
long = New York ,
class = abbrev
}
\DeclareAcronym{la}{
short = LA ,
long = Los Angeles ,
class = abbrev
}
\DeclareAcronym{un}{
short = UN ,
long = United Nations ,
class = abbrev
}
% class `nomencl': nomenclature
\DeclareAcronym{angelsperarea}{
short = \ensuremath{a} ,
long = The number of angels per unit area ,
sort = a ,
class = nomencl
}
\DeclareAcronym{numofangels}{
short = \ensuremath{N} ,
long = The number of angels per needle point ,
sort = N ,
class = nomencl
}
\DeclareAcronym{areaofneedle}{
short = \ensuremath{A} ,
long = The area of the needle point ,
sort = A ,
class = nomencl
}
\begin{document}
\ac{ny}, \ac{la} and \ac{un} are abbreviations whereas
\ac{angelsperarea}, \ac{numofangels} and \ac{areaofneedle} are part of the
nomenclature
\printacronyms[include=abbrev,name=Abbreviations]
\printacronyms[include=nomencl,name=Nomenclature]
\end{document}
glossaries
The glossaries
package is much more powerfull. You can define as many glossaries as you like. Here we can use the fact that a glossary for acronyms is already defined. Similar to nomencl
it requires you to run a script to sort the entries. If your file is called file.tex
this is usually done by calling
makeglossaries file
from the command line. Details can be found in the user manual (page 26, section 1.3.3).
The full example:
\documentclass{article}
\usepackage{longtable}
\usepackage[acronym]{glossaries}
% abbreviations:
\newacronym{ny}{NY}{New York}
\newacronym{la}{LA}{Los Angeles}
\newacronym{un}{UN}{United Nations}
% nomenclature:
\newglossaryentry{angelsperarea}{
name = $a$ ,
description = The number of angels per unit area,
}
\newglossaryentry{numofangels}{
name = $N$ ,
description = The number of angels per needle point
}
\newglossaryentry{areaofneedle}{
name = $A$ ,
description = The area of the needle point
}
\makeglossaries
\begin{document}
\gls{ny}, \gls{la} and \gls{un} are abbreviations whereas
\gls{angelsperarea}, \gls{numofangels} and \gls{areaofneedle} are part of the
nomenclature
\printglossary[type=\acronymtype,title=Abbreviations]
\printglossary[title=Nomenclature]
\end{document}
The nomencl
package typesets the labels in a fixed width box; if the label (together with a padding space) exceeds this width, the description is moved right.
\documentclass[12pt,a4paper]{report}
\usepackage[intoc]{nomencl}
\makenomenclature
\setlength\nomlabelwidth{1.5cm}
\nomenclature{AA}{text}
\nomenclature{AAA}{text}
\nomenclature{AAB}{text}
\nomenclature{AACD}{text}
\begin{document}
x
\printnomenclature
\end{document}
will do. An automatic setting is possible, by measuring the labels and writing the maximum width in the .aux
file. A couple of compilations are necessary if the labels change.
\documentclass[12pt,a4paper]{report}
\usepackage[intoc]{nomencl}
\makenomenclature
\usepackage{xpatch}
\makeatletter
\xapptocmd\thenomenclature{\let\@item\nomencl@item\def\nomencl@width{0pt}}{}{}
\let\nomencl@item\@item
\xpretocmd\nomencl@item{\nomencl@measure{#1}}{}{}
\def\nomencl@measure#1{%
\sbox0{#1}%
\ifdim\wd0>\nomencl@width\relax
\edef\nomencl@width{\the\wd0}%
\fi
}
\xapptocmd\endthenomenclature{%
\immediate\write\@mainaux{\global\nomlabelwidth\nomencl@width\relax}%
}{}{}
\makeatother
\nomenclature{AA}{text}
\nomenclature{AAA}{text}
\nomenclature{AAB}{text}
\nomenclature{AACD}{text}
\begin{document}
x
\printnomenclature
\end{document}
Version with commented code and two column nomenclature
\documentclass[12pt,a4paper]{report}
\usepackage[intoc]{nomencl}
\usepackage{multicol}
\makenomenclature
\usepackage{xpatch}
\makeatletter
%%% we want that \item[...] measures its argument
\xapptocmd\thenomenclature{\let\@item\nomencl@item\def\nomencl@width{0pt}}{}{}
% copy \@item
\let\nomencl@item\@item
% patch the copy
\xpretocmd\nomencl@item{\nomencl@measure{#1}}{}{}
% define the measuring command
\def\nomencl@measure#1{%
\sbox0{#1}%
\ifdim\wd0>\nomencl@width\relax
\edef\nomencl@width{\the\wd0}%
\fi
}
%%% we want a two column nomenclature, so we patch
%%% \thenomenclature to start multicols
\xpatchcmd\thenomenclature
{\section*{\nomname}}
{\begin{multicols}{2}[\section*{\nomname}]}
{}{}
\xpatchcmd\thenomenclature
{\chapter*{\nomname}}
{\begin{multicols}{2}[\chapter*{\nomname}]}
{}{}
%%% finally we patch \endthenomenclature to
%%% annotate in the aux file the required width
\xapptocmd\endthenomenclature{%
\immediate\write\@mainaux{\global\nomlabelwidth\nomencl@width\relax}%
\end{multicols}
}{}{}
\makeatother
\nomenclature{AA}{text}
\nomenclature{AAA}{text}
\nomenclature{AAB}{text}
\nomenclature{AACD}{text}
\begin{document}
x
\printnomenclature
\end{document}
Best Answer
May I recommend the tool "arara"?
Just use the following MWE:
and run
arara thesis.tex
. That works and you don't have to waste more thoughts on themakeindex
compiling routine ofnomencl