Draw rectangle into the Array
I am sure there is a nice tikz
way to do this, but here, I just lay out a succession of columns, with \fbox
es around the appropriate ones.
\documentclass[10pt]{article}
\usepackage{tabstackengine,xcolor}
\TABstackMath
\newcommand\redbox[1]{\textcolor{red}{\fbox{\textcolor{black}{#1}}}}
\begin{document}
\[
\TABbinary
\fboxsep=2pt
\fboxrule=1pt
\tabbedCenterstack{16\cdot\\11\cdot}
\redbox{\tabbedCenterstack{I_1\\I_1}}
\tabbedCenterstack{+11\cdot\\+16\cdot}
\redbox{\tabbedCenterstack{I_2\\I_2}}
\tabbedCenterstack{=\\=}
\redbox{\tabbedCenterstack{13\\17}}
\]
\end{document}
Even though I don't use tabbed columns, I use \tabbedCenterstack
in lieu of \Centerstack
, so that I can employ the \TABbinary
feature, which adds {}
to each side of every column, which will assure proper spacing for =
, +
, and \cdot
.
You can use the hf-tikz
package:
\documentclass{article}
\usepackage{amsmath,array}
\usepackage[norndcorners,customcolors,nofill]{hf-tikz}
\hfsetbordercolor{red!70}
\begin{document}
\begin{equation}
\tikzset{left offset=-0.02,right offset=0.02,disable rounded corners=true}
\begin{array}{@{} *{2}{ c @{} >{{}}c<{{}} @{} } c @{}}
16\cdot \tikzmarkin{A}I_1 & + & 11\cdot \tikzmarkin{B}I_2 & = & \tikzmarkin{C}13\\[1ex]
11\cdot I_1\tikzmarkend{A} & + & 16\cdot I_2\tikzmarkend{B} & = & 17\tikzmarkend{C}
\end{array}
\end{equation}
\end{document}