7

My goal : I correct copies from students that I scan to pdf. I wish I could make the annotations on the scanned copies rather than on the physical paper. Today, I have to scan the copies again to have my annotations transferable to students by email. Since most of the annotations are similar, I wish to have a stock of annotations I could transfer on the copies.

I went through a lot of technologies, including many "StackExchange Questions" here. I considered pdfcomment, cooltips, fancytooltips, the OCG family (ocgx, ocgp, ocg2, ...), etc. Two tracks attracted more specifically my attention :

  • pdfcomments : I like the mouseover to see the comment, the capabillity to move the annotation around so I can have a stock on a pdf and I can copy it onto the scanned copies. This would be my choice if there was not a main drawback : it accepts only plain text when I need to use mathematical notations. (It needs selected pdf readers). Because you can move comments, you can put them on any pdf, even if it is not compiled from Latex or if you don't have the source.
  • fancytooltips : I like the mouseover to see the comment, and the capability to use LaTeX mathematical formulas and images. Drawbacks : I can't move the annotation from a pdf document to the copies. (It works with very few pdf readers.) . I am not sure whether I can put tips on non Latex pdfs.

Is there a way to have pdfcomment have images/Latex mathematical formulas (or references to formulas that can show with a mouseover) ? Or is there a way to transfer fancytooltips to a non Latex pdf ? Or are there other techniques to achieve the goal ?

  • 1
    Something like this: http://tex.stackexchange.com/questions/119988/pdftooltip-from-pdfcomment-package-using-latex-code-in-tooltip, perhaps? –  Mar 28 '16 at 08:56
  • I know of this question but : * Is it working on a non latex pdf (scanned paper for instance) ? (I guess so since it is based on pdfcomment) *does it work with maths formulas ? – user1771398 Mar 28 '16 at 09:02
  • Well, AlexG said so, yes, about three years ago. The scanned image is included, as far as I know, you can make an overlay with TikZ etc. which has your pdfcomment stuff, for example –  Mar 28 '16 at 09:05
  • Then I must try harder in this direction. You seemed to ask for the very same problem (except the non Latex pdf constraint). Did you manage to enforce the proposed solution ? – user1771398 Mar 28 '16 at 09:14
  • I think, I have, but actually, I didn't pursue that way shortly after that. The solution by AlexG is of course very good, anyway. –  Mar 28 '16 at 09:16
  • is this related ? http://tex.stackexchange.com/questions/300440/making-notes-onto-a-pdf-document/ or am i mistaken? – touhami Mar 28 '16 at 13:13
  • 1
    How do move annotations from one pdf to the other? Through the export/import of an fdf? – Ulrike Fischer Mar 28 '16 at 14:21
  • @UlrikeFischer The most simply : by copy and paste ! And everything is transferred and works fine. That is really top, but the problem is that only plain text is allowed :( – user1771398 Mar 28 '16 at 15:42
  • Do you copy the whole comment or only the content? And which pdf-viewer do you use? – Ulrike Fischer Mar 28 '16 at 17:16
  • @UlrikeFischer I select the whole comment on the first document, copy it, paste it on the destination pdf file and it's done ! – user1771398 Mar 28 '16 at 17:23
  • @touhami thanks for the reference. The problematic is near since it is on non Latex pdf and to write maths formulas. I considered once eso-pic or pdfpage to place Latex text but there is no mouseover capabilities and the enforcement can be difficult since you have to deal directly with the coordinates, not very user-friendly. I see both as primitive layers to build something on it but not something I could readily use. – user1771398 Mar 28 '16 at 17:45
  • Sigh. I asked two questions and you answered only one. – Ulrike Fischer Mar 28 '16 at 17:48
  • @UlrikeFischer Sorry ! I used PDF-X Changer Viewer or Acrobat Reader DC. Note that it works when you open both files in the same pdf reader but won't work when you cross the readers. Not a problem though. – user1771398 Mar 28 '16 at 17:57
  • I am not sure I understand. but I think if you use the idea in Ignasi answer you can use fancytooltips because you will have new document that is latex pdf. may be i will add an answer here – touhami Mar 29 '16 at 20:11
  • @touhami Feel free to do so ! Foreseeable advantage, we could use full Latex in the comments/tooltips. Drawbacks, are probably the lack of ergonomy (grid + coordinates, non movable) but this can be addressed in the future, no mouseover feature (which is a way to get rid of space constraint on the pdf to receive the comments), capability to build "stocks" of comments that can be copied here and there. But a working example will confirm or not those predictions. – user1771398 Mar 30 '16 at 01:18

2 Answers2

4

It is to some extend possible to add unicode chars (including math symbols) to pdfcomment if you compile with lualatex (^^^^2200 etc can be replaced by the real unicode input ∀) but annotation will imho never be able to show complex equations:

\documentclass{article}
\PassOptionsToPackage{unicode}{hyperref}
\usepackage{pdfcomment}
\begin{document}
  text\pdfcomment{^^^^2200 ^^^^221a a=b^^^^00b2 öäüß }
\end{document}

enter image description here

If you want complex equations you could probably use stamps (or however they are called in the english version of the reader), but they have no mouse up (perhaps it could be added with javascript).

Ulrike Fischer
  • 327,261
  • It happens that I use luaLaTeX for calculations. I can also do subscripts with this unicode solution. Thanks for this bypass that helps ! – user1771398 Mar 28 '16 at 19:30
  • Together with a web site such as http://vikhyat.net/projects/latex_to_unicode/, it is easy to transform a Latex phrase such as "\forall\epsilon>0\exists\alpha\in\mathbb{R}^{+}|x-x_0|<\alpha\Rightarrow|f(x)-f(x_0)|<\epsilon" into the plain text "∀∊>0∃α∈ℝ⁺|x-x₀|<α⇒|f(x)-f(x₀)|<∊" which is already useful. This transformation can probably be internalized with luaLatex code. Of course, as soon as you need to place text somewhere around such as in a fraction, in a limit, in a ∑, it is less convincing ; example : \frac{1}{x+1} gives (1/x+1). – user1771398 Mar 30 '16 at 01:39
4

Here is a solution.

Note: This is not about using fancytooltips but how adding elements to a non latex pdf file, named here mytest.pdf and included implicitly with mtpage environment. (if i understand)

Note the example use \usepackage[filename=tooltipy,movetips,mouseover]{fancytooltips} from fancytooltips documentation examples.

The environment mtpage include the page of number (its argument) using tikzpicture inside it you can add stuff using \mtadd command.

The command \mtadd[options passed to tikz node]{(x,y)}{stuff}.

\documentclass{article}
\usepackage[filename=tooltipy,movetips,mouseover]{fancytooltips}% from fancytooltips examples directory
\usepackage{tikz}


\iftrue % comment for final
%\iffalse % uncomment this line for final
\newenvironment{mtpage}[1]{% #1 included page's number, 
% one can do this with stepcounter  
\newpage
\begin{tikzpicture}[overlay,remember picture]
\pgfmathtruncatemacro\xmaxstep{\paperwidth/.5cm}%
\pgfmathtruncatemacro\ymaxstep{\paperheight/.5cm}%
    \node[anchor=south west] at
        (current page.south west) {\includegraphics[page=#1] {mytest.pdf}};
    \draw[blue!20!white, thin, shift={(current page.south west)}]
        (current page.south west) grid [ystep=.5cm,xstep=.5cm] (current page.north east);
    \foreach \step [evaluate=\step as \x using \step*.5] in {1,2,...,\xmaxstep} {
    \node[xshift=\step cm, yshift=1cm] at (current page.south west) {\step};};
    \foreach \step [evaluate=\step as \y using \step*.5] in {2,...,\ymaxstep} {
    \node[yshift=\step cm, xshift=1cm] at (current page.south west) {\step};};}{%
\end{tikzpicture}}
\else
\newenvironment{mtpage}[1]{%
\newpage
\begin{tikzpicture}[overlay,remember picture]
    \node[anchor=south west] at
        (current page.south west) {\includegraphics[page=#1] {mytest.pdf}};}{%
\end{tikzpicture}}
\fi
\newcommand{\mtadd}[3][text=red]{\draw[shift={(current page.south west)}] #2 node[#1] {#3};}

\begin{document}
\begin{mtpage}{1}%this is page 1
\mtadd[text=blue,fill=red!20, anchor= south west]{(6,23)}{Some text just for \tooltip{test}{1}.}
\mtadd{(13.5,18.5)}{\tooltip{bla}{1}.}
\mtadd{(16,14)}{\tooltip{foo}{1}.}
% text add no tooltips
\mtadd{(2,9.5)}{MT}
\mtadd[text=blue]{(3,9.5)}{MT}
\end{mtpage}

%\begin{mtpage}{2} %this is page 2
%\end{mtpage}
\end{document}

enter image description here enter image description here enter image description here

touhami
  • 19,520