\documentclass[pagesize,11pt,leqno]{scrartcl}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[svgnames,rgb]{xcolor}
\usepackage{listings}
\usepackage[author={Josef Kleber},subject={Math test},color=Khaki]{pdfcomment}
\begin{document}
\defineavatar{Joe}{author=Joe,color=yellow}
\defineavatar{Bob}{author=Bob,color=green}
\setlength{\parindent}{0pt}
\addtokomafont{section}{\normalfont\normalcolor\bfseries}
\setkomafont{title}{\normalfont\normalcolor\bfseries}
\author{Josef Kleber}
\title{Using \texttt{\string\pdfmarkupcomment}\ in math mode}
\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny,basicstyle=\ttfamily\small,frame=single,backgroundcolor=\color{LightGoldenrodYellow},keywordstyle=\color{Blue},emph={mathstyle,style}, emphstyle=\color{Tomato},emph={[2]mathpopup},emphstyle={[2]\color{SeaGreen}},morekeywords={pdfmarkupcomment,[,]}}
\definestyle{mathpopup}{author={},subject={},color=NavajoWhite,markup=Highlight}
\hypersetup{pdfauthor={Josef Kleber},pdftitle={Using \textbackslash{}pdfmarkupcomment in math mode},pdfsubject={An example file for demonstrating the usage of \textbackslash{}pdfmarkupcomment in math mode},pdfborder={0 0 0},linkcolor=blue,citecolor=blue}%
\maketitle
\section{Simple formulas}
PDF annotations work in inline formula ($\pdfmarkupcomment[style=mathpopup]{\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)}{comment}$), as well as in display mode:

\[\pdfmarkupcomment[id=1,style=mathpopup,mathstyle=\displaystyle,open=true]{f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)}{comment}\]

\bigskip
Of course, you can only comment parts of a formula:

\bigskip
\begin{tabular}{cc}
\begin{minipage}{0.26\linewidth}
\[(a+b=c)^{\pdfmarkupcomment[style=mathpopup]{d+e}{comment}}\]
\end{minipage} &
\begin{minipage}{0.68\linewidth}
\begin{lstlisting}
\[(a+b=c)^{\pdfmarkupcomment[style=mathpopup]
{d+e}{comment}}\]
\end{lstlisting}
\end{minipage}
\end{tabular}

\bigskip
As you can see the size of the PDF annoation is too big! The math content is set into a box to measure the size. Unfortunately, the math context gets lost, which results in a wrong size, as the math snippets are set as inline formula into the box by default. You can correct this with the option \texttt{mathstyle} (\texttt{\string\textstyle, \string\displaystyle, \string\scriptstyle, \string\scriptscriptstyle}) 

\bigskip
\begin{tabular}{cc}
\begin{minipage}{0.25\linewidth}
\[(a+b=c)^{\pdfmarkupcomment[style=mathpopup,mathstyle=\scriptstyle]{d+e}{comment}}\]
\end{minipage} &
\begin{minipage}{0.68\linewidth}
\begin{lstlisting}
\[(a+b=c)^{\pdfmarkupcomment[style=mathpopup,
mathstyle=\scriptstyle]{d+e}{comment}}\]
\end{lstlisting}
\end{minipage}
\end{tabular}

\bigskip
Of course, it also works with equations:

\bigskip
\begin{tabular}{cc}
\begin{minipage}{0.41\linewidth}
\begin{equation}
\pdfmarkupcomment[style=mathpopup,mathstyle=\displaystyle]{\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)}{comment}
\end{equation}\label{eq:display}
\end{minipage} &
\begin{minipage}{0.52\linewidth}
\begin{lstlisting}
\begin{equation}
\pdfmarkupcomment[style=mathpopup,
mathstyle=\displaystyle]
{\sum_{i=1}^{n}i=\frac{1}{2}n
\cdot(n+1)}{comment}
\end{equation}\label{eq:display}
\end{lstlisting}
\end{minipage}
\end{tabular}

\bigskip
In formula \ref{eq:display} \texttt{mathsytle=\string\displaystyle} was used.

\section{Complex formulas}
If you use more complex environments like \texttt{eqnarry*}, you can no longer comment the complete formula, as this would break the internals of the environment. Remember that you can only comment, what you can put into a math box (\${}math stuff\${}). Therefore, you can only comment parts of the complex formula:

\bigskip
\begin{tabular}{cc}
\begin{minipage}{0.4\linewidth}
\begin{eqnarray*}
\pdfmarkupcomment[style=mathpopup]{\mathrm{left}}{comment} & 
\pdfmarkupcomment[style=mathpopup]{\mathrm{middle}}{comment} & \pdfmarkupcomment[style=mathpopup]{\mathrm{right}}{comment}\\
\pdfmarkupcomment[style=mathpopup,mathstyle=\displaystyle]{\frac{1}{\sqrt{n}}}{comment} = & \pdfmarkupcomment[style=mathpopup,mathstyle=\displaystyle]{\frac{\sqrt{n}}{n}}{comment} = & \pdfmarkupcomment[style=mathpopup,mathstyle=\displaystyle]{\frac{n}{n\sqrt{n}}}{comment}
\end{eqnarray*}
\end{minipage} &
\begin{minipage}{0.53\linewidth}
\begin{lstlisting}
\begin{eqnarray*}
\pdfmarkupcomment[style=mathpopup]
{\mathrm{left}}{comment} & 
\pdfmarkupcomment[style=mathpopup]
{\mathrm{middle}}{comment} & 
\pdfmarkupcomment[style=mathpopup]
{\mathrm{right}}{comment}\\
\pdfmarkupcomment[style=mathpopup,
mathstyle=\displaystyle]
{\frac{1}{\sqrt{n}}}{comment} = & 
\pdfmarkupcomment[style=mathpopup,
mathstyle=\displaystyle]
{\frac{\sqrt{n}}{n}}{comment} = & 
\pdfmarkupcomment[style=mathpopup,
mathstyle=\displaystyle]
{\frac{n}{n\sqrt{n}}}{comment}
\end{eqnarray*}
\end{lstlisting}
\end{minipage}
\end{tabular}
\end{document} 