如何获取大写字母的首字母缩略词条目并仅将词汇表中的条目首字母大写?

如何获取大写字母的首字母缩略词条目并仅将词汇表中的条目首字母大写?

我在这个论坛上找到了很多关于如何将条目呈现到词汇表中的信息(大写、小写、首字母大写);但我不明白如何为首字母缩略词列表和词汇表设置两种不同的样式,并以不同的方式呈现条目。这是我用来将首字母大写到词汇表中的代码;但这会影响首字母缩略词列表和词汇表。对于词汇表来说没问题,但我希望首字母缩略词条目以大写形式呈现整个单词……

这是完整的 MWE...

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

\usepackage[acronym,shortcuts,automake,nopostdot]{glossaries}

\usepackage{glossary-tree}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Capitalize the first letter of the entry %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\ignore}[1]{}

\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\capitalize}{>{\SplitList{~}}m}
 {
  \seq_clear:N \l_capitalize_words_seq
  \ProcessList{#1}{\CapitalizeFirst}
  \seq_use:Nn \l_capitalize_words_seq { ~ }
 }
\NewDocumentCommand{\CapitalizeFirst}{m}
 {
  \capitalize_word:n { #1 }
 }

\sys_if_engine_pdftex:TF
 {
  \cs_set_eq:Nc \capitalize_tl_set:Nn { protected@edef }
 }
 {
  \cs_set_eq:NN \capitalize_tl_set:Nn \tl_set:Nn
 }

\cs_new_protected:Nn \capitalize_word:n
 {
  \capitalize_tl_set:Nn \l_capitalize_word_tl { #1 }
  \seq_if_in:NfTF \g_capitalize_exceptions_seq { \tl_to_str:n { #1 } }
   % exception word
   { \seq_put_right:Nn \l_capitalize_words_seq { #1 } } % exception word
   % to be uppercased
   { \seq_put_right:Nx \l_capitalize_words_seq { \tl_mixed_case:V \l_capitalize_word_tl } }
 }
\cs_generate_variant:Nn \tl_mixed_case:n { V }
\NewDocumentCommand{\AppendToList}{m}
 {
  \clist_map_inline:nn { #1 }
   {
    \seq_gput_right:Nx \g_capitalize_exceptions_seq { \tl_to_str:n { ##1 } }
   }
 }
\cs_generate_variant:Nn \seq_if_in:NnTF { Nf }
\seq_new:N \l_capitalize_words_seq
\seq_new:N \g_capitalize_exceptions_seq
\ExplSyntaxOff

\renewcommand{\glsnamefont}[1]{\capitalize{#1}}

%%%%%%%%%%%%%%%%%%

\makeglossaries

\newglossaryentry{latex}
{
        name=latex,
        description={Is a mark up language specially suited for 
scientific documents}
}

\newglossaryentry{maths}
{
        name=mathematics,
        description={Mathematics is what mathematicians do}
}

\newglossaryentry{formula}
{
        name=formula,
        description={A mathematical expression}
}

\newacronym{gcd}{GCD}{Greatest Common Divisor}

\newacronym{lcm}{LCM}{Least Common Multiple}


\begin{document}

The \Gls{latex} typesetting markup language is specially suitable 
for documents that include \gls{maths}. \Glspl{formula} are 
rendered properly an easily once one gets used to the commands.

Given a set of numbers, there are elementary methods to compute 
its \acrlong{gcd}, which is abbreviated \acrshort{gcd}. This 
process is similar to that used for the \acrfull{lcm}.

\printglossary[type=\acronymtype]

\printglossary

\end{document}

答案1

最后,解决方案是当您调用首字母缩略词时:您必须像这样修改 glsnamefond 命令:\renewcommand{\glsnamefont}[1]{#1} \printglossary[type=\acronymtype] 它现在可以工作:首字母缩略词大写,只有首字母在词汇表中大写。

相关内容