While explaining the idea product of two negative numbers I wanted to highlight a vertical part of the display to emphasize on the factors that are being multiplied by:
\documentclass[letterpaper]{article}
\usepackage{fullpage}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\newcommand{\red}[1]{%
{\color{OrangeRed}#1}}
\begin{document}
\begin{equation*}
\left.\begin{array}{cc}
-2\cdot \red{2}=& -4 \\
-2\cdot \red{1}=& -2 \\
-2\cdot \red{0}=& 0
\end{array}\right\} \text{\small Product increases by 2 each time.}
\end{equation*}
\end{document}
This gives:
So I chose to use a color but then I had also wanted to achieve something like the following:
I am not interested in the yellow red bordered box. What am looking for is an arrow pointing on the red numbers with a vertical border around them as shown and the possibility of adding a node with text in the same format shown aligned with the word "Product".
Edit
Can I use this method to achieve this:
Best Answer
To accomplish this task you can make use of the
tikzmark
macro. This solution allows to get:The code:
Notice that you need to compile twice.
Inside the
tikzset
there is the definition of the style of the picture to be drawn (remember picture with id
) then the definition and the writing on the the.aux
of the id and position of the mark. Anyway, to get a better explanation, you can refer to https://tex.stackexchange.com/a/50054/13304. Finally, the commands that you need to use inside your document,\tikzmarkin
and\tikzmarkend
are defined.For this purpose I adopted the same trick of Mark a pseudocode block and insert comments near it: the insertion of an anchor inside the
\tikzmarkin
macro to subsequently used it as reference to insert the annotation. What changes in the previous MWE?In the preamble you should add:
The
\tikzmarkin
should be improved as:where the relevant new part is just
node [anchor=base] (#1){}
.Finally, the
document
:The last part is the one needed to insert the annotation: first I defined a coordinate where to insert it based on the anchor previously saved (to accomplish this, it is important that the
tikzpicture
has as optionsremember picture,overlay
). The last command:draws the arrow: the starting point is the coordinate of the annotation and the final point should be computed knowing that the reference anchor
a
is placed on the top left of the red rectangle.This will lead to:
One final remark: I think should be better to insert a
\linebreak
after thetikzpicture
to avoid that the annotation will be placed too nearly the subsequent text.