词汇表中的幻影空间

词汇表中的幻影空间

我正在尝试使用额外的词汇表来设置新的缩写样式,但是有一个我无法弄清楚的幻影空间。

尝试使长名称在德语缩写中自动以斜体显示,但在英语缩写中则不自动以斜体显示。

当我打印词汇表时,会在简称前添加一个额外的空格,从而导致德语缩写偏移。参见 mwe。

梅威瑟:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[toc=true, section=chapter, nonumberlist]{glossaries-extra}

\makeglossaries

\newabbreviationstyle{long-short-user-em}{
    %\GlsXtrUseAbbrStyleSetup{long-short-user}
    \renewcommand*{\CustomAbbreviationFields}{%
        name={\protect\glsabbrvfont{\the\glsshorttok}},
        sort={\the\glsshorttok},
        first={\protect\glsfirstlongemfont{\the\glslongtok}%
            \protect\glsxtruserparen{\protect\glsfirstabbrvuserfont{\the\glsshorttok}}%
            {\the\glslabeltok}},%
        firstplural={\protect\glsfirstlongemfont{\the\glslongpltok}%    
            \protect\glsxtruserparen
            {\protect\glsfirstabbrvuserfont{\the\glsshortpltok}}{\the\glslabeltok}},%
        plural={\protect\glsabbrvfont{\the\glsshortpltok}},%
        description={\protect\glslongfont{\the\glslongtok}}
    }%
}{
    \GlsXtrUseAbbrStyleFmts{long-short-user}%
    \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
    \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}

\setabbreviationstyle{long-short-user}
\setabbreviationstyle[german]{long-short-user-em}
\setabbreviationstyle[english]{long-short-user}

\newabbreviation{DTA}{DTA}{Some acronym long}
\newabbreviation{DTB}{DTB}{some other acronym long}
\newabbreviation{DTF}{DTF}{blah foo blah}
\newabbreviation[category=german]{aaa}{AAA}{Some Italicised german word}
\newabbreviation[category=german]{bbb}{BBB}{Some other Italicised german word}
\newabbreviation[category=german]{ccc}{CCC}{Foo Foo Foo}
\glsaddall

\begin{document}

\printglossary[title=List of Abbreviations]

\end{document}

在此处输入图片描述

分享Latex链接:https://www.sharelatex.com/read/zdfmqjnmkrkv

作为一个快速修复,我在 \newabbreviation 调用中手动设置强调,例如 {ccc}{CCC}{\textit{Foo Foo Foo}} 但寻找更优雅的解决方案

答案1

%这是线路上缺失的部分}{;我做了一些其他的重新格式化,以便更好地显示各个级别。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[toc=true, section=chapter, nonumberlist]{glossaries-extra}

\makeglossaries

\newabbreviationstyle{long-short-user-em}{% <-- not really necessary
  %\GlsXtrUseAbbrStyleSetup{long-short-user}
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={%
      \protect\glsfirstlongemfont{\the\glslongtok}%
      \protect\glsxtruserparen{\protect\glsfirstabbrvuserfont{\the\glsshorttok}}%
      {\the\glslabeltok}%
    },
    firstplural={%
      \protect\glsfirstlongemfont{\the\glslongpltok}%    
      \protect\glsxtruserparen{%
        \protect\glsfirstabbrvuserfont{\the\glsshortpltok}%
      }{\the\glslabeltok}
    },
    plural={\protect\glsabbrvfont{\the\glsshortpltok}},
    description={\protect\glslongfont{\the\glslongtok}},
  }%
}{% <-- this was the missing one
  \GlsXtrUseAbbrStyleFmts{long-short-user}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}

\setabbreviationstyle{long-short-user}
\setabbreviationstyle[german]{long-short-user-em}
\setabbreviationstyle[english]{long-short-user}

\newabbreviation{DTA}{DTA}{Some acronym long}
\newabbreviation{DTB}{DTB}{some other acronym long}
\newabbreviation{DTF}{DTF}{blah foo blah}
\newabbreviation[category=german]{aaa}{AAA}{Some Italicised german word}
\newabbreviation[category=german]{bbb}{BBB}{Some other Italicised german word}
\newabbreviation[category=german]{ccc}{CCC}{Foo Foo Foo}
\glsaddall

\begin{document}

\printglossary[title=List of Abbreviations]

\end{document}

相关内容