詞彙表 - 首次使用所選首字母縮寫時抑制縮寫

詞彙表 - 首次使用所選首字母縮寫時抑制縮寫

這是我的第一篇文章,如果我打破了任何慣例,我深表歉意!我決定用 LaTeX 寫我的博士論文,但在按照我的意願格式化首字母縮寫/術語表時遇到了一些麻煩。我正在使用該glossaries包,並希望將其用於兩個不同的用例,其中之一(標準用途)我運行良好。

該問題涉及在引用化學品等時嘗試使用術語表與製造商/公司打交道。按照慣例,當您首次列出某種化學物質時,應按照「Chemical X(Company Y, Sometown, USA)」的方式進行引用。如果您使用一家公司的多種產品,則後續引用該公司時只需提及公司名稱即可,無需位置。這些公司引用不應出現在首字母縮寫列表中。

借助本網站之前的答案,我透過定義一個未列印的新「假」術語表,成功地從首字母縮寫列表中隱藏了公司名稱。我嘗試使用\newignoredglossary,但這似乎也隱藏了文本中的縮寫詞,不知道為什麼,但我對假術語表解決方案感到滿意。

然而,首次使用這些公司首字母縮略詞\gls{}會產生「Company, Sometown, USA (Company)」。我希望在顯示時​​不要在末尾的括號中重複公司名稱。

我意識到我可以使用:

\glsdesc{company} 

其次是

\glsunset{company} \gls{company} 

為了達到我想要的效果 - 但這需要手動查找並標記每個公司名稱的第一次使用,然後加上\glsdesc{}-\glsunset{}並且考慮到在撰寫論文期間段落的順序可能會發生變化,我會更確切地說,這是自動處理的。

這是一個最小的工作範例:

\documentclass{article}

\usepackage[acronym]{glossaries}

\newglossary[flg]{fake}{fls}{flo}{Fake Entries}

\newacronym[type=fake]{bio}{Biohazard Inc}{Biohazard Inc, MA, USA}
\newacronym{pbs}{PBS}{Phosphate Buffered Saline}

\makeglossaries

\begin{document}

First use - \gls{bio}. Second use - \gls{bio}. Not displayed in glossary, but first use repeats company name in parentheses. 

\gls{pbs} should appear in the glossary. Second use \gls{pbs}.

\printglossary[type=\acronymtype]

\end{document}

有沒有一種簡單的方法可以實現這一點glossaries?我想知道是否glossaries-extra能夠更好地處理這個問題,但文檔對我來說並不是100% 清楚,而且我擔心嘗試轉換可能會破壞當前普遍有效的首字母縮略詞列表,而這已經是一個複雜的、多文件文檔,不一定能解決我的問題!

答案1

這是另一種方法:

\documentclass{article}

\usepackage[acronym]{glossaries}

\newignoredglossary{ignored}

% syntax: \newcompany[extra options]{label}{name}{location}
\newcommand*{\newcompany}[4][]{%
 \newglossaryentry{#2}{type=ignored,%
  name={#3},%
  first={#3 (#4)},%
  description={#4},%
  #1}%
}

\glssetnoexpandfield{first}

% syntax: \newchemical[extra options]{company}{label}{short}{long}
\newcommand{\newchemical}[5][]{%
 \newglossaryentry{#3}{type=\acronymtype,%
  name={#4},%
  first={#5 (\ifglsused{#2}{\glsentryname{#2}}{\glsentryname{#2},
    \glsentrydesc{#2}\protect\glsunset{#2}})},%
  description={#5},%
  #1}%
}

\makeglossaries

\newcompany{bio}{Biohazard Inc}{MA, USA}
\newchemical{bio}{pbs}{PBS}{Phosphate Buffered Saline}

\begin{document}

First use - \gls{bio}. Second use - \gls{bio}.

\gls{pbs} should appear in the glossary. Second use \gls{pbs}.

Reset\glsresetall[ignored,\acronymtype] and try the other way.

\gls{pbs} should appear in the glossary. Second use \gls{pbs}.

First use - \gls{bio}. Second use - \gls{bio}.

\printglossary[type=\acronymtype]

\end{document}

這會產生:

文件影像

答案2

定義每個公司首字母縮寫時使用該first=選項會產生我想要的結果:

\newacronym[type=fake, first=\glsdesc{bio}]{bio}{Biohazard Inc}{Biohazard Inc, MA, USA}

詞彙表包非常棒,但功能如此豐富,對於像我這樣的初學者來說可能很難理解所有選項。

相關內容