UPDATE i've since published a LaTeX style file based on the below finds, CXLTX Position Absolute, part of the (incipient) CXLTX Style Collection, which makes it easier to precisely position one-liners on the page. pull requests: awesome!

i'm trying to position text à la CSS position: absolute and found the textpos package which basically works great. in the documentation they say (p4) that "the box that is positioned by the \textblock environment is a tight fit to the block of text (or other material) inside it`, but when i try



% not needed, but makes for easier measuring:


\begin{textblock}{150}[1,0](500,000)\flushright helo\end{textblock}
\begin{textblock}{150}[1,0](500,200)\flushright world\end{textblock}
\begin{textblock}{150}[1,0](500,400)\flushright gX\end{textblock}
\begin{textblock}{150}[1,0](700,400)\flushright .\end{textblock}




what i get is

enter image description here

so while the right edges of the boxes is correctly positioned at 500 (tenths mm) and the top edges as such correctly at, respectively, 0, 200, and 400, and the lower edges of the boxes do wrap tightly around the descenders as advertised, the boxes are still 8mm high – how can i have them wrap as advertised?


now this was an easy one... sometimes writing down a question leads you to solving a problem. for the record:

i had incorrectly assumed that putting something into an textpos textblock would act a bit like putting stuff onto a page or into a minipage, i.e., paragraph 'skips' would be silently elided.

not so.

first, setting


brought a reduction of the box heights; then,


yielded this:

enter image description here

which is sort of counter-intuitive—i mean, zero space between paragraphs should equal 'zero whitespace above paragraph', no?

Note in the real world, you would not want to set \parskip globally to the surprising value shown here, but rather make it appear locally, inside the textblock environments (and maybe cast that as a new macro).

Update as a follow-up, i've defined a handy macro that simplifies the absolute positioning of text. here it is:

\newcommand{\textposstrut}{{\color{blue}\vrule height\textposstrutheight width\textposstrutwidth depth\textposstrutdepth}}


now, when you do

\begin{textblock}{150}[1,0.5](500,000)\flushright\textposstrut helo\end{textblock}
\begin{textblock}{150}[1,0.5](500,200)\flushright\textposstrut world\end{textblock}
\begin{textblock}{150}[1,0.5](500,400)\flushright\textposstrut gX\end{textblock}
\begin{textblock}{150}[1,0.5](700,400)\flushright\textposstrut .\end{textblock}


(within the same document setup as shown in the question, above) you get

enter image description here

where the gX in the bottom left demonstrates that the text has indeed been positioned correctly (the baseline of the right edge of the X being at ( 30mm, 40mm ) measured from the edge of the document).

note that the strut as defined here has a visible width for the sake of demonstration; also, its height and depth have been carefully tailored so as to match the specific font dimensions used here—when you switch to another font, chances are that both \textposstrutheight and -depth will have to be re-defined.

  • Half of your problems would be solved if you don't set \parskip to a non zero value: have mercy of your readers. ;-) – egreg Mar 25 '14 at 17:41
  • i do not normally do this; in the general case, i think using either whitespace between paragraphs or indenting the first line are the best ways to indicate paragraph breaks. however, parskip = parindent = 0 does have its uses. here it is done solely to demonstrate how parskip interacts with textpos boxes in unexpected ways. – flow Mar 25 '14 at 17: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.