TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 to work as an alert command. If I want to alert some part of my text I would simply write \alert{}. But I want the result in red color.

What is the best way to do this? I tried


but I know that there is \textcolor also. I want my command to work both for text and math contents.

What is the difference between them?

share|improve this question
up vote 25 down vote accepted

Despite the name \textcolor also works in math mode. The main difference is just one of syntax, \textcolor takes text as an argument (like \textrm) \color affects all text to the end of the group (like \rmfamily). However \textcolor also executes \leavevmode which makes the color special occur in a much less destructive place as part of the paragraph rather than on a vertical list. So \textcolor is usually a better choice unless you are setting a colour for a large amount of text, such as the whole document.

share|improve this answer
Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages? – Sigur Dec 8 '12 at 0:38
There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls – David Carlisle Dec 8 '12 at 0:39

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.