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?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityEdit:
\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
Old answer A fast solution:
\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:
tikzpicture
to print your equation and functionalityrememberpictureoverlay
and then you can add boxes arrows, symbols... whatever you want to make it appear as you wish$$...$$
that is not LaTeX syntax$$
is primitive tex syntax but it should not be used in a latex document. see tex.stackexchange.com/a/69854/1090\[
and\]
to have what you want. This is what @DavidCarlisle says