我正在尝试使用该nomencl
包(CTAN链接) 并希望以表格形式格式化命名法条目,如文档中所述(选项nomentbl
)。
这很好,除非我还尝试按照文档中所述自定义子组(通过\renewcommand{\nomgroup}...
)。附加的 MWE 在输出中返回以下错误
./mwe.nls:7: Missing number, treated as zero.
并且 PDF 中的标题都乱了(见下文)。
有人能解释一下吗?我遗漏了什么明显的内容吗?任何建议都将不胜感激!
\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage[per-mode=fraction]{siunitx}
\usepackage[nomentbl]{nomencl}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{S}}{\item[\textbf{Sets}]}{%
\ifthenelse{\equal{#1}{C}}{\item[\textbf{Constants}]}{%
\ifthenelse{\equal{#1}{V}}{\item[\textbf{Variables}]}{}}}}
\makenomenclature
\begin{document}
\printnomenclature
\clearpage
The objective function minimizes total energy cost in the period under consideration.
\begin{equation}
\label{eq:obj}
\min_x \sum_m\sum_t C_t \cdot q_m^{p,s} \cdot r_m^{p,s} \cdot x_{m,t}^{p,s}
\end{equation}
\nomenclature[c C]{$C_t$}{Electricity price in period $t$}{}{}
\nomenclature[c q]{$q_m^{p,s}$}{Output-specific power uptake of machine $m$ when producing paper $p$ in production mode $s$}{}{}
\nomenclature[c r]{$r_m^{p,s}$}{Production rate of machine $m$ for paper $p$ when run in mode $s$}{}{}
\nomenclature[s t]{$\mathcal{T}$}{Set of points in time}{}{}
\nomenclature[s p]{$\mathcal{P}$}{Set of paper types}{}{}
\nomenclature[s m]{$\mathcal{M}$}{Set of machines}{}{}
\nomenclature[v x]{$x_{m,t}^{p,s}$}{Binary variable that equals 1 if machine $m$ produces paper $p$ in production mode $s$ in period $t$, otherwise 0}{}{}
\end{document}
答案1
\nomgroup
选项并没有得到很好的支持nomentbl
。当然不能使用\ifthenelse
它来支持它,因为我们需要发出\multicolumn
命令。
一种解决方法是使用\pdf@strcmp
可扩展的字符串比较。
\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage[per-mode=fraction]{siunitx}
\usepackage[nomentbl]{nomencl}
\usepackage{pdftexcmds}
\makenomenclature
\makeatletter
\renewcommand{\nomgroup}[1]{%
\ifnum\pdf@strcmp{#1}{C}=\z@
\multicolumn{6}{l}{\textbf{Constants}}\\%
\else
\ifnum\pdf@strcmp{#1}{S}=\z@
\\\\\multicolumn{6}{l}{\textbf{Sets}}%
\else
\ifnum\pdf@strcmp{#1}{V}=\z@
\\\\\multicolumn{6}{l}{\textbf{Variables}}%
\fi
\fi
\fi
}
\makeatother
\begin{document}
\printnomenclature
\clearpage
The objective function minimizes total energy cost in the period under consideration.
\begin{equation}
\label{eq:obj}
\min_x \sum_m\sum_t C_t \cdot q_m^{p,s} \cdot r_m^{p,s} \cdot x_{m,t}^{p,s}
\end{equation}
\nomenclature[c C]{$C_t$}{Electricity price in period $t$}{}{}
\nomenclature[c q]{$q_m^{p,s}$}{Output-specific power uptake of machine $m$ when producing paper $p$ in production mode $s$}{}{}
\nomenclature[c r]{$r_m^{p,s}$}{Production rate of machine $m$ for paper $p$ when run in mode $s$}{}{}
\nomenclature[s t]{$\mathcal{T}$}{Set of points in time}{}{}
\nomenclature[s p]{$\mathcal{P}$}{Set of paper types}{}{}
\nomenclature[s m]{$\mathcal{M}$}{Set of machines}{}{}
\nomenclature[v x]{$x_{m,t}^{p,s}$}{Binary variable that equals 1 if machine $m$ produces paper $p$ in production mode $s$ in period $t$, otherwise 0}{}{}
\end{document}
顶级群体必须受到不同的对待。