Commands\textcolor

\textcolorCommand

Colors a single argument, used to highlight one term in a formula without affecting what follows; an optional model argument such as rgb, RGB, or gray gives the color numerically.

\textcolor{red}{x^2} + y^2
Available in
color, textmacros
Kind
prefix
Allowed mode
math, text
Frequency
<0.01% of corpus formulasrank 201 of 263
Commonality
medium
Tags
presentation
Renderer support
PackageMathJaxKaTeXXeTeX
colorMathJax: FullKaTeX: PartialXeTeX: Full
textmacrosMathJax: FullKaTeX: PartialXeTeX: Full
About the test scope

Syntax#

\textcoloro:N[\cs]optional control sequencem:N{\cs}control sequencem{a}math content

Argspec o:N m:N m — one optional and two mandatory arguments. In color. Reading argspecs

\textcoloro:N[\cs]optional control sequencem:N{\cs}control sequencem:T{a}text content

Argspec o:N m:N m:T — one optional and two mandatory arguments. In textmacros. Reading argspecs

Examples#

color

f(x) = \textcolor{blue}{\sin x} + \cos x

color

\textcolor[RGB]{0,128,0}{a + b} = c

color

\frac{\textcolor{red}{\partial f}}{\partial x}

textmacros

\text{\textcolor{red}{important}}

textmacros

\text{see \textcolor{blue}{this note} for $x > 0$}

textmacros

\text{\textcolor[RGB]{0,128,0}{valid for $n \ge 1$}}

Package variants#

PackageSignatureAllowed modeNotes
coloro:N m:N mmathColors a single argument, used to highlight one term in a formula without affecting what follows; an optional model argument such as rgb, RGB, or gray gives the color numerically.
textmacroso:N m:N m:TtextColors a span of text inside text-mode content such as \text; the colored argument is text and may contain inline math, and an optional model argument gives the color numerically.

In TeXForm#

TeXForm parses this entry as prefix syntax; the package determines its argument specification.

See also#

Test cases#

color
InputCaseMathJaxKaTeXXeTeX
\textcolor{blue}{a}Positive · baselinePassPassPass
\textcolor[RGB]{0,0,255}{a}Positive · vary:o[0]PassFailPass
\textcolor{blue}aPositive · bare[2]PassPassPass
\textcolor[\alpha]{0,0,255}{a}Negative · neg:N[0]FailFailFail
\textcolor{\alpha}{a}Negative · neg:N[1]PassFailFail
textmacros
InputCaseMathJaxKaTeXXeTeX
\textcolor{blue}{a}Positive · baselinePassPassPass
\textcolor[RGB]{0,0,255}{a}Positive · vary:o[0]PassFailPass
\textcolor{blue}aPositive · bare[2]PassPassPass
\textcolor[\alpha]{0,0,255}{a}Negative · neg:N[0]FailFailFail
\textcolor{\alpha}{a}Negative · neg:N[1]PassFailFail
\textcolor{blue}{a^2}Negative · neg:T[2]FailFailFail