ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* xpos.sty
@ 2006-08-29 15:23 Paul Jones
  2006-08-29 23:32 ` xpos.sty Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Jones @ 2006-08-29 15:23 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 2808 bytes --]

Hello,

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,
paul



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

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

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

\def\thexposition{\ifx\thepage\relax
  \noexpand\thexposition
   \else \strip@pt
  \dimexpr\pdflastxpos sp*\p@/\dimexpr 1bp\relax\relax \fi}
\def\theyposition{\ifx\thepage\relax
  \noexpand\theyposition
  \else \strip@pt
  \dimexpr(\ifnum\pdfoutput>\z@ \pdfpageheight\fi-\pdflastypos sp)%
  *\p@/\dimexpr 1bp\relax\relax \fi}
\def\thexyposition{\thexposition\space\theyposition}
\newbox\posit@box
\setbox\posit@box\box\voidb@x
\def\positionhwrite#1{%
  \global\setbox\posit@box\hbox{\unhbox\posit@box#1}%
  \ifhmode \unhbox\posit@box \fi}

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

\def\positiontop#1{\positionhwrite{\vadjust pre{\positionwrite{#1}}}}
\def\positionbottom#1{\positionhwrite{\vadjust{\positionwrite{#1}}}}
\def\positionbaseline#1{\positionhwrite{\positionwrite{#1}}}
\newcounter{positionpar}\relax
\newenvironment{positionpar}[2]{%
  \par
  \c@positionpar=\z@
  \toks@\expandafter{\number\currentgrouplevel\relax
         \advance\c@positionpar\@ne
         \ifhmode\expandafter\positiontop
                     \else\expandafter\positionwrite\fi{#1}}%
  \edef\posit@level{\the\toks@}%
  \def\position@endhook{#2}}{\ifhmode\par\fi\positionwrite{\position@endhook
}}

[-- Attachment #1.2: Type: text/html, Size: 3575 bytes --]

[-- Attachment #2: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-02  2:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-29 15:23 xpos.sty Paul Jones
2006-08-29 23:32 ` xpos.sty Hans Hagen
2006-09-02  2:44   ` xpos.sty Paul Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).