* registers: how can I place a command around the whole of the page numbers of an index term? @ 2018-05-09 15:09 MF 2018-05-09 18:01 ` Wolfgang Schuster 2018-05-10 10:28 ` MF 0 siblings, 2 replies; 8+ messages in thread From: MF @ 2018-05-09 15:09 UTC (permalink / raw) To: mailing list for ConTeXt users Hello list, i'd like moving the page numbers in my index to the right, with a \wordright. \setupregister[index][n=1,alternative=A] \starttext \CONTEXT\index{\ConTeXt} \page \LATEX\index{\LaTeX} \page \CONTEXT\index{\ConTeXt} \page \placeindex \stoptext The index is at page 4. I want to move the numbers "1,3" and "2" to the right. The parameter pagecommand is for the single page number, i want to put a command (\wordright) around the whole block of page numbers. How can i do that? Greetings, 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-09 15:09 registers: how can I place a command around the whole of the page numbers of an index term? MF @ 2018-05-09 18:01 ` Wolfgang Schuster 2018-05-10 10:28 ` MF 1 sibling, 0 replies; 8+ messages in thread From: Wolfgang Schuster @ 2018-05-09 18:01 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1531 bytes --] There is no option to apply a command to all page numbers but you can add something after the register entry with the textcommand key. Be aware this solution isn’t perfect because in the worst case (narrow columns for the register or long entries) page numbers can be split on multiple lines. \setupregister [index] [n=1, alternative=A, textcommand=\groupedcommand{}{\hfill\quad}] Wolfgang > MF <mailto:massifr@fastwebnet.it> > 9. Mai 2018 um 17:09 > Hello list, > i'd like moving the page numbers in my index to the right, with a > \wordright. > > \setupregister[index][n=1,alternative=A] > > \starttext > \CONTEXT\index{\ConTeXt} > \page > \LATEX\index{\LaTeX} > \page > \CONTEXT\index{\ConTeXt} > \page > \placeindex > \stoptext > > The index is at page 4. I want to move the numbers "1,3" and "2" to the > right. > The parameter pagecommand is for the single page number, i want to put > a command (\wordright) around the whole block of page numbers. > How can i do that? > > Greetings, > 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 > ___________________________________________________________________________________ [-- Attachment #1.2: Type: text/html, Size: 3100 bytes --] [-- Attachment #2: Type: text/plain, Size: 492 bytes --] ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-09 15:09 registers: how can I place a command around the whole of the page numbers of an index term? MF 2018-05-09 18:01 ` Wolfgang Schuster @ 2018-05-10 10:28 ` MF 2018-05-10 10:35 ` MF 1 sibling, 1 reply; 8+ messages in thread From: MF @ 2018-05-10 10:28 UTC (permalink / raw) To: ntg-context 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-10 10:28 ` MF @ 2018-05-10 10:35 ` MF 2018-05-10 10:44 ` Wolfgang Schuster 2018-05-10 11:07 ` Hans Hagen 0 siblings, 2 replies; 8+ messages in thread From: MF @ 2018-05-10 10:35 UTC (permalink / raw) To: ntg-context 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-10 10:35 ` MF @ 2018-05-10 10:44 ` Wolfgang Schuster 2018-05-10 14:43 ` MF 2018-05-10 11:07 ` Hans Hagen 1 sibling, 1 reply; 8+ messages in thread From: Wolfgang Schuster @ 2018-05-10 10:44 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Hans Hagen [-- Attachment #1.1: Type: text/plain, Size: 2117 bytes --] 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 <mailto:massifr@fastwebnet.it> > 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 > ___________________________________________________________________________________ [-- Attachment #1.2: Type: text/html, Size: 3814 bytes --] [-- Attachment #2: Type: text/plain, Size: 492 bytes --] ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-10 10:44 ` Wolfgang Schuster @ 2018-05-10 14:43 ` MF 2018-05-10 15:16 ` MF 0 siblings, 1 reply; 8+ messages in thread From: MF @ 2018-05-10 14:43 UTC (permalink / raw) To: mailing list for ConTeXt users \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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-10 14:43 ` MF @ 2018-05-10 15:16 ` MF 0 siblings, 0 replies; 8+ messages in thread From: MF @ 2018-05-10 15:16 UTC (permalink / raw) To: ntg-context > 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: registers: how can I place a command around the whole of the page numbers of an index term? 2018-05-10 10:35 ` MF 2018-05-10 10:44 ` Wolfgang Schuster @ 2018-05-10 11:07 ` Hans Hagen 1 sibling, 0 replies; 8+ messages in thread From: Hans Hagen @ 2018-05-10 11:07 UTC (permalink / raw) To: ntg-context 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-05-10 15:16 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-05-09 15:09 registers: how can I place a command around the whole of the page numbers of an index term? MF 2018-05-09 18:01 ` Wolfgang Schuster 2018-05-10 10:28 ` MF 2018-05-10 10:35 ` MF 2018-05-10 10:44 ` Wolfgang Schuster 2018-05-10 14:43 ` MF 2018-05-10 15:16 ` MF 2018-05-10 11:07 ` Hans Hagen
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).