无需触发首次使用即可访问特定词汇表字段

无需触发首次使用即可访问特定词汇表字段

我想知道在创建词汇表条目期间手动配置的任何字段是否可以通过宏或新命令手动/有意访问 - 可能的形式为:

\newcommand{\expectedFirst}[1]{???}

其中 ??? 是一个使用 gls 标签 #1 来抓取预定义字段(如短名称、标签、长名称、描述、首复数等)的定义。我将为想要提取的每个字段创建一个新命令,或者可能使用

\newcommand{\expectedField}[2]{???}

其中 #1 是标签字符串,#2 代表我想要提取或使其可访问的字段。

我仔细查看了 .dtx 词汇表文件,但没有找到任何看起来像是可以在外部复制的变量创建的宏定义。看起来有趣且可能有用的是存在一个跟踪布尔值来跟踪该术语是否已被调用。这个布尔值将是另一个我想在我的自定义宏中进行比较的变量。

梅威瑟:

\documentclass{article}
\usepackage[utf8]{inputenc}

\setlength\parindent{0pt}


%=========================================================================================================================================
% PACKAGES REQUIRED FOR GLOSSARIES
%=========================================================================================================================================

% Glossaries must be loaded before amsmath as per details in the following forum answer
% http://tex.stackexchange.com/questions/85696/what-causes-this-strange-interaction-between--and-amsmath
\usepackage[nogroupskip,toc,acronym]{glossaries} % must come after href   
\usepackage{scrwfile}%http://www.dickimaw-books.com/cgi-bin/faq.cgi?action=view&categorylabel=glossaries#glsnewwriteexceeded

\makeglossaries

\newglossaryentry{ICPMS}{ type={acronym}, sort={inductively coupled plasma mass spectrometry},  name={ICPMS}, short={ICPMS}, long={inductively coupled plasma mass spectrometry}, first={inductively coupled plasma mass spectrometry (ICPMS)}, description={inductively coupled plasma mass spectrometry} }

\begin{document}

    \begin{itemize}
        \item \gls{ICPMS}
        \item \gls{ICPMS}
            %\item \expectedFirst{ICPMS}
    \end{itemize}


\end{document} 

答案1

通过更仔细地检查文档并从原始问题的评论中获得灵感,我发现该glossaries包使用格式类似于\glsentryshort{}和的命令可以访问某些字段\glsentrylong{}。最重要的是,使用这些命令不会人为地触发会阻止适当的首次使用评估的计数器。

梅威瑟:

\documentclass{article}
\usepackage[utf8]{inputenc}

\setlength\parindent{0pt}

%=========================================================================================================================================
% PACKAGES REQUIRED FOR GLOSSARIES
%=========================================================================================================================================

% Glossaries must be loaded before amsmath as per details in the following forum answer
% http://tex.stackexchange.com/questions/85696/what-causes-this-strange-interaction-between--and-amsmath
\usepackage[nogroupskip,toc,acronym]{glossaries} % must come after href   
\usepackage{scrwfile}%http://www.dickimaw-books.com/cgi-bin/faq.cgi?action=view&categorylabel=glossaries#glsnewwriteexceeded

\makeglossaries

\newglossaryentry{ICPMS}{ type={acronym}, sort={inductively coupled plasma mass spectrometry},  name={ICPMS}, short={ICPMS}, long={inductively coupled plasma mass spectrometry}, first={inductively coupled plasma mass spectrometry (ICPMS)}, description={inductively coupled plasma mass spectrometry} }

\begin{document}

    \begin{itemize}
        \item \glsentrylong{ICPMS}
        \item \glsentryshort{ICPMS}
        \item \glsentryfull{ICPMS}
        \item \gls{ICPMS}
        \item \gls{ICPMS}
    \end{itemize}


\end{document} 

相关内容