5

I use glossaries to display a global symbol list but also local one for each equation. The first userkey is used to add the physical unit. But some smybols (like efficiencies or proportions) don't require a unit. I marked these with a dash. In the global list of symbols this looks fine (like the one at COP).

enter image description here

But for the local one (due to using a diffrent style) it looks kinda silly.

enter image description here

So my wish is to drop the in - if the \glsuerkeyi equals -. I have a command which is placed inside the glossarystyle to produce the entries :

%glossarystyle uses tabular 
\newcommand{\itemss}[2]{\glstext*{#1} & #2 in \glsuseri*{#1}  \\}

So I guess this command needs to be renewed conditionally for each entry. I found this (How to check if a macro value is empty or will not create text with plain TeX conditionals?) helpful post.

But I have quite a few things I'm not sure about:
a) Can the command even be renewed inside the glossaries environment and if yes can it be redefined for each entry?
b) I'm not sure which solution from the other post to apply. Since I got tokens, printed out text and I do not want to check for emtpy strings, and so on.

I would really appreciate if you could point me in the right direction.

Edit: I think i got it partially figured out. Using etoolboxes \ifstrequal might be a solution:

\newglossarystyle{tabx4col}{%
% put the glossary in a longtable environment:
\renewenvironment{theglossary}%
{\vspace{-1.7em} 
\begin{longtable}{@{}p{0.15\textwidth}@{}p{0.1\textwidth}@{}p{0.60\textwidth}@{}p{0.15\textwidth}@{}}}%
{\end{longtable}}%
% Set the table's header:
\renewcommand*{\glossaryheader}{}%
% No heading between groups:
\renewcommand*{\glsgroupheading}[1]{}%
% Main (level 0) entries displayed in a row:
\ifstrequal{\glsentryuseri{##1}}{-}{

\renewcommand*{\glossaryentryfield}[5]{%
\glstarget{##1}{##2}% Name
& \glsentryuseri{##1}% Units
& ##3% Description
& ##5% Page list
 \\% end of row
}%
}{
\renewcommand*{\glossaryentryfield}[5]{%
\glstarget{##1}{##2}% Name
&
& ##3% Description
& ##5% Page list
 \\% end of row
}%
}
% Sub entries treated the same as level 0 entries:
%\renewcommand*{\glossarysubentryfield}[6]{%
%\glossaryentryfield{##2}{##3}{##5}{##6}}%
%% Nothing between groups:
%\renewcommand*{\glsgroupskip}{}%
}

I'm not sure if \glsentryuseri{##1} is the right entry to check and I think it always get compared to the actual text inside the first pair of brackets, in this case \glsentryuseri{##1}. It would need to be expanded somehow.

Edit: Created MWE (https://gist.github.com/tairun/5648781)

Sensei
  • 515
  • Out of interest, what are you using to do your glossaries, I need to do one myself...? – Nicholas Hamilton May 25 '13 at 09:22
  • @ADP Package-wise? I use the glossaries package (http://www.ctan.org/pkg/glossaries). In my eyes its the best tool to create any kind of "index". Highly customizable with your own styles. Multiple glossaries and as I recently learned you can even create a glossary per chapter/section/environment whatever you like. – Sensei May 25 '13 at 09:35
  • @ADP np. If you need to know more, its quite a popular package. You will find good documentation on the internet or here at tex.stack – Sensei May 25 '13 at 09:42
  • Please add a complete minimal working example. – Marco Daniel May 25 '13 at 09:58
  • @Marco Daniel Created MWE (https://gist.github.com/tairun/5648781) – Sensei May 25 '13 at 11:34
  • @Sensei: Do you want something like this & \def\tempa{-}\edef\tempb{\glsentryuseri{##1}}\ifx\tempa\tempb\else\glsentryuseri{##1}\fi% Units <- it's your unit line. – Marco Daniel May 25 '13 at 11:47
  • Almost works. The other entry which is not supposed to be modified shows the wrong unit. For me it displays: ?ee0 (questionamark + its identifier. – Sensei May 25 '13 at 11:59
  • @Sensei: I took your example and here my output: http://i.stack.imgur.com/PP62q.png – Marco Daniel May 25 '13 at 12:03
  • @Marco Daniel Now it works like a charm. Thank you. Did like 4 compile runs and it wouldn't show up correctly. After deleting the temp files it worked though. Please convert your comment into an answer so I can accept it. Thanks again. – Sensei May 25 '13 at 12:21

1 Answers1

3

There are different approaches testing strings. The package etoolbox provides some approaches. However in your case it's important that \glsentryuseri{##1} is expanded before you test it. Related to your minimal example you can do this in the following way:

\def\tempa{-}%define token to compare
\edef\tempb{\glsentryuseri{##1}}%expand user key and save the material in a token
\ifx\tempa\tempb%compare both tokes
 %equal -- do nothing
\else
 %not equal; print out
 \glsentryuseri‌​{##1}
\fi

With these modification your example results to:

enter image description here

Marco Daniel
  • 95,681