[NTG-context] xpos.sty

Paul Jones shagreel at gmail.com
Tue Aug 29 17:23:05 CEST 2006


Thank you again for very timely and great answers to my question yesterday.
I am finding that implementing things in Context is usually easier than I
expect.  This is very nice.  Our company decided to switch to context from
latex recently.  It seems to have been a very good decision.  Thanks for all
the work you do to make context so fun to use.

We have one last thing to get translated from latex to context.  David
Kastrup wrote a bit of latex for us (included below) that magically writes
out the absolute xy position of each paragraph and image to a log file for
us.  We pass some extra information to the commands that get put in the log
file for us, but in the end we mainly need a way to get the absolute xy
coordinates of the bounding boxes for each paragraph, each section title,
each image and each image caption.  Is there a way to get this information
with context already? Or do I need to get a new module written?

Thanks in advance for any advise,

\newwrite\posit at write
\AtBeginDvi{\openout\posit at write \jobname.pos\relax}

\long\def\posit at protected@write#1#2#3{%
       \let\protect\@unexpandable at protect
       \edef\reserved at a{\write#1{#3}}%
       \reserved at a
      \if at nobreak\ifvmode\nobreak\fi\fi

\def\positionwrite{\ifx\protect\@typeset at protect
   \else \expandafter\@gobblefour \fi \posit at protected@write\posit at write{}}

   \else \strip at pt
  \dimexpr\pdflastxpos sp*\p@/\dimexpr 1bp\relax\relax \fi}
  \else \strip at pt
  \dimexpr(\ifnum\pdfoutput>\z@ \pdfpageheight\fi-\pdflastypos sp)%
  *\p@/\dimexpr 1bp\relax\relax \fi}
\newbox\posit at box
\setbox\posit at box\box\voidb at x
  \global\setbox\posit at box\hbox{\unhbox\posit at box#1}%
  \ifhmode \unhbox\posit at box \fi}

\newtoks\posit at everypar
\posit at everypar\expandafter{\the\everypar}
\def\posit at level{\m at ne}
\everypar{\unhbox\posit at box
  \ifnum\currentgrouplevel=\posit at level
  \fi\the\posit at everypar}
\let\everypar\posit at everypar

\def\positiontop#1{\positionhwrite{\vadjust pre{\positionwrite{#1}}}}
  \c at positionpar=\z@
         \advance\c at positionpar\@ne
  \edef\posit at level{\the\toks@}%
  \def\position at endhook{#2}}{\ifhmode\par\fi\positionwrite{\position at endhook
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ntg.nl/pipermail/ntg-context/attachments/20060829/358ab77e/attachment-0001.html 

More information about the ntg-context mailing list