Take the 2-minute tour ×

I have read this thread, but I don't think it addresses the same problem.

I am looking for a way to have a command in LaTeX with an interface as follows:

\placetextbox{x_in_page_percentage, y_in_page_percentage}{This is my text}

The command would place the text This is my text centered within a box that may overlap with anything else on the page, and that would be placed at the coordinates specified by the variables x_in_page_percentage and y_in_page_percentage. These variables control the location of the x in the diagram below. E.g.

      This is my text

This way, something like \placetextbox{0.5, 0.5}{This is my text} would place the text roughly on the center of the page, regardless of anything else that may be on that location.

Any thoughts how to do this?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The eso-pic package allows you to add pictures (and text) to pages as an overlay/in the foreground [as an underlay/in the background]. The specific command used to add content to the current page is \AddToShipoutPictureFG* [\AddToShipoutPictureBG*]. The starred * versions of these commands limit the output to the current page, while the unstarred versions ship its contents out to every page.

The following minimal example illustrates the technique used to answer your question in the form of a macro \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}:

\usepackage{lipsum}% For 'Lorem Ipsum' dummy text
\usepackage[pscoord]{eso-pic}% The zero point of the coordinate systemis the lower left corner of the page (the default).

\newcommand{\placetextbox}[3]{% \placetextbox{<horizontal pos>}{<vertical pos>}{<stuff>}
  \setbox0=\hbox{#3}% Put <stuff> in a box
  \AddToShipoutPictureFG*{% Add <stuff> to current page foreground

\placetextbox{0.5}{0.5}{\fbox{\Huge\textsf{This is my text.}}}%
\placetextbox{0.5}{1}{\Huge\texttt{Here is another piece of text.}}%
\placetextbox{0.1}{0.1}{\Large $\mathcal{A}_1$}%

Placement of text at absolute position on page

Other packages are also capable of doing this, including background and tikz.

share|improve this answer
Thanks @Werner. I get the following error with eso_pic: "Option clash for package eso-pic". Before that, I get a warning that says "You have requested the package ;eso-pic', but the package provides 'everyshi'" Any thoughts why I get this? –  user815423426 Aug 2 '11 at 19:42
Are you compiling the minimal example provided above? –  Werner Aug 2 '11 at 19:51
I just made it compile with the minimal example above. Thanks! Any clues why I may be getting the error "Option clash for the package eso-pic" with a more complex document? –  user815423426 Aug 2 '11 at 20:03
Nevermind. I just made it work. All I had to do is to include it in the document before other packages. Thanks a lot. It's a useful command to add copyright notices in papers, etc. –  user815423426 Aug 2 '11 at 20:12
It doesn't work for me. It moves everything on the next page... –  Karel Bílek Jun 5 '12 at 23:31
show 2 more comments

Your Answer


