グループ化された複数列の命名法

グループ化された複数列の命名法

複数のグループからなる複数列の命名法リストを印刷したいのですが、現時点では、マニュアルそして、コードスニペットからhttp://www.latex-community.org/forum/viewtopic.php?f=51&t=7892、原理的には機能します。

multicolsただし、リストはグループに関係なく、ページの最初の列全体にわたって表示され、2 番目の列に続きます。各グループが独自の環境にあることが望ましいです。

私が持っているもの:

私が望むこと:

パッケージでこれを実現する方法はありますかnomencl?


\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}

答え1

これが最善の解決策かどうかはわかりませんが、それでも...

% 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}

ここに画像の説明を入力してください

答え2

cgnieder によるソリューションは、2 行以上にまたがる長いエントリの場合は時々機能しなくなるため、ほぼ完璧です。

エントリが 2 列に分割されています

追加すると\begin{minipage}[t]{\linewidth}Your nomenclature entry\end{minipage}壊れるのを防ぐことができます。

壊れたエントリはもうありません

新しいバージョンではエントリ間の間隔がかなり広いので、\raggedcolumnsオプションを追加する必要があります。手動で追加したくない場合はminipage、次のコードを使用しますが、この名前変更によりグループが必須になり、エントリを から に変更する必要があります\nomenclature[B]{$\alpha$}{1}(\nomenclature{B}{$\alpha$}{1}角括弧が中括弧になっていることに注意してください)。これを行うにはおそらくもっと良い方法がありますが、私のカスタム LaTeX コードの知識は最高ではありません。

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

2列目のエントリ間に大きな空白がない

\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}

関連情報