# Boxing in cases environment

I'm working with a system

$$\begin{cases} Ax+By & = C\\ Dx+Ey & = F \end{cases}$$


Is there a way to put a box around A & D, around B & E, and around C & F within the system?

• You could use tikzpicture to print your equation and functionality rememberpictureoverlay and then you can add boxes arrows, symbols... whatever you want to make it appear as you wish – koleygr Sep 1 '17 at 7:22
• As always: also don't use $$...$$ that is not LaTeX syntax – daleif Sep 1 '17 at 7:25
• I'm not sure what you mean. In my TeXworks $$...$$ is the math display environment. – Ryan Sep 1 '17 at 7:56
•  is primitive tex syntax but it should not be used in a latex document. see tex.stackexchange.com/a/69854/1090 – David Carlisle Sep 1 '17 at 8:03
• See my answer: I using $ and $ to have what you want. This is what @DavidCarlisle says – koleygr Sep 1 '17 at 8:05

Edit:

\documentclass{article}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,shapes}

\makeatletter
\xdef\myfsize{\f@size}
\makeatother

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawRect}[4]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[#3] ([yshift={\myfsize/1.5},xshift=#4]#1.north west) rectangle ([xshift=-#4]#2.south east);
\end{tikzpicture}
}
\begin{document}
$\begin{cases} \tikzmark{a}A x+ \tikzmark{c}B y & = \tikzmark{e} C\\ D\tikzmark{b} x+E\tikzmark{d} y & = F\tikzmark{f} \DrawRect{a}{b}{green}{4pt}\DrawRect{c}{d}{red}{4pt}\DrawRect{e}{f}{black}{4pt} \end{cases}$
\end{document}


The above gives the same results but finds automatically the fontsize to use it as yshift and has an extra argument that reduces the box on x axis (a negative value will increase it)

Source of code that I changed: https://tex.stackexchange.com/a/35718/120578

\documentclass{article}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,shapes}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawRect}[3]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[#3] ([yshift=8pt,xshift=4pt]#1.north west) rectangle ([yshift=0pt,xshift=-4pt]#2.south east);
\end{tikzpicture}
}
\begin{document}

$\begin{cases} \tikzmark{a} A x+ \tikzmark{c} B y & = \tikzmark{e} C\\ D \tikzmark{b} x+E\tikzmark{d} y & = F\tikzmark{f} \DrawRect{a}{b}{green}\DrawRect{c}{d}{red}\DrawRect{e}{f}{black} \end{cases}$
\end{document}


Can be improved but I adding it to get my comment's point.

Result: