how to change color of matrix bracket
Here I provide bmatrixcolor
with an optional argument for the color. EDITED to save the pre-existing color, rather than returning to black
, using the xcolor
feature .
to refer to the current color. In this way, the matrix data will be set in the prevailing color.
\documentclass{article}
\usepackage{amsmath,xcolor}
\newenvironment{bmatrixcolor}[1][red]
{\colorlet{savethecolor}{.}\colorlet{bracecolor}{#1}%
\color{bracecolor}\left[\color{savethecolor}\begin{matrix}}
{\end{matrix}\color{bracecolor}\right]}
\begin{document}
\[
\begin{bmatrix} 1 & 0.5 \end{bmatrix}
\]
\[
\begin{bmatrixcolor} 1 & 0.5 \end{bmatrixcolor}
\]
\[
\begin{bmatrixcolor}[blue] 1 & 0.5 \end{bmatrixcolor}
\]
\color{red}
\[
x =\begin{bmatrixcolor}[blue] 1 & 0.5 \end{bmatrixcolor}\!^T
\]
\end{document}