2

I'm writing a report with both a list of constants and list of symbols, both defined using the glossaries package. The problem is that the second list (in this case constants) not only contains the elements that it should contain, but also the ones from the first list (the symbols): List of Constants now contains both the constants AND the symbols

This problem occurs irrespective of the order (if they are switched around, the list of symbols will contain the constants as well). I think I have to call some sort of glossary reset command between printing them but am unable to find it anywhere. Anyone knows what causes this problem?

I use the TeXLive-full distribution that comes with Ubuntu 16.04. Glossaries package version according to \listfiles: glossaries.sty 2017/01/19 v4.29

I prepared a MWE. Note that I include only 1 glossary style, while in reality I would have separate styles for list of constants and symbols. This is just to keep the MWE small. The problem also occurs with the separate styles. Here is the main.tex file:

\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}

And this is the glspreamble.tex file that defines the glossary styles (normally this would contain a separate style for the list of symbols since they don't have a value)

% 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}
0
1

You've assigned an entry in one glossary to a parent in another glossary. So romanletter (in the symbol glossary) has a child sym:t in the symbol glossary and a child con:g in the constants glossary. The child con:g causes its parent romanletter to be added to its own glossary, but this also causes all of the parent's other child entries (sym:t in this case) to be added.

I suspect this is actually just a typo and the parent for con:g should actually be 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
}

This correction produces the desired result.

image of document

1
  • Yes that solves it! Even after a lot of looking through the differences I didn't find it.. I changed the parent to romanletterc for constants and romanletters for symbols. Thanks a lot! – JoostMeulenbeld Apr 19 '17 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.