我创建了一种命名风格,在我的主文档中,它完美地工作,并且在我的空间限制内。但是,当没有字段时,即命名没有单位glossaries
时,我就会遇到问题。\newglossaryentry{...}
symbol
查看此 MWE 图像:
我尝试使用这个答案删除etoolbox
它\ifstrempty
格雷米尔像这样:
\newglossarystyle{nomenS}{%
\setglossarystyle{long}%
\renewenvironment{theglossary}%
{\begin{supertabular}[l]{@{}%
p{\dimexpr.1\columnwidth-2\tabcolsep}p{\dimexpr.8\columnwidth-2\tabcolsep}@{}}}%
{\end{supertabular}}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}}%
& \glossentrydesc{##1}\ifstrempty{\glossentrysymbol{##1}}{}{, \glossentrysymbol{##1}}%
\tabularnewline%
}%
}
但我不确定该symbol
字段是否是字符串,我也不太熟悉LaTeX 等。请问\ifx
我该如何更改nomenS
词汇表样式,以便在字段存在时仅包含逗号?symbol
梅威瑟:
\documentclass{article}
\usepackage{glossaries}
\newglossary{nomen}{nom}{ntn}{Nomenclature}
\newglossarystyle{nomenS}{%
\setglossarystyle{long}%
\renewenvironment{theglossary}%
{\begin{supertabular}[l]{@{}%
p{\dimexpr.1\columnwidth-2\tabcolsep}p{\dimexpr.8\columnwidth-2\tabcolsep}@{}}}%
{\end{supertabular}}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}}%
& \glossentrydesc{##1}, \glossentrysymbol{##1}%
\tabularnewline%
}%
}
\makeglossaries
\newglossaryentry{units}
{%
name={$\Delta\Phi_0$},
description={Superhelical phase offset},
symbol={°},
sort={abp},
type=nomen,
}
\newglossaryentry{nounits}
{%
name={$C_\alpha$},
description={No units},
sort={ca},
symbol={},
type=nomen,
}
\begin{document}
\glsaddall
\printglossary[type=nomen,style=nomenS]
\end{document}
答案1
词汇表提供了专门的测试:
\documentclass{article}
\usepackage{glossaries}
\newglossary{nomen}{nom}{ntn}{Nomenclature}
\newglossarystyle{nomenS}{%
\setglossarystyle{long}%
\renewenvironment{theglossary}%
{\begin{supertabular}[l]{@{}%
p{\dimexpr.1\columnwidth-2\tabcolsep}p{\dimexpr.8\columnwidth-2\tabcolsep}@{}}}%
{\end{supertabular}}%
\renewcommand{\glossentry}[2]{%
\glstarget{##1}{\glossentryname{##1}}%
& \glossentrydesc{##1}\ifglshassymbol{##1}{, \glossentrysymbol{##1}}{}%
\tabularnewline%
}%
}
\makeglossaries
\newglossaryentry{units}
{%
name={$\Delta\Phi_0$},
description={Superhelical phase offset},
symbol={°},
sort={abp},
type=nomen,
}
\newglossaryentry{nounits}
{%
name={$C_\alpha$},
description={No units},
sort={ca},
symbol={},
type=nomen,
}
\begin{document}
\glsaddall
\printglossary[type=nomen,style=nomenS]
\end{document}