3

I am using the packages amsmath and color.

The following works to color an entire array blue:

\documentclass{article}
\usepackage{amsmath}
\usepackage{color}
\begin{document}

\[
{\color{blue}
\left(
\begin{array}{c}
 1\\
 -3
\end{array}
\right)
}
\]

\end{document}

If I just want the numbers to be blue, I can move the \color inside the parens:

\documentclass{article}
\usepackage{amsmath}
\usepackage{color}
\begin{document}

\[
\left(
{\color{blue}
\begin{array}{c}
 1\\
 -3
\end{array}
}
\right)
\]

\end{document}

That works. However, if I move the \color inside the array, it does not work. The two errors are

Missing } inserted

and

Extra }, or forgotten $.

\documentclass{article}
\usepackage{amsmath}
\usepackage{color}
\begin{document}

\[
\left(
\begin{array}{c}
{\color{blue}
 1\\
 -3
 }
\end{array}
\right)
\]

\end{document}

Why does that not work?

  • remove grouping { } inside array and you'll see. – touhami Oct 10 '15 at 19:11
  • In array environment each column is group (in this case each raw) so you have error 1) \begingroup{ color{blue} 1\endgroup error 2 \begingroup 3}\endgroup – touhami Oct 10 '15 at 19:16
  • @touhami, When I remove grouping inside the array, only the 1 gets colored blue, not the -3. What is that supposed to be indicative of? – Daniel S. Oct 10 '15 at 19:17
  • each cell is a group, you can not start a group in one cell and end it in another. – David Carlisle Oct 10 '15 at 20:51
2

Color each cell:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor,array}

\begin{document}

\[
\left(
\begin{array}{@{}>{\color{blue}}c@{}}
 1\\
 -3
\end{array}
\right)
\]

\end{document}

enter image description 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.