Debian Codegraph @

texmf-dist/doc/latex/pdfcomment/example_math_markup.tex

raw
1 \documentclass[pagesize,11pt,leqno]{scrartcl}
2 \usepackage[english]{babel}
3 \usepackage[latin1]{inputenc}
4 \usepackage[T1]{fontenc}
5 \usepackage{lmodern}
6 \usepackage[svgnames,rgb]{xcolor}
7 \usepackage{listings}
8 \usepackage[author={Josef Kleber},subject={Math test},color=Khaki]{pdfcomment}
9 \begin{document}
10 \defineavatar{Joe}{author=Joe,color=yellow}
11 \defineavatar{Bob}{author=Bob,color=green}
12 \setlength{\parindent}{0pt}
13 \addtokomafont{section}{\normalfont\normalcolor\bfseries}
14 \setkomafont{title}{\normalfont\normalcolor\bfseries}
15 \author{Josef Kleber}
16 \title{Using \texttt{\string\pdfmarkupcomment}\ in math mode}
17 \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,[,]}}
18 \definestyle{mathpopup}{author={},subject={},color=NavajoWhite,markup=Highlight}
19 \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}%
20 \maketitle
21 \section{Simple formulas}
22 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:
23
24 \[\pdfmarkupcomment[id=1,style=mathpopup,mathstyle=\displaystyle,open=true]{f(x)=\prod_{i=1}^{n}\left(i-\frac{1}{2i}\right)}{comment}\]
25
26 \bigskip
27 Of course, you can only comment parts of a formula:
28
29 \bigskip
30 \begin{tabular}{cc}
31 \begin{minipage}{0.26\linewidth}
32 \[(a+b=c)^{\pdfmarkupcomment[style=mathpopup]{d+e}{comment}}\]
33 \end{minipage} &
34 \begin{minipage}{0.68\linewidth}
35 \begin{lstlisting}
36 \[(a+b=c)^{\pdfmarkupcomment[style=mathpopup]
37 {d+e}{comment}}\]
38 \end{lstlisting}
39 \end{minipage}
40 \end{tabular}
41
42 \bigskip
43 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})
44
45 \bigskip
46 \begin{tabular}{cc}
47 \begin{minipage}{0.25\linewidth}
48 \[(a+b=c)^{\pdfmarkupcomment[style=mathpopup,mathstyle=\scriptstyle]{d+e}{comment}}\]
49 \end{minipage} &
50 \begin{minipage}{0.68\linewidth}
51 \begin{lstlisting}
52 \[(a+b=c)^{\pdfmarkupcomment[style=mathpopup,
53 mathstyle=\scriptstyle]{d+e}{comment}}\]
54 \end{lstlisting}
55 \end{minipage}
56 \end{tabular}
57
58 \bigskip
59 Of course, it also works with equations:
60
61 \bigskip
62 \begin{tabular}{cc}
63 \begin{minipage}{0.41\linewidth}
64 \begin{equation}
65 \pdfmarkupcomment[style=mathpopup,mathstyle=\displaystyle]{\sum_{i=1}^{n}i=\frac{1}{2}n\cdot(n+1)}{comment}
66 \end{equation}\label{eq:display}
67 \end{minipage} &
68 \begin{minipage}{0.52\linewidth}
69 \begin{lstlisting}
70 \begin{equation}
71 \pdfmarkupcomment[style=mathpopup,
72 mathstyle=\displaystyle]
73 {\sum_{i=1}^{n}i=\frac{1}{2}n
74 \cdot(n+1)}{comment}
75 \end{equation}\label{eq:display}
76 \end{lstlisting}
77 \end{minipage}
78 \end{tabular}
79
80 \bigskip
81 In formula \ref{eq:display} \texttt{mathsytle=\string\displaystyle} was used.
82
83 \section{Complex formulas}
84 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:
85
86 \bigskip
87 \begin{tabular}{cc}
88 \begin{minipage}{0.4\linewidth}
89 \begin{eqnarray*}
90 \pdfmarkupcomment[style=mathpopup]{\mathrm{left}}{comment} &
91 \pdfmarkupcomment[style=mathpopup]{\mathrm{middle}}{comment} & \pdfmarkupcomment[style=mathpopup]{\mathrm{right}}{comment}\\
92 \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}
93 \end{eqnarray*}
94 \end{minipage} &
95 \begin{minipage}{0.53\linewidth}
96 \begin{lstlisting}
97 \begin{eqnarray*}
98 \pdfmarkupcomment[style=mathpopup]
99 {\mathrm{left}}{comment} &
100 \pdfmarkupcomment[style=mathpopup]
101 {\mathrm{middle}}{comment} &
102 \pdfmarkupcomment[style=mathpopup]
103 {\mathrm{right}}{comment}\\
104 \pdfmarkupcomment[style=mathpopup,
105 mathstyle=\displaystyle]
106 {\frac{1}{\sqrt{n}}}{comment} = &
107 \pdfmarkupcomment[style=mathpopup,
108 mathstyle=\displaystyle]
109 {\frac{\sqrt{n}}{n}}{comment} = &
110 \pdfmarkupcomment[style=mathpopup,
111 mathstyle=\displaystyle]
112 {\frac{n}{n\sqrt{n}}}{comment}
113 \end{eqnarray*}
114 \end{lstlisting}
115 \end{minipage}
116 \end{tabular}
117 \end{document}