2

pdfcomment with environment is not working and it's working fine with only paragraph text.

My MWE is :

\documentclass{article}
\usepackage{amsthm,xcolor}
\usepackage[subject={Top1},author={Daisy Duck},version=1,opacity=0,voffset=8pt,hoffset=-2pt]{pdfcomment}

\theoremstyle{theorem}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\def\Added#1{\pdfsquarecomment[author={Added Text:}]{#1}#1}
\def\Deleted#1{\pdfsquarecomment[author={Deleted Text:}]{#1}}
\def\Replaced#1#2{\pdfsquarecomment[author={Replaced Text: #1 with}]{#2}#2}

\def\Commentson{\let\Add\Added\let\Del\Deleted\let\Rep\Replaced}

\begin{document}
\Commentson
Thus leave \Add{open} essentially \Del{just} the \Rep{Cases}{case} of polylogarithmic $r(n)$ (beyond the general constant $r\geq 4$ noted above).

\begin{lemma}[Tannery's Theorem]\label{lem1}
If, for each $i\geq 1$, we have $\lim_{n\to\infty}f_{i}(n)=f_{i}$ and  $|f_i(n)| \leq M_i$ integer-valued sequence $(s_n)$ with $s_n\to\infty$.
\end{lemma}

.... and ....

\begin{lemma}[Tannery's \Del{t}heorem]\label{lem2} %%% Heading is missing in the PDF file when using \Del command
If, for each $i\geq 1$, we have $\lim_{n\to\infty}f_{i}(n)=f_{i}$ and  $|f_i(n)| \leq M_i$ integer-valued sequence $(s_n)$ with $s_n\to\infty$.
\end{lemma}

\end{document}

Lemma 2 heading is missing in the PDF file, when using \Del command. How to get respective PDF file with support for Acobat Reader.

1 Answer 1

2

During the processing of the theorem title amsthm doesn't expect exotic commands like \pdfcomment. While this can probably be fixed by some expansion tricks you can also cheat and jump back into the title later just for adding the comment.

This is slightly more involved because you need to store the rest of the title (to know how far you need to jump back) and you need to call another command to actually place the comment.

The following two commands implement this approach:

% collect the comment and the rest of the title, typeset the rest of the title
\def\collect#1#2{\xdef\commentarg{#1}\xdef\collected{#2}#2}
% jump left, put a delete comment with the collected comment text, jump right
\def\retrodel{\hspace{\widthof{\collected). }*-1}\Del{\commentarg}\hspace{\widthof{\collected). }}}

MWE:

\documentclass{article}
\usepackage{amsthm,xcolor}
\usepackage[subject={Top1},author={Daisy Duck},version=1,opacity=0,voffset=8pt,hoffset=-2pt]{pdfcomment}

%\theoremstyle{theorem}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\def\Added#1{\pdfsquarecomment[author={Added Text:}]{#1}#1}
\def\Deleted#1{\pdfsquarecomment[author={Deleted Text:}]{#1}}
\def\Replaced#1#2{\pdfsquarecomment[author={Replaced Text: #1 with}]{#2}#2}

\def\Commentson{\let\Add\Added\let\Del\Deleted\let\Rep\Replaced}

\def\collect#1#2{\xdef\commentarg{#1}\xdef\collected{#2}#2}
\def\retrodel{\hspace{\widthof{\collected). }*-1}\Del{\commentarg}\hspace{\widthof{\collected). }}}

\begin{document}
\Commentson
Thus leave \Add{open} essentially \Del{just} the \Rep{Cases}{case} of polylogarithmic $r(n)$ (beyond the general constant $r\geq 4$ noted above).

\begin{lemma}[Tannery's Theorem]\label{lem1}
If, for each $i\geq 1$, we have $\lim_{n\to\infty}f_{i}(n)=f_{i}$ and  $|f_i(n)| \leq M_i$ integer-valued sequence $(s_n)$ with $s_n\to\infty$.
\end{lemma}

.... and ....

\begin{lemma}[Tannery's \collect{t}{heorem}]\label{lem2}\retrodel %%% Heading is missing in the PDF file when using \Del command
If, for each $i\geq 1$, we have $\lim_{n\to\infty}f_{i}(n)=f_{i}$ and  $|f_i(n)| \leq M_i$ integer-valued sequence $(s_n)$ with $s_n\to\infty$.
\end{lemma}

\end{document}

Result:

enter image description here

4
  • Wow. Such a nice reply.
    – MadyYuvi
    Nov 10, 2023 at 6:16
  • @Marijn: What is the mean of \collected). }*-1. I'm not understood the mean of ). }*-1.?
    – Balaji
    Dec 5, 2023 at 12:50
  • 1
    @Balaji the idea is to measure the width of the string between the insertion point of the pdfcomment and the end of the lemma title. In this example that would be the length of heorem). . The word part heorem is stored in the macro \collected by the previous call of \collect{t}{heorem}. So \collected). is the same as heorem). . We measure the width of this string using \widthof{}, i.e., \widthof{\collected). }. Then we multiply by -1, so you get a negative width (for example if the width is 56pt then the negative width is -56pt). This is the amount we need to move left.
    – Marijn
    Dec 5, 2023 at 15:08
  • 1
    Then we actually move left with \hspace{}. So \hspace{\widthof{\collected). }*-1} is the same as, for example, \hspace{-56pt}. Then you add the pdfcomment as normal with \Del{comment}, then you skip back to the right right with \hspace again, the same amount but then the positive value without the *-1.
    – Marijn
    Dec 5, 2023 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .