TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

using pdfpages as a quick and dirty pdf annotation tool to fill in a pdf based form. I do this often and am really keen to try and stick to a linux environment.

There are a lot of entries so I'd like to use a macro to summarize the code

\AddToShipoutPictureFG{\put(x_coord,y_coord){content}} command with a macro. I've tried lots of variants on the \def below but keep getting errors. Any thoughts very appreciated. (including any other routes to take with this)

An MWE looks a little like the following with somepdf in the \includepdf command replaced by the pdf form in question.



\AddToShipoutPictureFG{\put(35,555){\large X}}
\pd(150,150,{Rhubarb and crumble})
share|improve this question
Remove the \expandafter. – Ulrike Fischer Jan 21 '13 at 16:21
up vote 2 down vote accepted

Your current definition of \pd includes an incorrect usage of \put. Put is defined to take 3 arguments in a specific delimited form (from latex.ltx):

  \hb@xt@\z@{\kern#1\unitlength #3\hss}%

Using \pd(<x>,<y>,<stuff>) expands to


where \put grabs <x> as #1, <y> as #2 and \expandafter as #3. Perhaps the following definition of \pd is what you're after:

\def\pd(#1,#2,#3){% \pd(<x>,<y>,<stuff>)

which will appropriately pass #3 to \put.

Here's a complete minimal example showing the difference:

enter image description here

\usepackage{eso-pic,pdfpages}% http://ctan.org/pkg/{eso-pic,pdfpages}
\AddToShipoutPictureFG{\put(35,555){\large X}}
\pdA(150,150,{\color{red}Rhubarb and crumble})
\pdB(150,150,{\color{green}Rhubarb and crumble})
\pdB(100,100,{Crumble topping})
share|improve this answer
perfect thank you. why does the \putstuff need to be \protected? thanks – Tahnoon Pasha Jan 21 '13 at 21:39
@TahnoonPasha: Some commands should not be expanded until the actual typesetting occurs. In this case, \color. See a short discussion on this topic in Minimal \protected@edef example. – Werner Jan 21 '13 at 23:26
Hi @Werner, having tried the macro, it seems to have a problem with multiple form inputs. So if I use \pdA(50,50,{Rhubarb and Custard}) and then \pdA(150,150,{Crumble topping}) then I get "Crumble topping" for both. Do you know what is going wrong here? – Tahnoon Pasha Jan 22 '13 at 6:15
@TahnoonPasha: See the updated answer. – Werner Jan 22 '13 at 6:24
Thanks @Werner. Bizarre, that was the first thing I tried but it didn't work hence my question. Must have typed it in wrong or something. – Tahnoon Pasha Jan 22 '13 at 8:42

Your Answer


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.