詞彙表中的單字大寫,文本中的小寫

詞彙表中的單字大寫,文本中的小寫

是否可以在詞彙表中以大寫形式書寫單詞,但在文本中以小寫形式書寫單詞?我可以使用\glslink代替\gls,但有沒有更好的解決方案?

這是一個例子來闡明我想要什麼:

\documentclass[a4paper]{article}

\usepackage{hyperref}
\usepackage{glossaries}

\makeglossaries
\newglossaryentry{lowercase}{name={lowercase}, description={In the glossary, this word should be capitalized}}
\newglossaryentry{uppercase}{name={Uppercase}, description={This word is capitalized}}

\begin{document}

Should both be lowercase: \gls{lowercase}, \gls{uppercase}.

Workaround: \gls{lowercase}, \glslink{uppercase}{uppercase}.

\printglossaries

\end{document}

這產生:

Should both be lowercase: lowercase, Uppercase.
Workaround: lowercase, uppercase. 

Glossary
lowercase In the glossary, this word should be capitalized. 1
Uppercase This word is capitalized. 1

答案1

有一個簡單的解決方案。您可以分別設定出現在術語表中的文字和出現在...文字中的文字。

\newglossaryentry{uppercase}{
    name={Uppercase},
    text={uppercase},
    description={Appears uppercase in the glossary and lowercase in the text}
}

答案2

對於未來遇到相同問題的用戶:

我自己遇到了這個問題並發現了這個問題及其複製。 @Nitram 的解決方案在第一個單字定義為巨集的情況下很有用。然而:

  • 我不想重複所有的姓名條目,
  • 我確實想控制什麼是大寫的,什麼不是(數學符號作為第一個字元的情況),
  • 如果沒有特別要求,我想保持平常的行為。

來自 @nicola-talbot 的回答那裡,我發現一個簡單的重新定義就可以解決問題:

\usepackage{mfirstuc}
\renewcommand{\glsnamefont}[2][]{\capitalisewords{#1}\xspace#2}

例子:

用法:在詞彙表中輸出“第一個單字大寫”,而 \gls{firstexample} 在文本中輸出“第一個單字大寫”:

\newglossaryentry{firstexample}{
  name={first}{word capitalized}
}

這不適用於巨集(將大寫整個單字),因此使用文字欄位:

\newglossaryentry{boite}{
  name={\Boite de valeurs},
  text={\boite de valeurs}
}

我先學數學,正常使用名稱:在術語表和文本中 \gls{firstexample} 輸出“$i$-th blabla”:

\newglossaryentry{iblabla}{
  name={$i$-th blabla}
}

答案3

我用過尼古拉的回答,因為這裡的答案都不適合我。

glossaries-extra軟體包允許輕鬆設定大小寫firstuc。我不必更改太多預覽程式碼,也不必更改呼叫。只需更改包並添加以下程式碼:

\setglossarystyle{long}
\setabbreviationstyle[acronym]{long-short}
\glssetcategoryattribute{acronym}{glossdesc}{firstuc}

答案4

文本中可以同時使用大寫和小寫;\Gls{}將給出大寫的單字或術語,如句子開頭所示。在其他地方,\gls{}也可以使用小寫形式。請參閱第 3 節初學者指南。我不確定這是否準確地解決了所提出的問題,但這是人們可能會發現這個問題的常見用法。

相關內容