I am trying to fill out a pdf form using LaTeX with the package pdfoverlay and textpos. The problem When I specify a coordinate with textpos and give it some text, the text will start at the coordinate, but I want the end of the text to end at the coordinate (you can see on the picture I have specified a coordinate where the form ends, but instead of the text ending there it begins)

I have asked others about this and there was some confusion, someone thought I was trying to create a form, I am not, the underline and all is already part of the pdf I am filling out.

  • Note: I am open to any suggestions regarding a better method to do this so please be creative with solutions. – user224041 Sep 6 '20 at 22:40
  • 1
    Try \llap{AAAA} – Donald Arseneau Sep 7 '20 at 0:10
  • It works perfectly! Thank you so much Mr. Arseneau :) – user224041 Sep 7 '20 at 9:43

You didn't show what you are doing exactly, but if the left edge of the text is being placed where you want the right edge, then using \llap{AAAA} will put the right edge there. That probably looks like


It is somewhat annoying that the textpos package only positions text blocks contained in the equivalent of \parbox. It would be nice to also have a type that was packaged like \makebox.

The \llap command (left overlap) comes from plain TeX, and it does not follow the paragraph parameters of the textblock, so the width parameter is irrelevant, as is the default centering performed by the textblock. (\llap is a bare \hbox, and goes on the vertical list instead of starting a paragraph.)

Alternatively, to do the job using the positioning parameters of textblock, you have to get a handle on the right edge of the text, and the easiest way is to push it to the right edge of the text block. So then

  \raggedleft AAAAA

The width (\textwidth) just has to be anything wider than the text. The [1, indicates positioning at the right edge of the text, and \raggedleft pushes the text to the right edge.

I would probably do

\newcommand\fillin[2]{% #1 = position, #2 = text
     \raggedleft #2
  • Yep this is exactly what I did. I already had a macro so I just added this to it. Thank you very much Mr. Arseneau. Have a good day. – user224041 Sep 8 '20 at 13:31
  • @user224041 Remember to up-vote the answer you found helpful – Norman Gray Sep 8 '20 at 14:07
  • @donald-arsenau The positioned \makebox is an interesting idea. What would that look like? \makeboxat(x,y){text} springs to mind? Or \begin{textbox}(x,y)text\end{textbox} for consistency? – Norman Gray Sep 8 '20 at 14:11
  • Mr. Gray, I'm afraid I can't do that. I am not a properly registered user, but I am considering registration, need to finish reading the Terms of Service first when I have spare time. – user224041 Sep 8 '20 at 16:00

See the textpos manual, Sect.1.3.3 Choosing the textblock reference point:

You may give an optional argument to the {textblock} environment, specifying which point in the box is to be placed at the specified point:


The coordinates ⟨ho⟩ and ⟨vo⟩ are fractions of the width and height of the text box, respectively, and state that the box is to be placed so that the reference point (⟨ho⟩,⟨vo⟩) within the box is to be placed at the point (⟨hpos⟩,⟨vpos⟩) on the page. The default specification is [0,0], indicating the top left of the box; the argument [0,1] (for example) would specify the bottom left, and [0.5,0.5] the middle.

There are further details, including how to default this, later in that section.

  • So actually, I did read through the manual many times before and found this section: I tried using this but I think its a misinterpretation of the text because actually, this is only defining where on the coordinate it should start and nothing about the text finishing there. The answer by Mr. Arseneau that I should use \llap produces the exact result that I wanted. – user224041 Sep 7 '20 at 9:42
  • Note that \begin{textblock}{2}[1,1](3,3) AAAA\end{textblock} will indeed produce a block 2 modules wide, with its bottom right corner at (3,3) but the text AAAA will be at the left-hand side of the block, ie, not at (3,3). You might want to say \hfill AAAA (or equivalent), which will put the text at the right of the box, at (3,3). The option [showboxes] might make it easier to position your text. (It might also be the case that you're using an old version of the package: the documentation notes that this feature was inconsistently implemented before v1.8). – Norman Gray Sep 7 '20 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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