From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/30566 Path: news.gmane.org!not-for-mail From: "Paul Jones" Newsgroups: gmane.comp.tex.context Subject: xpos.sty Date: Tue, 29 Aug 2006 11:23:05 -0400 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0358206368==" X-Trace: sea.gmane.org 1156865028 19128 80.91.229.2 (29 Aug 2006 15:23:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2006 15:23:48 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Tue Aug 29 17:23:39 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1GI5R1-00020N-Te for gctc-ntg-context-518@m.gmane.org; Tue, 29 Aug 2006 17:23:28 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 606AA1FD30; Tue, 29 Aug 2006 17:23:27 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 04113-06; Tue, 29 Aug 2006 17:23:20 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D02AE1FD4A; Tue, 29 Aug 2006 17:23:19 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 33A551FD4A for ; Tue, 29 Aug 2006 17:23:17 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 04070-06-3 for ; Tue, 29 Aug 2006 17:23:14 +0200 (CEST) Original-Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.229]) by ronja.ntg.nl (Postfix) with SMTP id D806A1FD30 for ; Tue, 29 Aug 2006 17:23:13 +0200 (CEST) Original-Received: by wr-out-0506.google.com with SMTP id i21so506880wra for ; Tue, 29 Aug 2006 08:23:12 -0700 (PDT) Original-Received: by 10.90.54.20 with SMTP id c20mr1651169aga; Tue, 29 Aug 2006 08:23:12 -0700 (PDT) Original-Received: by 10.90.67.7 with HTTP; Tue, 29 Aug 2006 08:23:05 -0700 (PDT) Original-To: ntg-context@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:30566 Archived-At: --===============0358206368== Content-Type: multipart/alternative; boundary="----=_Part_6971_27205667.1156864985810" ------=_Part_6971_27205667.1156864985810 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 }} ------=_Part_6971_27205667.1156864985810 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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}}

------=_Part_6971_27205667.1156864985810-- --===============0358206368== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context --===============0358206368==--