我正在创建命名法,想减少行距。如果我使用在线找到的方法插入命令\setlength{\nomitemstep}{-parsep}
,则所有行跳动都将被删除,包括命名法子节标题之前和之后的行跳动。有没有办法只减少个别项目的行距,而不减少标题的行距?
附件是示例代码和输出快照:
\documentclass[authoryear, preprint]{elsarticle}
\usepackage{nomencl}
\makenomenclature
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{A}}{\item[\textbf{Greek Symbols}]}{%
\ifthenelse{\equal{#1}{B}}{\item[\textbf{Other Variables}]}{}}}
\setlength{\nomitemsep}{-\parsep}
\RequirePackage{ifthen}
\begin{document}
This is my text document.
\nomenclature[a]{$\sigma$}{Variable explanation}
\nomenclature[a]{$\alpha$}{Variable explanation}
\nomenclature[a]{$\beta$}{Variable explanation}
\nomenclature[b]{$A$}{Variable explanation}
\nomenclature[b]{$B$}{Variable explanation}
\nomenclature[b]{$C$}{Variable explanation}
\nomenclature[b]{$D$}{Variable explanation}
\printnomenclature[0.9in]
\end{document}
非常感谢您的任何提示!
答案1
这是一个小的绕过解决方案:\noitemsep
在 a 中临时恢复该值\nomgroup
,然后使用较新的值。
\documentclass[authoryear, preprint]{elsarticle}
\usepackage{ifthen}
\usepackage{nomencl}
\usepackage{xpatch}
\newlength{\nomitemorigsep}
\setlength{\nomitemorigsep}{\nomitemsep}
\setlength{\nomitemsep}{-\parsep}
\makenomenclature
\renewcommand{\nomgroup}[1]{%
\itemsep\nomitemorigsep%
\ifthenelse{%
\equal{#1}{A}%
}{%
\item[\textbf{Greek Symbols}]%
}{%
\ifthenelse{\equal{#1}{B}}{%
\item[\textbf{Other Variables}]%
}{}%
}%
\itemsep\nomitemsep% Restore spacing
}
\begin{document}
This is my text document.
\nomenclature[a]{$\sigma$}{Variable explanation}
\nomenclature[a]{$\alpha$}{Variable explanation}
\nomenclature[a]{$\beta$}{Variable explanation}
\nomenclature[b]{$A$}{Variable explanation}
\nomenclature[b]{$B$}{Variable explanation}
\nomenclature[b]{$C$}{Variable explanation}
\nomenclature[b]{$D$}{Variable explanation}
\printnomenclature[0.9in]
\end{document}
答案2
如果你不需要设置精确的间距,而只想设置单倍间距,则可以\printnomenclature
在单倍间距环境中换行:
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}
\makenomenclature
\usepackage[doublespacing]{setspace}
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
\item[\bfseries
\ifstrequal{#1}{a}{Symbols}{%
\ifstrequal{#1}{b}{Acronyms}{}}%
]}
\begin{document}
\nomenclature[a]{$x$}{Symbol explanation}
\nomenclature[a]{$y$}{Symbol explanation}
\nomenclature[a]{$z$}{Symbol explanation}
\nomenclature[b]{A}{Acronym explanation}
\nomenclature[b]{B}{Acronym explanation}
\nomenclature[b]{C}{Acronym explanation}
\renewcommand{\nomname}{Nomenclature}
\begin{singlespace}
\printnomenclature
\end{singlespace}
\end{document}
在这种情况下,文档将是双倍行距(因为doublespacing
传递给setspace
包的参数,并且命名法将是单倍行距。
要编译此示例,请确保运行makeindex <filename>.nlo -s nomencl.ist -o <filename>.nls
要打印的命名法,其中是文件的名称.tex
。