TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

Is it possible to extract the coordinates of where LaTeX places an item? I want to be able to tell what page and where on that page LaTeX placed a figure.

share|improve this question

migrated from stackoverflow.com Jan 24 '12 at 7:08

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted

The zref package provides \zsavepos{<label>} using the savepos module

\usepackage[savepos]{zref}% http://ctan.org/pkg/zref

This allows one to place a regular \label-style label, this time using \zsavepos{<label>} and retrieve the (x,y) coordinates using \zposx{<label>} and \zposy{<label>}. Here is a minimal example:

(x,y) coordinates of a label

\usepackage[savepos]{zref}% http://ctan.org/pkg/zref
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rhoncus, 
mi in interdum dignissim, urna purus rutrum est, vel sodales elit mi ornare 
tortor. Praesent malesuada pulvinar nulla. Integer mattis tempus mi vel 
accumsan. Maecenas commodo, ligula dictum interdum sollicitudin, elit justo 
eleifend velit, at molestie ligula turpis vel risus. Sed consequat ornare 
pellentesque. Curabitur congue sollicitudin semper. \zsavepos{mark1}Nunc ac mi semper nibh 
placerat euismod sed sit amet nibh. Nulla neque magna, vestibulum at molestie 
ac, condimentum et tortor. Nunc et turpis congue augue dapibus pulvinar. 
Phasellus sagittis ipsum eget mauris congue ac condimentum tellus porttitor. 
Pellentesque habitant morbi tristique senectus et netus et malesuada fames 
ac turpis egestas. \zsavepos{mark2}Sed neque dui, laoreet porttitor lacinia vehicula, 
condimentum ut dui. Phasellus viverra sollicitudin est a consectetur. 
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere 
cubilia Curae;

\verb|mark1:| (x,y)=(\zposx{mark1}sp,\zposy{mark1}sp)=(\the\dimexpr\zposx{mark1}sp\relax,\the\dimexpr\zposy{mark1}sp\relax) \par
\verb|mark2:| (x,y)=(\zposx{mark2}sp,\zposy{mark2}sp)=(\the\dimexpr\zposx{mark2}sp\relax,\the\dimexpr\zposy{mark2}sp\relax)


The result is given in scaled points (or sp), measured horizontally from the left of the page border, and vertically from the bottom of the page border.

Identifying the page that some label is on is already supported by LaTeX's default \label-\ref system using

% ... <stuff>
% ... <stuff>

zref also supports this, but since LaTeX does this by default, there's nothing more needed.

Since these methods use the \label-\ref system of LaTeX, it requires at least two compilations in order to be accurate.

share|improve this answer
It is difficult to guess what the OP want to do with the info, but it maybe usefull to add varioref to your answer. – Danie Els Jan 24 '12 at 7:50

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.