[Tex/LaTex] \newcommand, par and textcolor

colormacrosparagraphs

OK. I read What's the difference between \newcommand and \newcommand*?. However, when I try using

\definecolor{cincinnati-red}{RGB}{190,0,0}

\newcommand{\authorA}[1]{\textcolor{cincinnati-red}{[A: #1]}}

in this form:

\authorA{
    Hi Guys:

    (more stuff)
}

I get the error

Runaway argument?
{[A:  Hi Guys: 
! Paragraph ended before \@textcolor was complete.
<to be read again> 
                   \par 
l.166 }

How do I set up this macro so that the textcolor extends over the entire scope of the argument? (Simply changing \textcolor to \color, as suggested when reading Writing paragraphs in \textcolor, does not work for me. (The color does not show up.)

Best Answer

The correct command here is \color as \textcolor is not long. The syntax for your command would then be

\newcommand{\authorA}[1]{{\color{cincinnati-red}[A: #1]}}

not that that \color and the text it applies to is enclosed in an extra group of braces, so the color does not affect the text following the command.

Sample output

\documentclass{article}

\usepackage{xcolor}

\definecolor{cincinnati-red}{RGB}{190,0,0}

\newcommand{\authorA}[1]{{\color{cincinnati-red}[A: #1]}}

\begin{document}

Text before

\authorA{
    Hi Guys:

    (more stuff)
}

Text after
\end{document}