3

This question already has an answer here:

How can I go about drawing a colored box around a column in a matrix with an arrow and text like this:

enter image description here

Here is the code that I have thus far:

\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} 

marked as duplicate by Peter Grill tikz-pgf Feb 8 '16 at 7:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

The simplest way is write matrix as TikZ matrix and add desired column frame and note to it:

enter image description here

\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}
  • ! Package pgf Error: No shape named M1-1-4 is known. – JuanPi Jul 27 '18 at 16:16
  • @JuanPi above mwe works. coordinate M1-1-4 is defined. i tested it now again with xelates as well with pdflatex. – Zarko Jul 27 '18 at 16:30
  • you are right, I had an error in my matrix that was reported as shaped unknown. – JuanPi Jul 31 '18 at 11:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.