2

I have a custom glossary and I am defining the user1 key in the glossary entry field but it doesn't show up in the glossary list.

I want the unit column (useri) to come in between name and description.

    \documentclass[11pt, a4paper]{article}
   \usepackage{tabu}
%    \usepackage{kima}% package style defined in a separate .sty file

    \usepackage{amssymb}
    \usepackage{amsmath}
    \usepackage{float}
    \usepackage[utf8]{inputenc}

    \usepackage[toc, nonumberlist, acronym, section, nopostdot]{glossaries}

    \makeglossaries 

   \begin{document} 

   \newglossarystyle{mystyle}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\begin{longtable}{@{}p{0.12\textwidth}@{} p{0.08\textwidth}@{}p{0.6\textwidth}}}%
{\end{longtable}}
% Set the table’s header:
\renewcommand*{\glossaryheader}{%
%\bfseries Term & \bfseries Description & \bfseries Units &
%\bfseries Symbol & \bfseries Dimensions & \bfseries Page List
%\\\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{##1}% Units
& \glossentrydesc{##1}% Description
%& \glossentrysymbol{##1}% Symbol
%& \glsentryuserii{##1}% Dimensions
%& ##2% Page list
\tabularnewline % end of row
}%
}%



    \glsaddallunused 



    \printglossary[title=List of Symbols, toctitle=List of Symbols,style =mystyle]


    \newglossaryentry{length}{name=$l$, description={Diffusion length}, user1={m} , sort=length}

    \gls{length}

    \end{document}
  • Without kima.sty, the file does not compile. Could you please change it to a MWE? Also, there seem to be suprious characters in the code, e.g. [ instead of [, or [![ at the beginning. – jarauh Oct 14 '15 at 0:10
  • @jarauh I edited the MWE, could u pls check now? – junomarkman Oct 14 '15 at 5:38
  • Your MWE works fine for me, but I recommend you move \newglossaryentry into the preamble. (See Drawbacks With Defining Entries in the Document Environment.) – Nicola Talbot Oct 14 '15 at 7:54
  • @NicolaTalbot unfortunately I cannot accept your answer here somehow. The grey tick doesn't appear next to your post. – junomarkman Oct 14 '15 at 9:01
  • @junomarkman Did moving \newglossaryentry to the preamble fix the problem? – Nicola Talbot Oct 14 '15 at 11:02
1

The problem is caused by defining the entry after \printglossary. The simplest (and recommended) fix is to move the definition to the preamble.

Version 3.07 and below wrote the name, description and symbol information to the external glossary file, which meant those values could be used in the glossary even if the entry was defined later, but none of the other fields could be referenced until the entry had been defined.

Versions after 3.07 only write the label to the external field (wrapped in the argument of \glossentry) to avoid the problems caused by fragile commands or overly long descriptions that exceeded makeindex's buffer. To ensure backward-compatibility, any entry definitions that occur within the document environment are written to a temporary file (with the extension .glsdefs) which is then read in at \begin{document} on the next LaTeX run. This means that the fields can be accessed in \printglossary even if it occurs before the entry definition. Unfortunately there are drawbacks with this approach, which is why the glossaries user manual recommends defining all entries in the preamble.

I'm guessing that you have version 3.07 or below, since all the fields should be accessible at that point with newer versions, unless you have modified the entry definition and haven't done a rerun.

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.