# comment a boxed equation with a arrow

I would like to comment a variable inside a boxed equation with an arrow (like the picture a), I hope someone could help me.

I used to comment the equation by an under/over-brace, but if there is too many text, the equation will be given a large space (like the picture b). If this problem could be solved also, I would be very grateful.

This seems like a job for tikzmark:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

$\boxed{F_{\tikzmark{a}1,n}= ...}$

\begin{tikzpicture}[remember picture,overlay]
\draw[->] ([xshift=2pt,yshift=-1pt]pic cs:a) -- ++(-45:20pt) coordinate (aux);
\node[yshift=-8pt] at (aux) {we only consider 1 unknown.};
\end{tikzpicture}

\end{document}


In the previous example I boxed the expression using \boxed from amsmath but if you want fancier results, you can build the box with TikZ or use the features from tcolorbox:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\tcbuselibrary{most}

\begin{document}

$\tcbhighmath{F_{\tikzmark{a}1,n}= ...}$

\begin{tikzpicture}[remember picture,overlay]
\draw[->] ([xshift=2pt,yshift=-1pt]pic cs:a) -- ++(-45:20pt) coordinate (aux);
\node[yshift=-8pt] at (aux) {we only consider 1 unknown.};
\end{tikzpicture}

\end{document}


• @user3004698: if Gonzalo's answer satisfies you, you can consider to upvote and accept his answer that is a good way to say "thank you". Mar 6 '14 at 15:44

\documentclass{article}
\usepackage{graphicx}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor}
\def\calloutsym{%
\ensurestackMath{%
\scalebox{1.7}{\color{red}\stackunder[0pt]{\bigcirc}{\downarrow}}}%
}
\newcommand\callouttext[1]{%
\def\stacktype{S}\renewcommand\useanchorwidth{T}\stackText%
\stackunder{\calloutsym}{\scriptsize\Longstack{#1}}\stackMath%
}
\newcommand\callout[3][1.5pt]{%
\def\stacktype{L}\stackMath\stackunder[#1]{#2}{\callouttext{#3}}%
}
\begin{document}
\fbox{$\displaystyle \smash{\callout{F}{\stackunder{$1,n$}{we only consider 1 unknown}}} = \left[ \frac{\partial f}{\partial l_1}\quad \frac{\partial f}{\partial l_2}\quad \frac{\partial f}{\partial l_3} \cdots \frac{\partial f}{\partial l_n} \right]$}
\end{document}


If you don't like the circle around the "F", remove \bigcirc, and perhaps scalebox the downarrow larger, as follows:

\documentclass{article}
\usepackage{graphicx}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor}
\def\calloutsym{%
\ensurestackMath{%
\scalebox{2}{\color{red}\stackunder[2pt]{}{\downarrow}}}%
}
\newcommand\callouttext[1]{%
\def\stacktype{S}\renewcommand\useanchorwidth{T}\stackText%
\stackunder{\calloutsym}{\scriptsize\Longstack{#1}}\stackMath%
}
\newcommand\callout[3][1.5pt]{%
\def\stacktype{L}\stackMath\stackunder[#1]{#2}{\callouttext{#3}}%
}
\begin{document}
\fbox{$\displaystyle \smash{\callout{F}{\stackunder{$1,n$}{we only consider 1 unknown}}} = \left[ \frac{\partial f}{\partial l_1}\quad \frac{\partial f}{\partial l_2}\quad \frac{\partial f}{\partial l_3} \cdots \frac{\partial f}{\partial l_n} \right]$}
\end{document}


Note that since I smashed the underset, you may need some \vspace to prevent subsequent text from interfering.