I want my two dollars:


However, all I get is:

! TeX capacity exceeded, sorry [input stack size=5000].
\font@name ->
l.3 \edef\twodollars{\$

Is it possible to use \edef with a value that includes a dollar sign?

  • 1
    Why not just use \def\twodollars{\$2}?
    – Werner
    Nov 30, 2011 at 5:07
  • @Werner: in the application the "2" is a macro \twoOrThree, and I want to use the value \twoOrThree has at the time of \twodollars definition, rather than the value at a later expansion of \twodollars. Nov 30, 2011 at 5:10
  • Also, the dollar sign just has to look like a dollar sign when \twodollars is expanded in plain horizontal mode text. I didn't see a "\textdollarsign" like for underscore. Nov 30, 2011 at 5:11

2 Answers 2



\edef\twodollars{\string$2} \twodollars

\string changes the category code for $ to 12 (other).

  • Works like a charm, even in the convoluted mess of my real application. Thanks! Nov 30, 2011 at 5:19
  • @JackSchmidt: If you need this more often, consider defining a macro for the dollar. For example, the newverbs package allows for \Verbdef\dollar|$|, which also works for other special characters including %, where \string does not work. Dec 1, 2011 at 8:59

The correct way is to say


as \$ is defined via \DeclareRobustCommand. An alternative is to say


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.