1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
\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}
|