1

This question already has an answer here:

This code is building from the solutions posted here. I am trying the approach suggested from the duplicate solutions. I am having two issues:

  1. I am not sure how to get the arrow to point to the text "free variable" with this new approach, and

  2. The brackets seem to be shorter and closer to the numbers as compared to the original matrix.

Can you help me fix these issues of drawing the arrow to point to the text and also fix the way how the brackets appear?

This is how I would like my end result to look, Thanks!:

enter image description here

Here is the code:

\documentclass[11pt]{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{0,173,239}

\usepackage{blkarray}

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

\usepackage{tikz}

\usetikzlibrary{arrows,matrix,positioning,fit}
\tikzset{%
  highlight/.style={rectangle,rounded corners,fill=ocre!50,draw,
    fill opacity=0.5,thick,inner sep=0pt}
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,
  baseline=(#1.base)] \node (#1) {#2};}
%
\newcommand{\Highlight}[1][submatrix]{%
    \tikz[overlay,remember picture]{
    \node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}

\begin{document}

\[
\begin{blockarray}{ccccc}
x_{1} & x_{2} & x_{3} & x_{4} &  \\
\begin{block}{[cccc|c]}
  1 & 0 & \tikzmark{left}{-1} & 0 & 0 \\
  0 & 1 & 2 & 0 & 0 \\
  0 & 0 & \tikzmark{right}{0} & 1 & 0 \\
\end{block}
\end{blockarray} 
\] 
\Highlight[new1] 

\tikz[overlay,remember picture] {
  \draw[->,thick,red,dashed] (new1)  node [pos=0.66,above,text width = 2cm] {\emph{free \\ variable};
}}

\end{document} 

marked as duplicate by egreg tikz-pgf Feb 8 '16 at 22:13

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.

  • See Stefan's answer in particular. – Alenanno Feb 8 '16 at 17:22
  • Hello, these solutions do not address my first issue with the brackets being shorter than that compared to the brackets in the Original Matrix and also closer to the numbers. How can I fix this issue? Thanks. – Joe Feb 8 '16 at 19:34
  • How is this any different from the question I just answered, which you asked later? Asking the same question just wastes people's time. – cfr Feb 8 '16 at 22:06
  • @Joe Of course it doesn't. This question is about a different topic. Stefan's answer in the linked question perfectly works with this code. – Alenanno Feb 8 '16 at 22:06
4

You must move the "free variable" node ; arrow will automatically follow.

\documentclass[11pt]{book}

\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{0,173,239}

\usepackage{blkarray}

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

\usepackage{tikz}

\usetikzlibrary{arrows,matrix,positioning,fit}
\tikzset{%
  highlight/.style={rectangle,rounded corners,fill=ocre!50,draw,
     fill opacity=0.5,thick,inner sep=0pt}
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,
  baseline=(#1.base)] \node (#1) {#2};}
%
\newcommand{\Highlight}[1][submatrix]{%
     \tikz[overlay,remember picture]{
     \node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}

\begin{document}

\[
\begin{blockarray}{ccccc}
x_{1} & x_{2} & x_{3} & x_{4} &  \\
\begin{block}{[cccc|c]}
  1 & 0 & \tikzmark{left}{-1} & 0 & 0 \\
  0 & 1 & 2 & 0 & 0 \\
  0 & 0 & \tikzmark{right}{0} & 1 & 0 \\
\end{block}
\end{blockarray} 
\] 
\Highlight[new1] 

\tikz[overlay,remember picture] {
  \node[below=(.5cm of new1), xshift=1.5cm, red,font=\itshape, name=free1] {\shortstack{free \\ variable};}}
\tikz[overlay,remember picture] \draw[->] (free1) to[out=180,in=270] (new1);

\end{document} 

enter image description here

  • Thank you for your solution. How can I modify your solution so that the text and arrow appear just like in the image included in my original question? Thanks. – Joe Feb 8 '16 at 19:42
  • 1
    I just edit my answer like you want – flav Feb 9 '16 at 5:03

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