Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to have extra column in the glossary.

My application is list of symbols with

  1. symbol
  2. description
  3. units
\documentclass{article}
\usepackage{glossaries}


\makeglossaries

\newglossaryentry{mwe}{name=MWE, description={Minimum Working Example}}

% the previous line should have some extra field, or i could define my own command.
% Something that would envolve description={ {some text} && {some unit}}

\begin{document}

\printglossaries

\clearpage

This is the call to the \Gls{mwe}

\end{document}

Update: for what it is worth if you are running ubuntu < 12.04, you need to update your packages. (refer to here)

share|improve this question
    
Please add a minimal working example (MWE) that illustrates your problem. –  Joseph Wright Feb 14 '13 at 17:31
    
I don't know how to implement it! –  aiao Feb 14 '13 at 17:32
    
What I'm after here is some demo of the input syntax you want to use and output you need to get. This might be 'pseudo-code' or a mock-up, for example done by creating a table by hand. –  Joseph Wright Feb 14 '13 at 17:33
    
I'd define a custom glossary style for this –  cgnieder Feb 14 '13 at 18:30
    
@cgnieder sounds promising. Were to start? –  aiao Feb 14 '13 at 23:46
add comment

1 Answer 1

up vote 6 down vote accepted

Glossary entries can have up to six user fields. Let's use user1 for units, so the entries will be constructed as

\newglossaryentry{A}{%
name={foo},%
description={bar},%
user1={cm}%
}

Then we need a new style that will make use of the new field. How to define a new style is described in the manual, the important thing to know is that the user fields can be accessed via \glsentryuseri{##1}. To do a style based on longtable, we do (mostly copied from the manual):

\documentclass[a4paper,10pt]{article}
\usepackage{glossaries}
\makeglossaries

\newglossaryentry{A}{%
name={foo},%
description={bar},%
user1={cm}%
}

\newglossaryentry{B}{%
name={AAPL},%
description={apples},%
user1={box}%
}

\newglossaryentry{C}{%
name={BTR},%
description={books to read},%
user1={LoC}%
}

\newglossaryentry{D}{%
name={BTRTIO},%
description={books to read that I own},%
user1={shelf},%
parent={C}
}

\newglossarystyle{aiaostyle}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
 {\begin{longtable}{lp{\glsdescwidth}cp{\glspagelistwidth}}}%
 {\end{longtable}}%
% Set the table’s header: title row
\renewcommand*{\glossaryheader}{%
 \bfseries Term & \bfseries Description & 
 \bfseries Units & \bfseries Page List
 \\\endhead}%
% No table header:
\renewcommand*{\glossaryheader}{}%
% No heading between groups:
 \renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row optionally numbered:
 \renewcommand*{\glossaryentryfield}[5]{%
    \glstarget{##1}{##2}% Name
    & ##3% Description
    & \glsentryuseri{##1}% Units
    & ##5% Page list
    \\% end of row
 }%
% Similarly for sub-entries (no sub-entry numbers):
\renewcommand*{\glossarysubentryfield}[6]{%
    % ignoring first argument (sub-level)
    \glstarget{##2}{##3}% Name
    & ##4% Description
    & \glsentryuseri{##2}% Units
    & ##6% Page list
    \\% end of row
 }%
% Nothing between groups:
\renewcommand*{\glsgroupskip}{}%
}

\begin{document}
\null
\glsaddall

\glossarystyle{aiaostyle}
\setlength{\glsdescwidth}{0.5\textwidth}
\setlength{\glspagelistwidth}{0.1\textwidth}
\printglossary

\end{document}

The glossary will then be a longtable with four columns, where the third, a c column, will contain the content of the user1 field. glossary with units

share|improve this answer
    
no luck ! Package xkeyval Error: 'user1' undefined in families 'glossentry'. –  aiao Feb 17 '13 at 20:52
    
@aiao Does this happen with my MWE, or with your code? What is the version of your glossaries package? The user field were introduced in version 2.04, maybe you have an older version. –  mafp Feb 17 '13 at 23:05
    
Its a copy paste of your code pdflatex..... Package: glossaries 2009/09/23 v2.03 (NLCT) –  aiao Feb 18 '13 at 14:52
    
@aiao Then I guess your best chance is to update your TeX distribution, 2009 is quite old. You could of course also install a new version of glossaries into TEXMFHOME, but you soon will find other problems with an outdated distribution. –  mafp Feb 18 '13 at 16:29
    
that did it. Thanx –  aiao Feb 18 '13 at 18:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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