首页 > 解决方案 > 如何在词汇表 newcommand 中定义嵌套调用

问题描述

使用词汇表包,我实现了一个组合词汇表和首字母缩写词列表,如此所述。这工作正常:

\newcommand{\agls}[4]{
    \newglossaryentry{#1}{
        text={#2},
        long={#3},
        name={\glsentrylong{#1} (\glsentrytext{#1})},
        first={\glsentryname{#1}},
        firstplural={\glsentrylong{#1}\glspluralsuffix (\glsentryname{#1}\glspluralsuffix )},
        description={#4}
    }
}

\agls{a:bim}{BIM}{Building Information Modeling}{3D Something}

我很快注意到我的大部分词汇表描述都以See \cref{sec:myLabel}. 这就是为什么我试图像这样修改它:

\newcommand{\agls}[5][]{
    \newglossaryentry{#2}{
        text={#3},
        long={#4},
        name={\glsentrylong{#2} (\glsentrytext{#2})},
        first={\glsentryname{#2}},
        firstplural={\glsentrylong{#2}\glspluralsuffix (\glsentryname{#2}\glspluralsuffix )},
        description={#5. See \cref{#1}}
    }
}

\agls[subsec:bim]{a:bim}{BIM}{Building Information Modeling}{3D Something}

(如果省略了可选参数,请不要介意损坏的引用,我稍后会用 修复这个问题\ifthenelse

但是,这会导致错误:

Argument of \@cref@stack@top has an extra }. \glsXpageXglsnumberformat{}{17}}}
Paragraph ended before \@cref@stack@top was complete. \glsXpageXglsnumberformat{}{17}}}

我似乎乳胶被几个右大括号弄糊涂了。我已经尝试将调用移动到单独的命令,但它没有改变任何东西:

\newcommand{\lref}[1][]{See \cref{#1}}
... description={#5. \lref[#1]} ...

我怎样才能解决这个问题?

更新:我刚刚注意到我也可以使用

\newcommand{\see}[1]{Siehe \cref{#1}}
\agls{a:bim}{BIM}{Building Information Modeling}{3D Something \see{subsec:bim}}

......这可能是我暂时要做的。如果有一个简单的修复程序,仍然会受到赞赏。

标签: latexglossaries

解决方案


推荐阅读