文本中自定义词汇表条目后的间距

文本中自定义词汇表条目后的间距

我有一个关于文本中任何 glos-entry 后面的空格以及如何消除它的问题。我问过类似的问题这里。这就是我使用的原因\glsnoexpandfields。我只是不明白后面的额外空格\gls{abc}是从哪里来的。希望有人能帮忙。我\newcommand操作说明关于如何写我的大学论文第18页,没有间距。

\documentclass{scrreprt}

\usepackage[utf8]{inputenc} \usepackage[ngerman]{babel} 
\usepackage[locale=DE]{siunitx}
            \sisetup{detect-mode = false,
            detect-family=true,
            mode=math,
            %               output-decimal-marker={,},
            binary-units=true,
            group-separator={\,},group-minimum-digits=3% }

                % upright indices-shortcut 
\mathcode`\.="8000 
\begingroup\lccode`~=`. 
\lowercase{\endgroup\def~}#1{\mathrm{#1}}

\usepackage{hyperref}

\usepackage[acronym, symbols, nomain, toc]{glossaries} 
\usepackage{booktabs} \usepackage{tabu}

        %%% new glossary style 
    \newglossarystyle{symblongtabu}{
            \renewenvironment{theglossary}{
                \begin{longtabu}spread 0pt[l]{ccc<{\strut}l}
                }{
            \end{longtabu}}
            \renewcommand*{\glsgroupheading}[1]{}
            \renewcommand*{\glsgroupskip}{}
            \renewcommand*{\glossaryheader}{
                \toprule
                \bfseries Formelzeichen & \bfseries Bezeichnung &
                \bfseries Einheit & \bfseries Seite(n)
                \tabularnewline\midrule\endhead
                \bottomrule\endfoot}
            \renewcommand*{\glossentry}[2]{
                \glsentryitem{##1}
                % Entry number if required
                \glstarget{##1}{\glossentrysymbol{##1}} &
                \glossentryname{##1} &
                \glsentryuseri{##1} &
                ##2\tabularnewline}}

        \makenoidxglossaries

        %%% newsymb macro
     \newcommand*{\nsymbol}[4]{\newglossaryentry{#1}{
                type=symbols,
                name={#2},
                description={\nopostdesc},
                symbol={{#3}}, 
                user1={#4}, 
                sort={#1}}} 
    \defglsentryfmt[symbols]{\ifmmode
            \glssymbol{\glslabel}
            \else
            \glsgenentryfmt~\glsentrysymbol{\glslabel}
            \fi} 

           %%% entries 
\nsymbol{abc}{alphabet}{$A_.{bc}$}{$\si{cm}$} 
\nsymbol{abc1}{alphabet1}{$A_.{bc1}$}{$\si{\protect\metre}$}

        \begin{document}

            \printnoidxglossary[type = symbols, style = symblongtabu]

            \gls{abc} \\
            \gls{abc1}

        \end{document}

答案1

TeX 将换行符视为空格,因此您的代码中会有很多由换行符引入的虚假空格。您需要使用 将它们注释掉%

在样式定义中:

    \newglossarystyle{symblongtabu}{% <- comment eol
        \renewenvironment{theglossary}{% <- comment eol
            \begin{longtabu}spread 0pt[l]{ccc<{\strut}l}
            }{% <- comment eol
        \end{longtabu}}% <- comment eol
        \renewcommand*{\glsgroupheading}[1]{}% <- comment eol
        \renewcommand*{\glsgroupskip}{}% <- comment eol
        \renewcommand*{\glossaryheader}{% <- comment eol
            \toprule
            \bfseries Formelzeichen & \bfseries Bezeichnung &
            \bfseries Einheit & \bfseries Seite(n)
            \tabularnewline\midrule\endhead
            \bottomrule\endfoot}% <- comment eol
        \renewcommand*{\glossentry}[2]{% <- comment eol
            \glsentryitem{##1}% <- comment eol
            % Entry number if required
            \glstarget{##1}{\glossentrysymbol{##1}} &
            \glossentryname{##1} &
            \glsentryuseri{##1} &
            ##2\tabularnewline}}

格式定义如下:

\defglsentryfmt[symbols]{\ifmmode
        \glssymbol{\glslabel}% <- comment eol
        \else
        \glsgenentryfmt~\glsentrysymbol{\glslabel}% <- comment eol
        \fi}

相关内容