8

I want to use the nomenclature to make a custom index of files in a directory. As long as my section starts with a letter, there is no problem. But if I want to section it with a number it does not work.

I got this MWE from Nomenclature section :

\documentclass{article}
\usepackage{nomencl}
\usepackage{ifthen}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{A}}{\item[\textbf{A}]}{%
    \ifthenelse{\equal{#1}{0}}{\item[\textbf{0}]}
        {}
    }
    }
}
\makenomenclature
  \nomenclature[A]{$\Omega_N$}{Set of all buses (nodes).}
  \nomenclature[A]{$n,m$}{Index of all buses (nodes). $m$ is alias of $n$.}
  \nomenclature[A]{$\Omega_L$}{Set of all Transmission lines.}
  \nomenclature[A]{$l$}{Index of transmission lines.}
  \nomenclature[0]{$\Omega_{K}$}{Set of all genetors.}
\begin{document}
  Some text
  \printnomenclature
\end{document} 

What should happen: I get an index with two sections: One starting at 0 (one entry) and the other section A has four entries.

This is what I get: I get an index with a section with no label, one entry and the other section A with four entries. For some reason, 0 is not recognized.

I've tried

\ifthenelse{#1=0}}{\item[\textbf{0}]}

as well ... no luck. Maybe 0 is a number and does not like to be compared as string...?!

EDIT: I need sections 0-9 and a-z for my index.

Any ideas are appreciated.

gilu
  • 666
  • Substitute the 0 (zero) with a B when checking for equality? – Johannes_B Mar 26 '15 at 09:42
  • Well, that might work if I don't use the whole alphabet. Unfortunately I need 0-9, a-z for my index. It could/would help, if I could use two letters for sections instead of only one letter. – gilu Mar 26 '15 at 09:57
  • 1
    I'm afraid nomencl is not able to distinguish between digits: when you have \nomenclature[<digit>]{...}{...} the entry is placed in the “Symbols” group irrespective of the <digit>. And just the first character is used for this purpose. – egreg Mar 26 '15 at 10:08
  • 1
    @gilu This is a limitation of MakeIndex – egreg Mar 26 '15 at 10:13
  • @gilu You may want to look at the glossaries package that has much more features. – egreg Mar 26 '15 at 10:20
  • @egreg As far as I know glossaries can handle only A...Z as well as nomencl and I think it is for the same reason. – karlkoeller Mar 26 '15 at 10:23
  • @karlkoeller It should make easier using Xindy, which might be better in that respect. – egreg Mar 26 '15 at 10:26

1 Answers1

2

Since there's no answer for the nomencl package, here's how you can implement it with the glossaries package. This doesn't use makeindex's grouping system, but instead utilizes the hierarchical structure provided by glossaries:

\documentclass{article}

\usepackage[
 nopostdot,% suppress automatic post-description full stop
 automake,% automatically run makeindex if restricted shell escape enabled
 nonumberlist,% suppress location lists
 nogroupskip,% suppress group skips (we're overriding the default grouping)
 style=tree% hierarchical display style required
]{glossaries}

\makeglossaries

% \newentry{letter/number}{label}{settings}
\newcommand*{\newentry}[3]{%
  \ifglsentryexists{#1}{}%
  {%
    \newglossaryentry{#1}{name={#1},description={\nopostdesc}}%
  }%
  \newglossaryentry{#2}{parent={#1},sort={#2},#3}%
}

\newentry{A}{omegaN}
 {name={$\Omega_N$},description={Set of all buses (nodes).}}

\newentry{A}{nm}
 {name={$n,m$},description={Index of all buses (nodes). $m$ is alias of $n$.}}

\newentry{A}{omegaL}
 {name={$\Omega_L$},description={Set of all Transmission lines.}}

\newentry{A}{l}
 {name={$l$},description={Index of transmission lines.}}

\newentry{0}{omegaK}
 {name={$\Omega_{K}$},description={Set of all genetors.}}

\begin{document}
Some text
\glsaddall% index all defined entries

\printglossaries
\end{document}

This defines the command \newentry which will define the parent entry (for the group) if it hasn't already been defined. It will then define the actual entry as a child entry. Since all the name fields use commands or special characters (like \Omega or $), the sort key is set to the label by default to assist makeindex's sorting. This can be changed, if required, in the third argument of \newentry.

The result looks like:

image of glossary

The style can be changed if required. There are a number of predefined styles. You'll need one that can support hierarchical entries. Table 15.1 in the user guide provides a summary. You'll need one where the maximum level is greater than 0 but doesn't have the "Homograph" column checked.

Nicola Talbot
  • 41,153