我想打印一个由多个组组成的多列命名列表。目前,使用手动的以及来自的代码片段http://www.latex-community.org/forum/viewtopic.php?f=51&t=7892,从原理上讲它是可行的。
但是,无论组是什么,列表都会沿着页面的整个第一列运行,然后继续运行第二列。我希望每个组都有自己的multicols
环境:
我拥有的:
我想要的是:
有没有办法用这个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 行或更多行的长条目而中断。
添加\begin{minipage}[t]{\linewidth}Your nomenclature entry\end{minipage}
将防止它被破坏。
新版本中条目之间的间距很大,因此您应该添加该\raggedcolumns
选项。如果您不想手动添加,minipage
请使用以下代码,但此重命名将使组成为必需的,并且条目需要从更改为\nomenclature[B]{$\alpha$}{1}
(\nomenclature{B}{$\alpha$}{1}
请注意,方括号现在是花括号)。可能有更好的方法来做到这一点,但我的自定义乳胶代码知识并不是最好的。
\usepackage{letltxmacro}
\LetLtxMacro\oldnomenclature\nomenclature
\renewcommand{\nomenclature}[3]{\oldnomenclature[{#1}]{#2}{\begin{minipage}[t]{\linewidth}#3\end{minipage}}}
\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}