> This would be a solution:
> 
> Index term, and some
> text
>  21, 34, 45, 72, 89,
>        101, 103, 109
> 
> where the rule is: when the numbers exceed the text width, close the
> paragraph, then start a new, right aligned one.
> 
> So i wrote this:
> 
> ---------------------------------------------------
> \def\wordorparagraphright#1{\let\scratchWidth\relax
>   \setbox\scratchbox=\hbox{#1}\newdimen\scratchWidth
>   \scratchWidth=\wd\scratchbox
>   \ifdim\scratchWidth < 0.9\textwidth
>     \wordright{#1}%
>   \else
>     \par
>     \startalignment[flushright]#1\stopalignment
>   \fi}
> 
> \starttext
> \input sapolsky \wordorparagraphright{\it other text} \par
> \blank
> \input sapolsky \wordorparagraphright{\it other text, this time
> longer}
> \par
> \blank
> \input sapolsky \wordorparagraphright{\it other text, this time
> much much much much much much much much much much much much 
> much much much much much much much much much much longer} \par
> \stoptext
> ---------------------------------------------------
> 

This, instead, works also with registers:

-------------------------------------------------
--
\unexpanded\def\wordorparagraphright{\dosingleempty\WordOrParagraphRigh
t}

\def\WordOrParagraphRight[#1]{\groupedcommand{\setbox0\hbox\bgroup}
{\egroup\newdimen\myBoxWd\myBoxWd=\wd0
  \ifdim\myBoxWd < .7\hsize
    \wordright{\box0}%
  \else
    \startalignment[flushright]\leftskip=.3\hsize plus 1fil\unhbox0
\stopalignment
  \fi}}

\starttext
\input sapolsky \wordorparagraphright{\it other text} \par
\blank
\input sapolsky \wordorparagraphright{\it other text, this time longer}
\par
\blank
\input sapolsky \wordorparagraphright{\it other text, this time
much much much much much much much much much much much much 
much much much much much much much much much much longer} \par
\stoptext
---------------------------------------------------


A doubt: i'm using box0, is it dangerous?

I tried with scratchbox, but it doesn't work, then i moved to box0, and
it seems to work, even with a big file (with a big register too) of
mine.

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to