在词汇表中使用 \lstinline - 排序问题

在词汇表中使用 \lstinline - 排序问题

我似乎在使用词汇表时遇到了排序问题...我不太清楚问题到底是什么,但我无法摆脱它

\documentclass{scrreprt}

\usepackage[utf8]{inputenc} \usepackage[ngerman]{babel}

\usepackage{listings}

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

\makenoidxglossaries 
\newglossary*{glsentry}{Glossary}
     \newglossaryentry{hi}{         
             type=glsentry, 
             name={\lstinline|high impedance|}, 
             description={describes a logical signal state which is not to be recognized as \lstinline|high| or \lstinline|low|}}
     \newglossaryentry{an}{         
             type=glsentry, 
             name={another}, 
             description={another entry}}

\begin{document}    
\printnoidxglossary[type = glsentry]        
\section{test}  
\gls{hi} \\     
\gls{an}     
\end{document}

我可以尝试诸如等等之类的操作sort=defsort=word但是条目中的“名称”并没有出现在词汇表中的正确位置...如果我使用sort=usesort=last它是显示的最后一个条目,但名称根本没有出现......

我可能做错了什么,当然也没什么,但我没有其他想法了。提前致谢。

编辑:我注意到,我的最小示例在词汇表中使用粗体itemlabels,但我的实际项目却没有...这就是为什么我添加了一个额外的示例,其中包含所有相关选项(据我所知)...但这确实包含词汇表中的粗体“高阻抗”,而我的项目却没有。

\documentclass{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{listings}
\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%
}

\usepackage[acronym, symbols, nomain, toc, sanitizesort, style=index]{glossaries}
\usepackage{booktabs}   % essential for customized symbol glossary
\usepackage{tabu}   % essential for customized symbol glossary
\glsnoexpandfields
    % create customized symbols
    \newglossarystyle{symblongtabu}{
        \renewenvironment{theglossary}{
            \begin{longtabu}spread 0pt[l]{lll<{\strut}l}
            }{
        \end{longtabu}}
        \renewcommand*{\glsgroupheading}[1]{}
        \renewcommand*{\glsgroupskip}{}
        \renewcommand*{\glossaryheader}{
            \toprule
            \bfseries Formelzeichen & \bfseries Beschreibung &
            \bfseries Einheit & \bfseries Seite(n)
            \tabularnewline\midrule\endhead
            \bottomrule\endfoot}
        \renewcommand*{\glossentry}[2]{
            \glsentryitem{##1}
            % Entry number if required
            \glstarget{##1}{\glossentrysymbol{##1}} &
            \glossentrydesc{##1} &
            \glsentryuseri{##1} &
            ##2\tabularnewline}}


\makenoidxglossaries

    % symbol entries without description
\newcommand*{\nsymbol}[4]{\newglossaryentry{#1}{
        type=symbols,
        name={#2},
        description={\nopostdesc},
        symbol={\ensuremath{#3}}, 
        %               user1={#4}, 
        user1={$\si{#4}$}, 
        sort={#1}}}
\newcommand*{\nsymbold}[5]{\newglossaryentry{#1}{
        type=symbols,
        name={#2},
        description={#5},
        symbol={\ensuremath{#3}}, 
        %               user1={#4}, 
        user1={$\si{#4}$}, 
        sort={#1}}}
\defglsentryfmt[symbols]{\ifmmode
    \glssymbol{\glslabel}
    \else
    \glsgenentryfmt~\glsentrysymbol{\glslabel}
    \fi}

    \nsymbold{i}{current}{i_1}{\ampere}{current of line 1}

    \newacronym{ac}{AC}{Accounting Current}

\newglossary*{glsentry}{Glossary}
    \newglossaryentry{hi}{
        type=glsentry, name={\lstinline|high impedance|}, description={describes an signal state which is not to be recognized as \lstinline|high| or \lstinline|low|}}
    \newglossaryentry{hi2}{
        type=glsentry, name={high impedance}, description=describes an signal state which is not to be recognized as high or low}
    \newglossaryentry{an}{
        type=glsentry, name={another}, description={another entry}}


\begin{document}


\printnoidxglossary[type = acronym, title = {glos1}]
\printnoidxglossary[type = glsentry, style=index]

\printnoidxglossary[type = symbols, style = symblongtabu, title = {glos2}]

    \newpage

    \section{test}
    \gls{hi}\\
    \gls{i}\\
    \gls{ac}


\end{document}

也许有人浪费了一些时间并能够假设我使用错了...

答案1

首先你需要了解它\printnoidxglossary试图做什么。默认情况下style=list,它使用description环境并将 放在name的可选参数中\item。所以测试一下:

\documentclass{scrreprt}

\usepackage{listings}

\newcommand{\test}{\lstinline|high impedance|}

\begin{document}
\begin{description}
\item[\test] test.
\end{description}
\end{document}

这产生了

测试。

商品标签丢失,这意味着如果您使用这种风格,也会发生同样的事情。(我怀疑这可能与的逐字逐句的品质glossaries有关。)\lstinline

index风格是一种合理的近似,因此使用style=index

\documentclass{scrreprt}

\usepackage[utf8]{inputenc} \usepackage[ngerman]{babel}

\usepackage{listings}

\usepackage[acronym, symbols, nomain, toc, sanitizesort,style=index]{glossaries}

\makenoidxglossaries 
\newglossary*{glsentry}{Glossary}
     \newglossaryentry{hi}{         
             type=glsentry, 
             name={\lstinline|high impedance|}, 
             description={describes a logical signal state which is not to be recognized as \lstinline|high| or \lstinline|low|}}
     \newglossaryentry{an}{         
             type=glsentry, 
             name={another}, 
             description={another entry}}

\begin{document}    
\printnoidxglossary[type = glsentry]        
\section{test}  
\gls{hi} \\     
\gls{an}     
\end{document}

得出的结果为:

文件图像

“high resistance” 位于 “another” 之前,因为排序值为\lstinline|high impedance|another。第一个值以 开头\,第二个值以 开头a。您正在使用\makenoidxglossaries执行 ASCII 排序,并且 的字符代码\小于 的字符代码a。如果要更改此顺序,则需要指定sort值:

\newglossaryentry{hi}{
     type=glsentry,
     name={\lstinline|high impedance|},
     sort={high impedance},
     description={describes a logical signal state which is not to be   
     recognized as \lstinline|high| or \lstinline|low|}}

相关内容