Hi Hans, I'll play with the code in the next time, thanks for the example. Wolfgang Am 05.11.2009 um 17:09 schrieb Hans Hagen:
Wolfgang Schuster wrote:
whats the best method to determine the current horizontal position in the text because I want to write a commands which behaves different whether it appears at the begin, end or in the middle of the text.
pdfTeX’s savepos information are not the best method because it could take (in the worst case) to many when i have many macros in a paragraph, display math mode can give me the information i want (in combination with savepos information) but i wan't to know if there a side effects.
Example: \def\position {\bgroup \forgetdisplayskips \everymath{}% \everydisplay{}% $$\xdef\theposition{\the\predisplaysize}$$% \vskip-2\baselineskip \hskip\dimexpr\theposition-2em\relax \ifhmode\aftergroup\space\fi\aftergroup\theposition \egroup} \starttext text text \position{} text text text text text text text \position{} text \stoptext
you also need to compensate for usage like
\startnarrower text text \position{} text
text text text text text text \position{} text \stopnarrower
and other alignment cases; also, you values look wrong.
so, why not
\starttext
\xypos{first}x \hfill x\xypos{middle}x \hfill x\xypos{last}
\MPx{text:1}
\MPw{text:1}
\MPx{first} \MPx{middle} \MPx{last}
\stoptext
so, simple pos's (xy)
in mkiv the amount of them is no problem as they are stored at the lua end
test:
\def\position {\bgroup \forgetdisplayskips \everymath{}% \everydisplay{}% $$\xdef\theposition{\the\predisplaysize}$$% \vskip-2\baselineskip \hskip\dimexpr\theposition-2em\relax \ifhmode\aftergroup\space\fi\aftergroup\theposition \egroup}
\starttext
text text \position{} text
text text text text text text \position{} text
\newcount\MyPos
\def\position {\global\advance\MyPos\plusone \xypos{MyPos:\the\MyPos}% \the\dimexpr\MPx{MyPos:\the\MyPos}-\MPx{text:1}\relax}
text text \position{} text
text text text text text text \position{} text
\blackrule[width=48pt]
\blackrule[width=146pt]
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________