I'm trying to replace a single option (e.g., width=2mm or colour=green or dotted) with a simple \newcommand. I`m imagining something short like \w2, \cg, or \qst, just for typing speed (especially with the option=something ones).

What I'm specifically trying to do:



\todo[\q]{my text goes here}

I'm given an error that reads "Package xkeyval Error: `color=green' undefined in families todonotes'.

Now, the package gives an alternative to this, which is to fully write out the whole line as a new command, i.e.:

\newcommand{\q}{\todo[color=green]{my text goes here}}

Which is not terrible, but now I'm just curious how I can set one option as a command, since I haven't been able to find it anywhere, and I'm sure I'll want to do this in the future.

Update Looks like my speediest version is to do:

\newcommand{\q}[2][]{\todo[color=green, #1]{#1}}

So I can still change other options as normal.


The keyval parser goes to some lengths not to expand macros so that you can use them in values without them being expanded at the wrong time.

So you could force \q to expand before being passed in by


But that isn't very convenient,


is likely to be the simplest version.

  • Simple and speedy was what I was hoping for - this explains why all the other answers I was seeing when looking this up were so complex. Thanks! Feb 18 '20 at 20:35

You can define new keys.





Abc \todo[q]{text goes here}

Abc \todo[color=green]{text goes here}


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.