How can I expand a macro inside an optional argument list

label={$\bullet$},topsep=0mm, parsep=0mm,% leftmargin=3mm,rightmargin=0cm,labelwidth=5mm,labelsep=3mm%

\item gugus

This does not work, (not giving any good debuggin message). So the expansion is wrong?

How can I fix this?

  • This is the typical trap with key-value-interfaces, it won't work this way – user31729 Aug 26 '15 at 13:24
  • What is the trap here :-) or better what does latex do when inserting the macro? – Gabriel Aug 26 '15 at 13:25
  • The trap is the non-expansion of key-value - parsers, but David Carlisle stated this already – user31729 Aug 26 '15 at 15:14
  • There are some solutions to this question as well other answers to your other questions, but you rarely accept answers -- that's not really a proof of approving the efforts by users in order to help you – user31729 Dec 2 '15 at 20:46

keyval parsers typically don't expand the arguments (otherwise things like font=\small would blow up badly as \small would expand too early.

so the simplest thing is to use

\begin{itemize}[label={$\bullet$},topsep=0mm, parsep=0mm,% leftmargin=3mm,rightmargin=0cm,labelwidth=5mm,labelsep=3mm%

\item gugus

Usually a key value parser needs to see the syntax characters = and , directly. Therefore, the macro \sss should be expanded once. This can be done with lots of \expandafter:

\expandafter\begin\expandafter{\expandafter i\expandafter t ...\expandafter}\expandafter[\sss]

or the whole expression can be expanded as macro:


Here, \unexpanded prevents the further expansion of \sss after it was expanded once to prevent values from expanding too early.

  • Do you have some good reference to learn about expansions? – Sigur Aug 26 '15 at 13:32
  • 1
    "The TeXbook" by Donald E. Knuth or "TeX by Topics" by Victor Eijkhout. – Heiko Oberdiek Aug 26 '15 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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