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...

1 Answer 1


\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_%


  • 2
    Which will insert spaces after control sequences, of course.
    – Joseph Wright
    Aug 29, 2012 at 10:59
  • @JosephWright As does \show and such, so it's a feature :-) A more elegant solution probably requires verbatim style trickery. Aug 29, 2012 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, 2012 at 11:06
  • @JosephWright ...in which case you'd get the complementary problem with spaces... Aug 29, 2012 at 11:08
  • 1
    I recoil with dismay and horror at this lamentable plague of macros which do not have expandable versions. — Charles Hermite :P
    – percusse
    Aug 29, 2012 at 11:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .