# Is there are way to annotate pdfs with LaTeX? [duplicate]

Possible Duplicate:
How to annotate PDF files generated by pdflatex?

Is there a way to annotate pdfs with LaTeX annotations? I mean a pdf that I do not have the source code for (or may not have even been written in LaTeX itself, for that matter).

The motivation behind my question is that I would really like to annotate my lecture notes digitally to stop me losing important notes, but the lecturer does not like the idea of releasing the source code to his notes to students. (i.e. I don't think asking for the source code went down well and I would like to not feel the need to ask another lecturer the same question if I can avoid it :-))

I could try to type them out myself but when time is limited it would be ambitious at best, to try it when there are more urgent work I need to prioritise.

I use linux, my pdf viewer is okular and it mainly for maths/physics type work if that is useful information to add. It would be handy to be able to do it one way or another so I am open to any suggestions that might help out!

-

## marked as duplicate by doncherry, Kurt, Werner, Qrrbrbirlbel, cgniederDec 5 '12 at 21:56

Two possibilities: if doing "real time" (ie in the lecture) then I wouldn't bother with LaTeX annotations and would just annotated the PDF directly using a PDF annotation tool (my favourites are xournal for Linux and GoodNotes for iPad). If afterwards, simply load the PDF with something like pdfpages and "write on top" using normal LaTeX commands. –  Loop Space Dec 5 '12 at 17:40
This question is very similar to tex.stackexchange.com/questions/6306/…. Please take a look at it as the information there might help you. If so, that's great, and we'll probably close this question as a duplicate just to keep the place tidy and to help people find answers quickly. If not, please edit your question here to explain why so that people can better focus their attention to help you. –  doncherry Dec 5 '12 at 17:42
pdf pages? Can you elaborate? @AndrewStacey –  Magpie Dec 5 '12 at 17:43
There's a package on CTAN called pdfpages: ctan.org/pkg/pdfpages and it defines a command where you include pages from a PDF as the background to some pages which you can then draw on top of using normal LaTeX commands. I use it for filling in PDF forms and I use TikZ to place the text at specific points relative to the form. The documentation for pdfpages is worth a look to see if it would do what you want. –  Loop Space Dec 5 '12 at 17:48
@Magpie That is a difference, of course. It looks to me like the OP over there was looking for a way to annotate finished PDFs as well, so the top answer (pdfcomment) actually doesn't address the problem. Many of the other answers address that problem though, it seems. I guess @Andrew could add his answer over there as well. (Btw, Kurt's edit was perfectly valid, perhaps except for the conversion of British spelling to American, but I'm sure that was an honest mistake on his side.) –  doncherry Dec 5 '12 at 17:52

Here's an example using pdfpages to load the PDF as a background with TikZ to draw on top of it. The following code will complain about a missing image (tikzmark_example.pdf) but hopefully will give you the idea of what I was saying in the comments. I've left the grid in place as that's how I figure out the coordinates. This is adapted from code I use to "fill in" PDF forms by writing on top of them - in other situations I'd probably end up with a different set of helper macros to make it easier to place the annotations.

\documentclass{article}
%\url{http://tex.stackexchange.com/q/85651/86}
\usepackage[svgnames]{xcolor}
\usepackage{pdfpages}
\usepackage{tikz}

\tikzset{
every node/.style={
anchor=mid west,
}
}

\makeatletter
\pgfkeys{/form field/.code 2 args={\expandafter\global\expandafter\def\csname field@#1\expandafter\endcsname\expandafter{#2}}}

\newcommand{\place}[3][]{\node[#1] at (#2) {\csname field@#3\endcsname};}
\makeatother

\newcommand{\xmark}[1]{\node at (#1) {X};}

\begin{document}

\foreach \mykey/\myvalue in {
ctsfn/{Defined in Week 1},
metsp/{Defined in Week 3},
} {
\pgfkeys{/form field={\mykey}{\myvalue}}
}

\includepdf[
pages=1,
picturecommand={%
\begin{tikzpicture}[remember picture,overlay]
%%% The next lines draw a useful grid - get rid of them (comment them out) on the final version
\draw[gray] (current page.south west) grid (current page.north east);
\foreach \k in {1,...,28} {
\path (current page.south east) ++(-2,\k) node {\k};
}
\foreach \k in {1,...,20} {
\path (current page.south west) ++(\k,2) node {\k};
}
%%% grid code ends here
\tikzset{every node/.append style={fill=Honeydew,font=\large}}
\place[name=ctsfn]{14cm,17cm}{ctsfn}
\place[name=metsp]{11cm,9cm}{metsp}
\draw[ultra thick,blue,->] (ctsfn) to[out=135,in=90] (9cm,17.3cm);
\draw[ultra thick,blue,->] (metsp) to[out=155,in=70] (6cm,9cm);
\end{tikzpicture}
}
]{tikzmark_example.pdf}

\end{document}


The result of the above is:

-
That looks like the sort of thing I need! Thanks. Can you advise how to get rid of the square grid though? –  Magpie Dec 5 '12 at 22:35
@Magpie I've added some comments to the code as to where the grid bit is. –  Loop Space Dec 5 '12 at 22:47

Although there might be a way to comment third party PDFs by using LaTeX, this is not a usefull way.

There are lots of software to deal with your needs, but more on the windows side. Under Linux, I employ flpsed, http://www.ecademix.com/JohannesHofmann/flpsed.html .

-