多個術語表混合條目:第二個術語表中有重複項

多個術語表混合條目:第二個術語表中有重複項

我正在編寫一份包含常數清單和符號清單的報告,兩者都是使用詞彙表包裹。問題是第二個列表(在本例中為常數)不僅包含它應該包含的元素,還包含第一個列表中的元素(符號): 常數列表現在包含常數和符號

無論順序為何,都會出現此問題(如果交換順序,符號清單也將包含常數)。我想我必須在列印它們之間調用某種術語表重置命令,但我無法在任何地方找到它。有誰知道是什麼原因導致這個問題?

我使用 Ubuntu 16.04 附帶的 TeXLive-full 發行版。詞彙表包版本根據\listfiles:glossaries.sty 2017/01/19 v4.29

我準備了一個MWE。請注意,我只包含 1 種術語表樣式,而實際上我會對常數和符號清單使用單獨的樣式。這只是為了保持 MWE 較小。單獨的樣式也會出現此問題。這是 main.tex 檔:

\documentclass[12pt,a4paper]{article}

\usepackage{glossaries}

%%%%%%% Load the preamble that contains the glossary styles
\input{./Helpers/glspreamble}

%%%%%%% Define entries for the list of acronyms, constants and symbols
\newglossaryentry{con:g}
{
    type=constants, % entry should be in the list of constants!
    name={\ensuremath{g}}, % Put the symbol here in dollar signs
    description={Local gravitational acceleration}, % A brief description of this entry (to appear in the glossary).
    user1={\ensuremath{9.81}},
    symbol={\ensuremath{\frac{m}{s^2}}}, % put the unit here
    sort=g, % for correct sorting type the full name of the symbol here
    parent=romanletter % for sorting purposes, use romanletter or greekletter
}

\newglossaryentry{sym:t}
{
    type=symbol, % entry should be in the list of symbols!
    name={\ensuremath{t}}, % Put the symbol here in dollar signs
    description={Time}, % A brief description of this entry (to appear in the glossary).
    user1={\ensuremath{-}},
    symbol={\ensuremath{s}}, % put the unit here
    sort=t, % for correct sorting type the full name of the symbol here
    parent=romanletter % for sorting purposes, use romanletter or greekletter
}

\begin{document}

%%%%%%% Print the glossaries
\printnoidxglossary[type=symbol,nonumberlist,style=listoc]

%%%%%%% ----> What should I do here to reset the glossary entries?
\printnoidxglossary[type=constants,nonumberlist,style=listoc]

%%%%%%% Reference an element from every glossary
Reference symbol: \gls{sym:t} \gls{sym:t}\\
Reference constant: \gls{con:g} \gls{con:g}

\end{document}

這是定義詞彙表樣式的 glspreamble.tex 檔案(通常這會包含符號清單的單獨樣式,因為它們沒有值)

% Generate the glossary 
    % create a new glossary style for the list of constants
        % Adapted from http://www.latex-community.org/forum/viewtopic.php?f=5&t=20797
        \newglossarystyle{listoc}{%
        % \glossarystyle{altlongragged4col}
        \setlength{\glsdescwidth}{0.8\textwidth}
        % allow line wrap in the description column
        \renewenvironment{theglossary}%
            {\begin{longtable}{lllp{\glsdescwidth}}}%
            {\end{longtable}}%
        \renewcommand{\glsgroupskip}{}% make nothing happen between groups
        \renewcommand*{\glossaryheader}{%
        \bfseries Symbol & \bfseries Value & \bfseries Unit & \bfseries Description \\\endhead}%
        % No heading between groups:
        \renewcommand*{\glsgroupheading}[1]{}%
        % Main (level 0) entries displayed in a row optionally numbered:
        \renewcommand*{\glossentry}[2]{%
        \glsentryitem{##1}% Entry number if required
        \glstarget{##1}{\glossentryname{##1}}% Name
            & \glsentryuseri{##2}% Value
            & \glossentrysymbol{##2}% Unit
            & \glossentrydesc{##2}% Description
            \tabularnewline % end of row
        }%
        % Similarly for sub-entries (no sub-entry numbers):
        \renewcommand*{\subglossentry}[3]{%
        % ignoring first argument (sub-level)
        \glstarget{##2}{\glossentryname{##2}}% Name
            & \glsentryuseri{##2}% Value
            & \glossentrysymbol{##2}% Unit
            & \glossentrydesc{##2}% Description
            \tabularnewline % end of row
            }%
            % Nothing between groups:
            \renewcommand*{\glsgroupskip}{}%
            }

\newglossary[symbol-glg]{symbol}{symbol-gls}{symbol-glo}{List of Symbols}
\newglossary[constants-glg]{constants}{constants-gls}{constants-glo}{List of Constants}
\makenoidxglossaries
\newglossaryentry{romanletter}{type=symbol,name={},description={\nopostdesc},sort=a}
\newglossaryentry{greekletter}{type=symbol,name={},description={\nopostdesc},sort=b}
\newglossaryentry{romanletterc}{type=constants,name={},description={\nopostdesc},sort=a}
\newglossaryentry{greekletterc}{type=constants,name={},description={\nopostdesc},sort=b}

答案1

您已將一個術語表中的條目指派給另一術語表中的父條目。因此romanletter(在symbol術語表中)在術語表sym:t中有一個子級,在術語表中有symbol一個子級。子項會導致其父項被添加到自己的詞彙表中,但這也會導致父項的所有其他子條目(在本例中)被添加。con:gconstantscon:gromanlettersym:t

我懷疑這其實只是一個錯字,而父級con:g其實應該是romanletterc.

\newglossaryentry{con:g}
{
    type=constants, 
    name={\ensuremath{g}}, 
    description={Local gravitational acceleration},
    user1={\ensuremath{9.81}},
    symbol={\ensuremath{\frac{m}{s^2}}},
    sort=g,
    parent=romanletterc % <--- correction
}

此校正會產生所需的結果。

文件影像

相關內容