用語集のファントムスペース

用語集のファントムスペース

glossaries-extra を使用して新しい略語スタイルを設定しようとしていますが、原因がわからないファントム スペースがあります。

ドイツ語の略語の場合は長い名前が自動的に斜体になるが、英語の場合は斜体にならないようにしようとしています。

printglossary を実行すると、短縮名の前に余分なスペースが追加され、ドイツ語の略語がオフセットされます。mwe を参照してください。

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}

ここに画像の説明を入力してください

sharelatex リンク: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}

関連情報