Re: [NTG-context] registers: how can I place a command around the whole of the page numbers of an index term?

2018-05-10 Thread MF

> 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
___

Re: [NTG-context] registers: how can I place a command around the whole of the page numbers of an index term?

2018-05-10 Thread MF
\wordright is ok until the numbers don't exceed the text width.

It manages these two cases right:

Index term, and some
text  21, 34, 45, 72

Index term, and some
text
  21, 34, 45, 72, 89

When the numbers exceed the text width, it fails:

Index term, and some
text
21, 34, 45, 72, 89, 101, 103, 109

It fails because it uses a hbox, that can't do nothing but running
beyond the right margin.

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

But it doesn't work with

---
\unprotect

\unexpanded\def\startregisterpages
   {\begingroup
\dostarttagged\t!registerpages\empty
\useregisterstyleandcolor\c!pagestyle\c!pagecolor
\registerparameter\c!pageleft}

\unexpanded\def\stopregisterpages
   {\registerparameter\c!pageright
\dostoptagged
\endgroup}

\protect

\def\wordorparagraphright#1{\let\scratchWidth\relax
 
\setbox\scratchbox=\hbox{#1}\newdimen\scratchWidth
 
\scratchWidth=\wd\scratchbox
  \ifdim\scratchWidth < 0.9\textwidth
\w
ordright{#1}%
  \else
\par
\startalignment[flushright]#1\stopalign
ment
  \fi}

\setupregister
   [index]
   [n=1,
alternative=A,
distance=0pt,
pageleft=\wordorparagraphright\bgroup,
pageright=\egroup]

\starttext
\CONTEXT\index{\ConTeXt}
\page
\LATEX\index{\LaTeX}
\page
\CONTEXT\index{\ConTeXt}
\page
\placeindex
\stoptext
---

I suppose it's related to the problem that \groupedcommand solves.
Is there a solution?

An even better solution would be:

Index term, and some
text 21, 34, 45, 72,
   89, 101, 103, 109

where the rule is: put the text until it fills the current line, than
proceed flushing the remainder of the paragraph lines to the right.

Here i tried changing \leftskip in the middle of a paragraph, but it
works globally.

I think this is even harder to implement, at least in the middle of the
register macros.
___
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
___

Re: [NTG-context] Vertical alignment in tabulate

2018-05-10 Thread Alexey Kryukov
On Thu, 10 May 2018 14:36:20 +0200
luigi scarso wrote:

> > a minimal example could help .

OK, it's simple:

\starttext
\starttabulate[|A{yes,verytolerant}p(4in)|A{flushleft,low}p|]

\NC \input{knuth}
\NC A small remark\NC\NR

\stoptabulate
\stoptext

Here I would like to get the text in the second column bottom-aligned.

-- 
Regards,
Alexey Kryukov 

Moscow State University
Faculty of History
___
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
___

Re: [NTG-context] Vertical alignment in tabulate

2018-05-10 Thread luigi scarso
On Thu, May 10, 2018 at 2:30 PM, Alexey Kryukov  wrote:

> Hi,
>
> is it possible to specify a verticall alignment for a cell contents in
> the tabulate environment? I have experimented with the A key,
> but any options related with the vertical alignment seem to be
> silently ignored here.
>
> a minimal example could help .

-- 
luigi
___
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
___

[NTG-context] Vertical alignment in tabulate

2018-05-10 Thread Alexey Kryukov
Hi,

is it possible to specify a verticall alignment for a cell contents in
the tabulate environment? I have experimented with the A key,
but any options related with the vertical alignment seem to be
silently ignored here.

-- 
Regards,
Alexey Kryukov 

Moscow State University
Faculty of History
___
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
___

Re: [NTG-context] registers: how can I place a command around the whole of the page numbers of an index term?

2018-05-10 Thread Hans Hagen

On 5/10/2018 12:35 PM, MF wrote:

This is a more polite version, that lets you restore the original
macros.

\let\origstartregisterpages=\startregisterpages%
\let\origstopregisterpages=\stopregisterpages%
\def\setupregisterpagescommand#1{%
   \unexpanded\def\startregisterpages{\origstartregisterpages#1\bgroup }
   \unexpanded\def\stopregisterpages{\egroup\origstopregisterpages}}
\def\resetregisterpagescommand{%
   \let\startregisterpages=\origstartregisterpages%
   \let\stopregisterpages=\origstopregisterpages}

\setupregister[index][n=1,alternative=A]

\starttext
\CONTEXT\index{\ConTeXt}
\page
\LATEX\index{\LaTeX}
\page
\CONTEXT\index{\ConTeXt}
\page
\setupregisterpagescommand{\wordright}
\placeindex
\page
\resetregisterpagescommand
\placeindex
\stoptext

btw, Hans, are you going to add an option to \setupregister? :)

knowing that wolfgang looked into it i just wait till he cooks up something

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] registers: how can I place a command around the whole of the page numbers of an index term?

2018-05-10 Thread Wolfgang Schuster
The following solution which adds two additional keys (pageleft and 
pageright)

is cleaner because it doesn’t have to overload commands.


\unprotect

\unexpanded\def\startregisterpages
  {\begingroup
   \dostarttagged\t!registerpages\empty
   \useregisterstyleandcolor\c!pagestyle\c!pagecolor
   \registerparameter\c!pageleft}

\unexpanded\def\stopregisterpages
  {\registerparameter\c!pageright
   \dostoptagged
   \endgroup}

\protect

\setupregister
  [index]
  [n=1,
   alternative=A,
   distance=0pt,
   pageleft=\wordright\bgroup,
   pageright=\egroup]

\starttext
\CONTEXT\index{\ConTeXt}
\page
\LATEX\index{\LaTeX}
\page
\CONTEXT\index{\ConTeXt}
\page
\placeindex
\stoptext


Wolfgang

MF 
10. Mai 2018 um 12:35
This is a more polite version, that lets you restore the original
macros.

\let\origstartregisterpages=\startregisterpages%
\let\origstopregisterpages=\stopregisterpages%
\def\setupregisterpagescommand#1{%
\unexpanded\def\startregisterpages{\origstartregisterpages#1\bgroup }
\unexpanded\def\stopregisterpages{\egroup\origstopregisterpages}}
\def\resetregisterpagescommand{%
\let\startregisterpages=\origstartregisterpages%
\let\stopregisterpages=\origstopregisterpages}

\setupregister[index][n=1,alternative=A]

\starttext
\CONTEXT\index{\ConTeXt}
\page
\LATEX\index{\LaTeX}
\page
\CONTEXT\index{\ConTeXt}
\page
\setupregisterpagescommand{\wordright}
\placeindex
\page
\resetregisterpagescommand
\placeindex
\stoptext

btw, Hans, are you going to add an option to \setupregister? :)
___
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
___


___
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
___

Re: [NTG-context] registers: how can I place a command around the whole of the page numbers of an index term?

2018-05-10 Thread MF
This is a more polite version, that lets you restore the original
macros.

\let\origstartregisterpages=\startregisterpages%
\let\origstopregisterpages=\stopregisterpages%
\def\setupregisterpagescommand#1{%
  \unexpanded\def\startregisterpages{\origstartregisterpages#1\bgroup }
  \unexpanded\def\stopregisterpages{\egroup\origstopregisterpages}}
\def\resetregisterpagescommand{%
  \let\startregisterpages=\origstartregisterpages%
  \let\stopregisterpages=\origstopregisterpages}

\setupregister[index][n=1,alternative=A]

\starttext
\CONTEXT\index{\ConTeXt}
\page
\LATEX\index{\LaTeX}
\page
\CONTEXT\index{\ConTeXt}
\page
\setupregisterpagescommand{\wordright}
\placeindex
\page
\resetregisterpagescommand
\placeindex
\stoptext

btw, Hans, are you going to add an option to \setupregister? :)
___
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
___

Re: [NTG-context] registers: how can I place a command around the whole of the page numbers of an index term?

2018-05-10 Thread MF
Thanks Wolfgang and sorry if i reply to my mail, since i've downloaded
yours on another PC.

I've found these macros in strc-reg.mkiv, that are called right before
and after the page numbers:

\unexpanded\def\startregisterpages
  {\begingroup
   \dostarttagged\t!registerpages\empty
   \useregisterstyleandcolor\c!pagestyle\c!pagecolor}

\unexpanded\def\stopregisterpages
  {\dostoptagged
   \endgroup}

And this seems to work:

\let\origstartregisterpages=\startregisterpages%
\let\origstopregisterpages=\stopregisterpages%
\unexpanded\def\startregisterpages{\origstartregisterpages\wordright\bg
roup }
\unexpanded\def\stopregisterpages{\egroup\origstopregisterpages}

\setupregister[index][n=1,alternative=A]

\starttext
\CONTEXT\index{\ConTeXt}
\page
\LATEX\index{\LaTeX}
\page
\CONTEXT\index{\ConTeXt}
\page
\placeindex
\stoptext

I've also learned about \groupedcommand, which i did not know.
Again, thanks for you help.

Best wishes,
Massi


___
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
___