Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I cannot manage to get the following command to work. I have a beamer presentation with several slides on a frame. Then I want to use the pdfcomment package to show some comments on the slides. Usually this works fine, but on frames with multiple steps, it's annoying, because the comments appear on each slide (and they are visible on each slide, even if the respective text has not appeared yet!). So my solution is the following:

I calculate the slide number on the frame and the use the \only command to show the comment only of the last slide of the frame. In my example, this is the fifth slide on the frame. The command works like this:

\only<5>{\pdfcomment[style=note,author=name]{comment...}}

However, as it is quite annoying to find the last slide on the frame by hand, I tried to define a command, which reads:

\newcommand{\pdfnote}[2]{%
\setcounter{slidenum}{\insertpagenumber}
\addtocounter{slidenum}{1}
\addtocounter{slidenum}{-\insertframestartpage}
\only<\value{slidenum}>{\pdfcomment[style=note,author=#1]{#2}}%
}

Basically it uses the counter slidenum, which contains the last slide on the frame, e.g. 2. The routine works, except that the pdfcomment is visible on all slides! It's kind of weird, because when I simply replace \value{slidenum} with 2, it works. And I just added the line \arabic{slidenum} just before the \only command so check if the counter is correct. Furthermore I replaced the \pdfcomment by a simple text. That's working as well.

By the way: \only does work, \onslide does not work at all for pdfcomment. I really don't understand. Do you have any ideas? Below you find a complete example.

\documentclass{beamer}

\usepackage[draft,author=admin]{pdfcomment}

\definestyle{note}{icon=Comment,color=white,open=true}
\definestyle{warning}{icon=Comment,color=red,open=true}

\newcounter{slidenum}

\newcommand{\pdfnote}[2]{%
\setcounter{slidenum}{\insertpagenumber}
\addtocounter{slidenum}{1}
\addtocounter{slidenum}{-\insertframestartpage}
%\arabic{slidenum}
\only<\value{slidenum}>{\pdfcomment[style=note,author=#1]{#2}}%
}

\begin{document}

\begin{frame}

test\\ \pause
next line
\pdfnote{me}{my comment}

\end{frame}

\end{document}
share|improve this question
add comment

2 Answers

I didn't test exactly the reason why it doesn't work but it is apparent that the calculations fall short and it is being shown on every slide, although the number shown is correct.

However, you can use the internal counter of beamer which is the beamerpauses counter. As the name implies it is incremented whenever there is an overlay specification is given.

\documentclass{beamer}
\usepackage[draft,author=admin]{pdfcomment}
\definestyle{note}{icon=Comment,color=white,open=true}
\definestyle{warning}{icon=Comment,color=red,open=true}
\newcommand{\pdfnote}[2]{%
\onslide*<\value{beamerpauses}>{\pdfcomment[style=note,author=#1]{#2}}%
}
\begin{document}
\begin{frame}
test\\ \pause
next line
\pdfnote{me}{comment 1}
\\ \pause
adsf
\pdfnote{me}{comment 2}
\end{frame}
\end{document}

I have changed \only to \onslide* to show yet another possibility which is effectively the same thing as stated in the manual.

share|improve this answer
    
Thanks for your reply. It's kind of working, but only if I actually use \pause for overlays. In practive I am usually using <number> (e.g. \item<3->) and so on. beamerpauses does not notice those overlays and thus the counter stays 1 all the time and the comment appears alsways on the first slide, not on the last, as intended. –  blitzo Feb 29 '12 at 15:07
    
I don't have a general solution yet for this. –  percusse Mar 4 '12 at 15:49
add comment

In the following, I define a \thelastslideofframe command that, after the second pdflatex run, expands to the number of slides in the current frame. It can be fed into \only<>and so on and works with \pause as well as with explicit overlay specifications.

\documentclass{beamer}

\usepackage[draft,author=admin]{pdfcomment}

\definestyle{note}{icon=Comment,color=white,open=true}
\definestyle{warning}{icon=Comment,color=red,open=true}

\makeatletter
\newcommand\thelastslideofframe{%
  \the\numexpr0\beamer@endpageofframe-0\beamer@startpageofframe+1%
}
\makeatother
\newcommand{\pdfnote}[2]{%
  \only<\thelastslideofframe>{\pdfcomment[style=note,author=#1]{#2}}%
}

\begin{document}

\begin{frame}
  \onslide<3>{This is slide 3, the last slide of this frame!\par}
  test\\ \pause
  next line
  \pdfnote{me}{My comment, on last slide only (after second compilation)}
\end{frame}

\end{document}
share|improve this answer
    
I have found a small glitch, though: If one reduces the number of slides, \thelastslideofframe still contains the old value on the next pdflatex run. In this run, we insert content (the PDF comment) with \only<\thelastslideofframe>, so that after this run the number of slides is again the original value of \thelastslideofframe. Solution/Workaround: Delete the .nav auxiliary file. –  Daniel Jan 9 at 14:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.