
我正在使用glossaries
pdfLaTeX 中的包。我在嘗試著
在正文中使用小寫字母縮寫詞
和
對於索引,將術語表中每個條目名稱的首字母大寫。
我已經嘗試環顧四周,但找不到解決方案。
makeindex
為了獲取術語表,我運行定義如下的命令:
"/usr/texbin/makeglossaries" %
通常,我從 2 個外部檔案載入條目,但我不認為這是問題,因為在執行 MWE 後我也遇到了同樣的問題。不管怎樣,為了顯示我正在使用的命令,我將它們作為註釋插入 MWE 中。
另外,我不確定這是否重要,但我使用 MinionPro 作為我的主要字體和 KOMA-Script。
我的 MWE 是基於這個線程: http://www.latex-community.org/forum/viewtopic.php?f=5&t=9966
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}
% \input{./text/glossary}
% \loadglsentries{./text/symbols}
\makeglossaries
\newacronym{pcm} {PCM} {phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
name = {\null$\Delta H_{fus}$},
description={latent heat of fusion}}
\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.
\textsc{This is small caps. PCM pcm }
\renewcommand{\glsnamefont}[1]{\makefirstuc{#1}}
\printglossary[type=slg, style=long, nonumberlist=true]
\renewcommand{\glsnamefont}[1]{\MakeUppercase{#1}}
\printglossary[type=acronym, style=long]
\end{document}
結果如下:
唯一被大寫的是來自數學環境的 Fus,我真的不明白這是如何發生的。其他所有內容(小型大寫字母選項和大寫描述)都不起作用。
有人可以解釋一下我做錯了什麼嗎?
答案1
正如評論中提到的,您的首字母縮寫不會以小寫字母出現,因為您已經使用大寫字母定義了它們。你說的描述的大寫沒有起作用。這是因為您尚未對描述進行任何更改。\glsnamefont
適用於名稱而不是描述。您需要定義一種新樣式,使描述以大寫字母開頭:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}
\makeglossaries
\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
name = {\null$\Delta H_{fus}$},
description={latent heat of fusion}}
\newglossarystyle{long-ucdesc}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
}%
}
\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.
\textsc{This is small caps. PCM pcm }
\printglossary[type=slg, style=long-ucdesc, nonumberlist=true]
\renewcommand{\glsnamefont}[1]{\MakeUppercase{#1}}
\printglossary[type=acronym, style=long]
\end{document}
這會產生:
下面定義了一種使描述的首字母大寫的樣式:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}
\makeglossaries
\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
name = {\null$\Delta H_{fus}$},
description={latent heat of fusion}}
\newglossarystyle{long-ucdesc}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
}%
}
\makeatletter
\newglossarystyle{long-initcapsdesc}{%
\setglossarystyle{long}%
\renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\protected@edef\thisdesc{\glsentrydesc{##1}}%
\xcapitalisewords{\thisdesc}\glspostdescription\space ##2\tabularnewline
}%
}
\makeatother
\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.
\textsc{This is small caps. PCM pcm }
\printglossary[type=slg, style=long-ucdesc, nonumberlist=true]
\printglossary[type=acronym, style=long-initcapsdesc]
\end{document}
結果:
如果您至少有 4.22 版本glossaries
,則可以使用\glsentrytitlecase
:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[toc=true,smallcaps,section,nonumberlist,acronym,nomain]{glossaries}
\newglossary{slg}{sym}{syb}{Nomenclature}
\makeglossaries
\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
name = {\null$\Delta H_{fus}$},
description={latent heat of fusion}}
\newglossarystyle{long-ucdesc}{%
\setglossarystyle{long}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\Glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
}%
}
\newglossarystyle{long-initcapsdesc}{%
\setglossarystyle{long}%
\renewcommand{\glsnamefont}[1]{\MakeUppercase{##1}}%
\renewcommand{\glossentry}[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
\glsentrytitlecase{##1}{desc}\glspostdescription\space ##2\tabularnewline
}%
}
\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.
\textsc{This is small caps. PCM pcm }
\printglossary[type=slg, style=long-ucdesc, nonumberlist=true]
\printglossary[type=acronym, style=long-initcapsdesc]
\end{document}
和glossaries-extra
您可以使用該glossdesc
屬性:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[section,nonumberlist,acronym,nomain]{glossaries-extra}
\newglossary{slg}{sym}{syb}{Nomenclature}
\makeglossaries
\setabbreviationstyle[acronym]{long-short-sc}
\newacronym{pcm}{pcm}{phase change material}
\newglossaryentry{sym:hfus}{type=slg,sort={pl:h},
name = {\null$\Delta H_{fus}$},
description={latent heat of fusion}}
\glssetcategoryattribute{acronym}{glossdesc}{title}
\glssetcategoryattribute{general}{glossdesc}{firstuc}
\begin{document}
Sample: \gls{sym:hfus}. \gls{sym:hfus}. \gls{pcm}. \gls{pcm}.
\textsc{This is small caps. PCM pcm }
\printglossary[type=slg, style=long, nonumberlist=true]
\printglossary[type=acronym, style=long]
\end{document}