I have an equation in a tikz environment and I would like to be able to highlight part of it. For example the following:
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,latexsym}
\usepackage{tikz}
\begin{document}
\tikzstyle{block} = [draw,fill=blue!60,minimum width=1.1 em, minimum height= 1em, rounded corners= 4pt]
\begin{figure}[h]
\centering
\begin{tikzpicture}
\coordinate (Eq1) at (1,2);
\coordinate (Eq2) at (1,1);
\node[block] at (1,2) (block1) {};
\node at (Eq1) {$A = B + C$};
\node at (Eq2) {$D = E + F$};
\node[block] at (0, -0.5) (block2) {Blah};
\draw[->] (block1) -- (block2);
\end{tikzpicture}
\end{figure}
\end{document}
However, it is a huge pain to by hand play around with the node placement of the blocks to highlight the corresponding part of the equation. I'd like a way to specify the node. Attempting to do such, I played around with \tikz{\node} within the equation but to no avail as follows
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,latexsym}
\usepackage{tikz}
\begin{document}
\tikzstyle{block} = [draw,fill=blue!60,minimum width=1.1 em, minimum height= 1em, rounded corners= 4pt]
\begin{figure}[h]
\centering
\begin{tikzpicture}
\coordinate (Eq1) at (1,2);
\coordinate (Eq2) at (1,1);
%\node[block] at (1,2) (block1) {};
\node at (Eq1) {$A = \tikz{ \node[fill=blue!60, rounded corners = 4pt, minimum size = 1 em]
(block1) {$B$};} + C$};
\node at (Eq2) {$D = E + F$};
\node[block] at (0, -0.5) (block2) {Blah};
\draw[->] (block1) -- (block2);
\end{tikzpicture}
\end{figure}
\end{document}
The B is no longer aligned with the other parts of the equation and the arrow is stuck in the second block. Can you suggest a good way to go about doing this? Thanks!
EDIT
Based on the first response (Thanks by the way!) I want to add that at this point I'd like to still do this all within a tikz picture. For my paired down example below I know it make senses to just do \begin\end{equation} but for my actual application I'm hoping to have a lot more going on and just this one equation arbitrarily placed in a bigger diagram. Maybe this can be done still using the usual latex equation commands but it seems more natural to approach having it within a tike picture
Best Answer
The following answer builds on your second attempt, and uses a
\tikzmark
-like command to achieve the annotation effect.Code
Output
By the way, it's recommended that you use
\tikzset
instead of the deprecated\tikzstyle
.