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 know that it is possible to obtain colored text in Latex by including the color package and writing like

\textcolor{red}{This is red text}

How could I define a macro which would produce text of a given color such as

\red{This is red text}


share|improve this question
\newcommand\red[1]{\color{red}#1} isn't good enough? Why you don't want to use \textcolor, too verbose? Maybe the question actually was about defining own macros? If yes, then see e.g. LaTeX/Customizing LaTeX from LaTeX wikibook. – przemoc Jul 11 '11 at 18:35
@przemoc: Your macro will switch to red color for every text following it, not only the macro's argument. Correct would be (e.g.) \newcommand\red[1]{{\color{red}#1}} (note the additional set of braces). – lockstep Jul 11 '11 at 18:40
@lockstep: Damn, right! Forgot about them... – przemoc Jul 11 '11 at 18:41
@Ihahne: The command \red is defined in pstricks and therefore leads to errors. You can overcome this conflict by \renewcommand\red[1]{{\color{red}#1}} or better define a new command like \newcommand\txtred[1]{{\color{red}#1}}. – strpeter Dec 10 '13 at 11:25
up vote 16 down vote accepted

\newcommand{\red}[1]{\textcolor{red}{#1}} works. Or are you trying to do something more general, such that \somecolorname{foo} behaves the same as \textcolor{somecolorname}{foo}? That latter case is probably not a good idea...

share|improve this answer
A \newcommand*{\red}{\textcolor{red}} is actually fine enough. There is no need to pass the argument around. Also \textcolor simply calls \color internally, so \newcommand\red[1]{{\color{red}#1}} would be more efficient. However I would go with \newcommand*\red{\color{red}}, then you can write {\red text} instead of \ref{text} and also use \red to switch to red for the rest of the group. – Martin Scharrer Jul 11 '11 at 18:54
@MartinScharrer, it's true that you can elide the argument. And it's more efficient TeX, too (actually, it's more efficient programming in nearly any language). On the other hand, it is slightly odd-looking and takes a bit of TeXpertise to understand a command definition that effectively takes one more invisible argument. So unless I need the subtly different semantics of leaving off the argument (because of brace groups), or really am worried about the efficiency, I tend to leave the argument in for clarity's sake. – Ben Lerner Jul 11 '11 at 19:02

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.