8

I'd like to print a multicolumn nomenclature list that consists of several groups. At the moment, using the grouping approach described in the manual and with a code snippet from http://www.latex-community.org/forum/viewtopic.php?f=51&t=7892, it works in principle.

However, the list runs down the entire first column of the page and then continues on the second, regardless of the groups. What I'd prefer is for each group to be in its own multicols environment:

What I have:

What I'd like:

Is there a way to achieve this with the nomencl package?


\documentclass{article}
\usepackage{nomencl}
\usepackage{ifthen}
\usepackage{multicol}
\makenomenclature


\renewcommand{\nomgroup}[1]{%
  \ifthenelse{\equal{#1}{A}}{%
   \medskip\item[\large\textbf{\textsf{Latin}}]\medskip%
    }{%
    \ifthenelse{\equal{#1}{B}}{%    
     \medskip\item[\large\textbf{\textsf{Greek}}]\medskip}{%
            \medskip}
    }
}

\renewcommand*\nompreamble{\begin{multicols}{2}}
\renewcommand*\nompostamble{\end{multicols}}


\begin{document}  

\nomenclature[A]{a}{1}%
\nomenclature[A]{b}{2}%
\nomenclature[A]{c}{3}%
\nomenclature[A]{d}{4}%
\nomenclature[A]{e}{5}%
\nomenclature[A]{f}{6}%
\nomenclature[A]{g}{7}%
\nomenclature[A]{h}{8}%
\nomenclature[A]{i}{9}%
\nomenclature[A]{j}{10}%
\nomenclature[A]{k}{11}%
\nomenclature[A]{l}{12}%


\nomenclature[B]{$\alpha$}{1}%
\nomenclature[B]{$\beta$}{2}%
\nomenclature[B]{$\gamma$}{3}%


\printnomenclature
\end{document}
7

Not sure this is the best solution, but still...

% arara: pdflatex
% arara: nomencl
% arara: pdflatex
\documentclass{article}
\usepackage{nomencl}
\usepackage{multicol}
\makenomenclature

\makeatletter
\newif\if@nomlist

\newcommand*\nomlist{%
  \@nomlisttrue
  \list{}{%
    \labelwidth\nom@tempdim
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \itemsep\nomitemsep
    \let\makelabel\nomlabel}}

\renewcommand*\thenomenclature{%
  \@ifundefined{chapter}%
    {\section*{\nomname}\if@intoc\addcontentsline{toc}{section}{\nomname}\fi}%
    {\chapter*{\nomname}\if@intoc\addcontentsline{toc}{chapter}{\nomname}\fi}%
  \nompreamble
  \@nomlistfalse
}

\renewcommand\nomgroup[1]{%
  \if@nomlist\endlist\end{multicols}\fi
  \ifx#1A\relax
    \def\nomgroupname{Latin}%
  \else
    \ifx#1B\relax
      \def\nomgroupname{Greek}%
    \else
      \def\nomgroupname{Other}%
    \fi
  \fi
  \begin{multicols}{2}[\noindent\large\textbf{\textsf{\nomgroupname}}]
  \nomlist
}

\renewcommand*\nompreamble{}
\renewcommand*\nompostamble{\end{multicols}}
\makeatother

\usepackage{lipsum}
\begin{document}
\lipsum[1-2]

\nomenclature[A]{a}{1}%
\nomenclature[A]{b}{2}%
\nomenclature[A]{c}{3}%
\nomenclature[A]{d}{4}%
\nomenclature[A]{e}{5}%
\nomenclature[A]{f}{6}%
\nomenclature[A]{g}{7}%
\nomenclature[A]{h}{8}%
\nomenclature[A]{i}{9}%
\nomenclature[A]{j}{10}%
\nomenclature[A]{k}{11}%
\nomenclature[A]{l}{12}%

\nomenclature[B]{$\alpha$}{1}%
\nomenclature[B]{$\beta$}{2}%
\nomenclature[B]{$\gamma$}{3}%

\printnomenclature
\end{document}

enter image description here

1

The solution by cgnieder is almost perfect as it occasionally breaks for long entries that span 2 or more rows.

Entry broken over two columns

Adding \begin{minipage}[t]{\linewidth}Your nomenclature entry\end{minipage} will prevent it from being broken.

No more broken entries

The spacing between entries on the new version are quite large so you should add the \raggedcolumns option. If you don't want to manually add the minipage use the following code but this renaming will make the group mandatory and entries will need to be changed from \nomenclature[B]{$\alpha$}{1} to \nomenclature{B}{$\alpha$}{1} (note the square braces are now curly). There is probably a better way to do this but my custom latex code knowledge isn't the best.

\usepackage{letltxmacro}
\LetLtxMacro\oldnomenclature\nomenclature
\renewcommand{\nomenclature}[3]{\oldnomenclature[{#1}]{#2}{\begin{minipage}[t]{\linewidth}#3\end{minipage}}}

No large white space between entries in second column

\documentclass{article}
\usepackage{nomencl}
\usepackage{multicol}
\makenomenclature

\makeatletter
\newif\if@nomlist

\newcommand*\nomlist{%
  \@nomlisttrue
  \list{}{%
    \labelwidth\nom@tempdim
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \itemsep\nomitemsep
    \let\makelabel\nomlabel}}

\renewcommand*\thenomenclature{%
  \@ifundefined{chapter}%
    {\section*{\nomname}\if@intoc\addcontentsline{toc}{section}{\nomname}\fi}%
    {\chapter*{\nomname}\if@intoc\addcontentsline{toc}{chapter}{\nomname}\fi}%
  \nompreamble
  \@nomlistfalse
}

\renewcommand\nomgroup[1]{%
  \if@nomlist\endlist\end{multicols}\fi
  \ifx#1A\relax
    \def\nomgroupname{Latin}%
  \else
    \ifx#1B\relax
      \def\nomgroupname{Greek}%
    \else
      \def\nomgroupname{Other}%
    \fi
  \fi
  \begin{multicols}{2}[\raggedcolumns\noindent\large\textbf{\textsf{\nomgroupname}}]
  \nomlist
}

\renewcommand*\nompreamble{}
\renewcommand*\nompostamble{\end{multicols}}
\makeatother

\usepackage{lipsum}
\begin{document}

\nomenclature[A]{a}{1}%
\nomenclature[A]{b}{2}%
\nomenclature[A]{c}{3}%
\nomenclature[A]{d}{4}%
\nomenclature[A]{e}{5}%
% \nomenclature[A]{f}{This is a very long description that won't fit so it gets split on to multiple columns}%
\nomenclature[A]{f}{\begin{minipage}[t]{\linewidth}This is a very long description that won't fit so it gets split on to multiple columns\end{minipage}}%
\nomenclature[A]{g}{7}%
\nomenclature[A]{h}{8}%
\nomenclature[A]{i}{9}%
\nomenclature[A]{j}{10}%
\nomenclature[A]{k}{11}%

\nomenclature[B]{$\alpha$}{1}%
\nomenclature[B]{$\beta$}{2}%
\nomenclature[B]{$\gamma$}{3}%

\printnomenclature

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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