3

I want to be able to change the color of a matrix brackets. I have found this answer but it is not exactly what I am looking for, since with this answer the subindex just right outside the matrix is not at the desired height. I would like to be able to write something similar to

\begin{equation*}
   \begin{pmatrix}
        1 \\
        2 \\
        -1
   \end{pmatrix}_{\!\!e}
\end{equation*}

and obtain

enter image description here

but with a different color for the brackets (and maybe also a different color for the subindex).

4
  • 6
    Does this answer your question? how to change color of matrix bracket – Sachchidanand Prasad Oct 26 '20 at 8:58
  • 1
    @SachchidanandPrasad -- The OP mentioned, that that answer messes with the positioning of the subscript – DG' Oct 26 '20 at 11:47
  • 1
    @SachchidanandPrasad It does not. As I mention in the post, I had already seen this answer, but it messes with the positioning of the subscript, as #DG' says. – Just_a_newbie Oct 26 '20 at 12:06
  • 1
    @Just_a_newbie Yeah just saw that, sorry for this. – Sachchidanand Prasad Oct 26 '20 at 14:32
3
\documentclass{article}
\usepackage{amsmath,xcolor,environ}

\NewEnviron{pmatrixcolor}[1][red]{%
  \colorlet{currentcolor}{.}%
  \mathinner{\begingroup\color{#1}\left(\color{currentcolor}%
    \begin{matrix}
      \BODY
    \end{matrix} \color{#1}\right)\endgroup}}

\begin{document}
\[
    \begin{pmatrix}
        1 \\
        2 \\
        -1
    \end{pmatrix}
    _e
\]

\[
    \begin{pmatrixcolor}
        1 \\
        2 \\
        -1
    \end{pmatrixcolor}
    _e
\]
\end{document}

enter image description here

1
  • 1
    Thank you, this is exactly what I was looking for! – Just_a_newbie Oct 27 '20 at 10:40

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.