TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with a command i make for a specific glossary:

\def\term#1{\def\tempa{#1}\futurelet\next\term@i}% Save first argument
\def\term@i{\ifx\next\bgroup\expandafter\term@ii\else\expandafter\term@end\fi}%Check brace
\def\term@ii#1{\glslink{term:\tempa}{#1}}%Two args
\def\term@end{\glslink{term:\tempa}{\tempa}}%Single args

It should work like this:

'\term{BAR}' -> '\glslink{term:BAR}{BAR}'
'\term{BAR}{FOO}' -> '\glslink{term:BAR}{FOO}'

It works fine except of the space that is entered before the Result.

It seems to work like that

'\term{BAR}' -> '\xspace\glslink{term:BAR}{BAR}'
'\term{BAR}{FOO}' -> '\xspace\glslink{term:BAR}{FOO}'
share|improve this question

Your example works fine on my TeXLive installation. Please post a complete compilable example so we can have a closer look. The space seems not to come from your code anyway. Also your first line seems to be unrelated to the example and should be removed.

You can achieve the same using:



'\term{BAR}' -> '\glslink{term:BAR}{BAR}'

'\term[FOO]{BAR}' -> '\glslink{term:BAR}{FOO}'

I assume here that \glslink is happy inside a group. Otherwise the code is a little bit more complicated.

share|improve this answer

Your Answer


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.