farbiges Kästchen um eine Spalte in der Matrix

farbiges Kästchen um eine Spalte in der Matrix

Wie kann ich in einer Matrix ein farbiges Kästchen mit einem Pfeil und Text wie diesem um eine Spalte zeichnen:

Bildbeschreibung hier eingeben

Hier ist der Code, den ich bisher habe:

\documentclass[11pt]{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm}

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

\usepackage{tikz} 

\begin{document}

\begin{equation}
\begin{bmatrix}[cccc|c]
  1 & 0 & -1 & 0 & 0 \\
  0 & 1 & 2 & 0 & 0 \\
  0 & 0 & 0 & 1 & 0
\end{bmatrix}\\
\end{equation}

\end{document} 

Antwort1

Der einfachste Weg besteht darin, die Matrix als TikZ-Matrix zu schreiben und den gewünschten Spaltenrahmen und die Notiz hinzuzufügen:

Bildbeschreibung hier eingeben

\documentclass[11pt]{book}
    \usepackage{amsmath,amsfonts,amssymb,amsthm}
    \usepackage{tikz}
\usetikzlibrary{arrows.meta,bending,matrix,positioning}

    \begin{document}
\begin{equation}
\begin{tikzpicture}[
    node distance=1mm and 0mm,
    baseline]
\matrix (M1) [matrix of nodes,{left delimiter=[},{right delimiter=]}]
{
  1 & 0 & -1 & 0 & 0 \\
  0 & 1 & 2  & 0 & 0 \\
  0 & 0 & 0  & 1 & 0 \\
};
\draw   (M1-1-4.north east) -- (M1-3-4.south east);
\draw[red,very thick] 
        (M1-1-3.north west) -| (M1-3-3.south east) -| (M1-1-3.north west);
\node (fv) [below right=of M1.south east,align=left,
            font=\sffamily\bfseries] {free\\variable};
\draw[blue!60,very thick,shorten >=1mm,-{Stealth[bend]}] 
        (fv.west) to [out=180,in=270] (M1-3-3.south);
\end{tikzpicture}
\end{equation}
    \end{document}

verwandte Informationen