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

I would like to define a new command like the following. The latex when compiling should emit I_{wr} when given without arguments, or the optional arguments should come as a subscript.


So If I give $\myCommand{2}$, then it would emit the text as I_{wr}2. The 2 does not come in the subscript form. Could anyone please tell me how to do this correctly?

Thank You

share|improve this question
up vote 8 down vote accepted

It's already correct except for the usage:


The argument is an optional argument that uses square brackets:


Full example:



  \myCommand[2] = 2 * \myCommand


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.