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.

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

While printing the List of Symbols, I would like, in a draft, to print the definition commands as well. For instance, consider the following commands:


and the following command for printing symbols within a table:

\providecommand{\symbdef}[2]{\texttt{\color{blue}\string #1} & #1 & #2}

Now, the code:

\section{List of Symbols}
\symbdef{\perm}{a permutaion} \\
\symbdef{\permel{i}}{the value of \perm for the argument $i$} \\

proudeces output: \perm and \permeli in the first column. However I would like to print \permel{i} instead of \permlei here and do not know how.

Please help...

share|improve this question
up vote 6 down vote accepted

\string only takes one token and prints that, so it only ever sees \permel.


\providecommand{\symbdef}[2]{\texttt{\color{blue}\detokenize{#1}} & #1 & #2}

This will insert explicit spaces after control sequences, which is not semantically wrong, but might not be aesthetically pleasing. In that case, try filtering out the spaces like this:

\providecommand{\symbdef}[2]{\texttt{\color{blue}\expandafter\filterspaceaftercs\detokenize{#1\x}_} & #1 & #2}

|gdef|filterspaceaftercs#1\#2 #3_%


share|improve this answer
Which will insert spaces after control sequences, of course. – Joseph Wright Aug 29 '12 at 10:59
@JosephWright As does \show and such, so it's a feature :-) A more elegant solution probably requires verbatim style trickery. – Stephan Lehmke Aug 29 '12 at 11:05
Yes, I known :-) I was just contrasting it with \string, which does not but where you do need to do a token-by-token conversion (tricky, depending on requirements). – Joseph Wright Aug 29 '12 at 11:06
@JosephWright ...in which case you'd get the complementary problem with spaces... – Stephan Lehmke Aug 29 '12 at 11:08
I recoil with dismay and horror at this lamentable plague of macros which do not have expandable versions. — Charles Hermite :P – percusse Aug 29 '12 at 11:51

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.