ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* indexing puzzle
@ 2012-05-22 22:39 Alan Bowen
  2012-05-24 11:06 ` Alan Bowen
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Bowen @ 2012-05-22 22:39 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1244 bytes --]

I have been trying to index the passages cited in a book and would be
grateful for some tactical advice.

There are several works by a single author, and it is customary to cite
each text by page and line number, as in 1253.12 (page 1253, line12), for
example.

I have a sort key for each work. But now I need a way to get the entry

1253.7 (page 1253, line 7) before the entry
1253.12 (page 1253, line 12).

\[Passage[AuthorText]{Author+Text+1253.07}1253.7 or
\[Passage[AuthorText]{Author+Text+1253.07}1253. 7
would work, but it is really better to have the index entry as “1253.7”
rather than as “1253.07” or “1253. 7”

I have experimented with different sort keys—e.g., AuthorText125307—and can
generate an index with the 1235.7 and so on in the proper place and form,
say, before 1253.12.

But then the problem is that I also get entire sequences of entries out of
order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring
the sort key AuthorText removes the latter problems but then leaves 1253.7
in the wrong place.)

If anyone has experience with this or just some ideas for a solution, their
suggestions will be most welcome.

I am using the MKII in the latest ConTeXt standalone.

Alan

[-- Attachment #1.2: Type: text/html, Size: 1515 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indexing puzzle
  2012-05-22 22:39 indexing puzzle Alan Bowen
@ 2012-05-24 11:06 ` Alan Bowen
  2012-05-24 21:14   ` Rogers, Michael K
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Bowen @ 2012-05-24 11:06 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 2091 bytes --]

For anyone interested in producing classical indices locorum, I have
devised a way that seems to work, although it is not that elegant.

The first step is to modify the sort keys by counting the number of digits
in the page number:
thus,
[AuthorText01] for pages 1–9,
[AuthorText02] for pages 10–99, and so on

The next is to insert the command “ \ab” (note the space) when the line
number is a single digit:
thus
391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line}

For \ab, I have:

\newdimen\digitwidth
\setbox0=\hbox{\tfx\char32}
\digitwidth=\wd0

\def\ab{\tfx\kern-\digitwidth}

The hitch here is that the font size is not context dependent.

Alan

On Tue, May 22, 2012 at 6:39 PM, Alan Bowen <bowenalan03@gmail.com> wrote:

> I have been trying to index the passages cited in a book and would be
> grateful for some tactical advice.
>
> There are several works by a single author, and it is customary to cite
> each text by page and line number, as in 1253.12 (page 1253, line12), for
> example.
>
> I have a sort key for each work. But now I need a way to get the entry
>
> 1253.7 (page 1253, line 7) before the entry
> 1253.12 (page 1253, line 12).
>
> \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or
> \[Passage[AuthorText]{Author+Text+1253.07}1253. 7
> would work, but it is really better to have the index entry as “1253.7”
> rather than as “1253.07” or “1253. 7”
>
> I have experimented with different sort keys—e.g., AuthorText125307—and
> can generate an index with the 1235.7 and so on in the proper place and
> form, say, before 1253.12.
>
> But then the problem is that I also get entire sequences of entries out of
> order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring
> the sort key AuthorText removes the latter problems but then leaves 1253.7
> in the wrong place.)
>
> If anyone has experience with this or just some ideas for a solution,
> their suggestions will be most welcome.
>
> I am using the MKII in the latest ConTeXt standalone.
>
> Alan
>
>
>
>

[-- Attachment #1.2: Type: text/html, Size: 2845 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indexing puzzle
  2012-05-24 11:06 ` Alan Bowen
@ 2012-05-24 21:14   ` Rogers, Michael K
  2012-05-26 12:41     ` Alan Bowen
  0 siblings, 1 reply; 7+ messages in thread
From: Rogers, Michael K @ 2012-05-24 21:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 4800 bytes --]

1. For \ab you might want
    \def\ab{\unskip}
since the space is not the same as the width of a digit.

2. Does your solution work with line numbers greater than 99?  I tried to implement your idea and I got the order 25.7, 25.117, 25.37.  Probably more than 99 lines never occurs on a page, so it's a non-issue.  But Homer, for instance, is often referred to by Book.Line, and the lines go past 100.  Again, perhaps a non-issue for you.

3.  My own attempts:  At first I though what a nice opportunity for me to learn a little more Lua, which it was.  After, I read you wanted a MKII solution.  Well, I'm embarrassed at how long I took to do the MKII, but I'm not good at controlling expansion.  Anyway, it automatically generates sort keys for the pages by converting digits to letters and padding with initial a's, so that each page or line number is a fixed length (4 in this case, up to 10000 pages/lines).  For instance,
    123.4--56 is mapped to  abcdaaaeaafg
MKII does not seem to sort digit-based keys reliably; MKIV does, and you can just pad out the digits with zeros.  The complete sort key that worked was the catenation of the author, text, and locus key, which is similar to what you have.

MKII:
\defineregister[Passage][Passages]
...
% interface to register -- \locuskey indirectly returns a key in \nextkey
\def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}}
\def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}}
% Def. of \locuskey#1
%    In: #1<-p1[.l2[--l3]] Out: key stored in \nextkey
... (see attached file, if interested)

MKIV:
% interface to register -- expansion in MKIV must be different, because a direct approach works:
\def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}}
% Def. of \locuskey
\startluacode
userdata = userdata or { }
function userdata.locuskey(x)
    context(string.gsub(x,"(%d+)",function (s) return string.format("%04d",tonumber(s)) end))
end
\stopluacode
\def\locuskey#1{\ctxlua{userdata.locuskey("#1")}}

The Mark IV/Luatex one was much nicer, less frustrating to figure out.


On May 24, 2012, at 7:06 AM, Alan Bowen wrote:

For anyone interested in producing classical indices locorum, I have devised a way that seems to work, although it is not that elegant.

The first step is to modify the sort keys by counting the number of digits in the page number:
thus,
[AuthorText01] for pages 1–9,
[AuthorText02] for pages 10–99, and so on

The next is to insert the command “ \ab” (note the space) when the line number is a single digit:
thus
391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line}

For \ab, I have:

\newdimen\digitwidth
\setbox0=\hbox{\tfx\char32}
\digitwidth=\wd0

\def\ab{\tfx\kern-\digitwidth}

The hitch here is that the font size is not context dependent.

Alan

On Tue, May 22, 2012 at 6:39 PM, Alan Bowen <bowenalan03@gmail.com<mailto:bowenalan03@gmail.com>> wrote:
I have been trying to index the passages cited in a book and would be grateful for some tactical advice.

There are several works by a single author, and it is customary to cite each text by page and line number, as in 1253.12 (page 1253, line12), for example.

I have a sort key for each work. But now I need a way to get the entry

1253.7 (page 1253, line 7) before the entry
1253.12 (page 1253, line 12).

\[Passage[AuthorText]{Author+Text+1253.07}1253.7 or
\[Passage[AuthorText]{Author+Text+1253.07}1253. 7
would work, but it is really better to have the index entry as “1253.7” rather than as “1253.07” or “1253. 7”

I have experimented with different sort keys—e.g., AuthorText125307—and can generate an index with the 1235.7 and so on in the proper place and form, say, before 1253.12.

But then the problem is that I also get entire sequences of entries out of order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring the sort key AuthorText removes the latter problems but then leaves 1253.7 in the wrong place.)

If anyone has experience with this or just some ideas for a solution, their suggestions will be most welcome.

I am using the MKII in the latest ConTeXt standalone.

Alan


________________________________

This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).

[-- Attachment #1.2: Type: text/html, Size: 6925 bytes --]

[-- Attachment #2: SortkeyMkII.tex --]
[-- Type: application/octet-stream, Size: 3318 bytes --]

%!TeX TS-program = ConTeXt-MKII

\defineregister[Passage][Passages] 
\setupregister[Passage][n=1,% 
balance=yes,% 
pagestyle=\tfx\em,% 
textstyle=\tfx,% 
criterium=all,% 
interaction={pagenumber},% 
] 
\setupregister[Passage][indicator=no,distance=0.5em] 
% interface to register
\def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}}
\def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}}

%
% Def. of \locuskey#1
%	In: #1<-p1[.l2[--l3]] Out: key stored in \nextkey
% Utility: length of string of characters (see TeX Book, p. 219)
\newcount\keylength
\def\initkeylength#1{\global\keylength=0 \doLength#1\end}
\def\doLength#1{\ifx#1\end\let\next=\relax\else\global\advance\keylength by1\let\next=\doLength\fi\next}
% Create a letter-only key based on page.line(s).   Result stored in \nextkey.
\def\locuskey#1{\gdef\nextkey{}\doifinstringelse{.}{#1}
	{\doifinstringelse{-}{#1}{\startlocuskeypagelinerange#1\stoplocuskeypagelinerange}{\startlocuskeypageline#1\stoplocuskeypageline}}
	{\locuskeypage{#1}}}
\def\locuskeypage#1{\padkey{#1}\padkey{}\padkey{}}
\def\startlocuskeypageline#1.#2\stoplocuskeypageline{\padkey{#1}\padkey{#2}\padkey{}}
\def\startlocuskeypagelinerange#1.#2--#3\stoplocuskeypagelinerange{\padkey{#1}\padkey{#2}\padkey{#3}}
% pad page or line number with intial a's, fixed length 5 chars; convert digits to letters
\def\padkey#1{{\initkeylength{#1}\xdef\nextkey{\nextkey\ifcase\keylength aaaa\or aaa\or aa\or a\else\fi}\toletters{#1}}}
\def\toletters#1{\keylength=0 \dotoletters#1\end}
\def\dotoletters#1{\ifx#1\end\let\next=\relax\else\digittoletter#1\let\next=\dotoletters\fi \next}
\def\digittoletter#1{\xdef\nextkey{\nextkey\ifcase#1a\or b\or c\or d\or e\or f\or g\or h\or i\or j\else #1\fi}}

\starttext 

See \MyPassage{Simplicius}{\em In de caelo}{280}280.
See \MyPassage{Simplicius}{\em In de caelo}{483.15--19}483.15--19. 
See \MyPassage{Simplicius}{\em Work III}{280}280.
See \MyPassage{Plato}{\em Whatever}{77.13--24}77.13--24. 
See \MyPassage{Plato}{\em Whatever}{25.7}25.7. 
See \MyPassage{Plato}{\em Whatever}{25.37}25.37. 
See \MyPassage{Simplicius}{\em Work III}{483.1}483.1. 
See \MyPassage{Simplicius}{\em Work III}{483.15--19}483.15--19. 
\page 
See \MyPassage{Simplicius}{\em In de caelo}{477.3--4}477.3--4.
See \MyPassage{Simplicius}{\em Alter}{478.3}478.3.
See \MyPassage{Simplicius}{\em In de caelo}{278}278. 
See \MyPassage{Simplicius}{\em In de caelo}{377}377. 
See \MyPassage{Simplicius}{\em In de caelo}{277}277. 
See \MyPassage{Simplicius}{\em In de caelo}{8}8. 
See \MyPassage{Simplicius}{\em In de caelo}{77.3--4}77.3--4. 
See \MyPassage{Simplicius}{\em In de caelo}{377.43--44}377.43--44. 
See \MyPassage{Plato}{\em Whatever}{28}28. 
See \MyPassage{Plato}{\em Whatever}{77.3--4}77.3--4. 
See \MyPassage{Plato}{\em Whatever}{377.43--44}377.43--44. 
\page
See \MyPassage{Simplicius}{\em In de caelo}{377.43--44}377.43--44. 
See \MyPassage{Simplicius}{\em In de caelo}{376.7--14}376.7--14. 
See \MyPassage{Simplicius}{\em In de caelo}{376.73}376.73. 
See \MyPassage{Simplicius}{\em In de caelo}{377.43}377.43. 
See \MyPassage{Simplicius}{\em In de caelo}{478}478.
See \MyPassage{Plato}{\em Whatever}{25.117}25.117. 
\page 

\placeregister[Passage] 


\stoptext 


[-- Attachment #3: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indexing puzzle
  2012-05-24 21:14   ` Rogers, Michael K
@ 2012-05-26 12:41     ` Alan Bowen
  2012-05-26 13:21       ` Rogers, Michael K
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Bowen @ 2012-05-26 12:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 6402 bytes --]

Michael—

Thank you so much for your very helpful response.

1. \unskip works well.

2. What I currently have is admittedly an ad hoc system for encoding my
indices. As you note, the system works for  page numbers > 99 where line
numbers < 99. When line numbers > 99, I adapt the sort key differently:
thus, for Cleomedes, *Cael*. I have [CleomCael105001] for 1.5.1. This works
(in MKII) but only because the number of entries is very small.

3. I like your MKII solution—it is much more general, works well on what I
have, and is certainly less taxing to encode. Many thanks!

The book that I trying to index right now is the last of my MKII projects.
So I am also interested in, and very grateful, for  your MKIV solution.

All best, Alan


On Thu, May 24, 2012 at 5:14 PM, Rogers, Michael K <mroge02@emory.edu>wrote:

>  1. For \ab you might want
>     \def\ab{\unskip}
> since the space is not the same as the width of a digit.
>
>  2. Does your solution work with line numbers greater than 99?  I tried
> to implement your idea and I got the order 25.7, 25.117, 25.37.  Probably
> more than 99 lines never occurs on a page, so it's a non-issue.  But Homer,
> for instance, is often referred to by Book.Line, and the lines go past 100.
>  Again, perhaps a non-issue for you.
>
>  3.  My own attempts:  At first I though what a nice opportunity for me
> to learn a little more Lua, which it was.  After, I read you wanted a MKII
> solution.  Well, I'm embarrassed at how long I took to do the MKII, but I'm
> not good at controlling expansion.  Anyway, it automatically generates sort
> keys for the pages by converting digits to letters and padding with initial
> a's, so that each page or line number is a fixed length (4 in this case, up
> to 10000 pages/lines).  For instance,
>     123.4--56 is mapped to  abcdaaaeaafg
> MKII does not seem to sort digit-based keys reliably; MKIV does, and you
> can just pad out the digits with zeros.  The complete sort key that worked
> was the catenation of the author, text, and locus key, which is similar to
> what you have.
>
>  MKII:
>  \defineregister[Passage][Passages]
> ...
> % interface to register -- \locuskey indirectly returns a key in \nextkey
>
> \def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}}
> \def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}}
> % Def. of \locuskey#1
> %    In: #1<-p1[.l2[--l3]] Out: key stored in \nextkey
> ... (see attached file, if interested)
>
>  MKIV:
>  % interface to register -- expansion in MKIV must be different, because
> a direct approach works:
>  \def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}}
>  % Def. of \locuskey
>  \startluacode
> userdata = userdata or { }
>  function userdata.locuskey(x)
>     context(string.gsub(x,"(%d+)",function (s) return
> string.format("%04d",tonumber(s)) end))
> end
> \stopluacode
> \def\locuskey#1{\ctxlua{userdata.locuskey("#1")}}
>
>  The Mark IV/Luatex one was much nicer, less frustrating to figure out.
>
>
>  On May 24, 2012, at 7:06 AM, Alan Bowen wrote:
>
> For anyone interested in producing classical indices locorum, I have
> devised a way that seems to work, although it is not that elegant.
>
>  The first step is to modify the sort keys by counting the number of
> digits in the page number:
> thus,
> [AuthorText01] for pages 1–9,
> [AuthorText02] for pages 10–99, and so on
>
>  The next is to insert the command “ \ab” (note the space) when the line
> number is a single digit:
> thus
> 391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line}
>
>  For \ab, I have:
>
>  \newdimen\digitwidth
> \setbox0=\hbox{\tfx\char32}
> \digitwidth=\wd0
>
>  \def\ab{\tfx\kern-\digitwidth}
>
>  The hitch here is that the font size is not context dependent.
>
>  Alan
>
> On Tue, May 22, 2012 at 6:39 PM, Alan Bowen <bowenalan03@gmail.com> wrote:
>
> I have been trying to index the passages cited in a book and would be
> grateful for some tactical advice.
>
>  There are several works by a single author, and it is customary to cite
> each text by page and line number, as in 1253.12 (page 1253, line12), for
> example.
>
>  I have a sort key for each work. But now I need a way to get the entry
>
>  1253.7 (page 1253, line 7) before the entry
> 1253.12 (page 1253, line 12).
>
>  \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or
> \[Passage[AuthorText]{Author+Text+1253.07}1253. 7
> would work, but it is really better to have the index entry as “1253.7”
> rather than as “1253.07” or “1253. 7”
>
>  I have experimented with different sort keys—e.g., AuthorText125307—and
> can generate an index with the 1235.7 and so on in the proper place and
> form, say, before 1253.12.
>
>  But then the problem is that I also get entire sequences of entries out
> of order (485.19, 485.21 before 477.31, and so on). Very puzzling.
> (Restoring the sort key AuthorText removes the latter problems but then
> leaves 1253.7 in the wrong place.)
>
>  If anyone has experience with this or just some ideas for a solution,
> their suggestions will be most welcome.
>
>  I am using the MKII in the latest ConTeXt standalone.
>
>  Alan
>
>
>
> ------------------------------
>
> This e-mail message (including any attachments) is for the sole use of
> the intended recipient(s) and may contain confidential and privileged
> information. If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination, distribution
> or copying of this message (including any attachments) is strictly
> prohibited.
>
> If you have received this message in error, please contact
> the sender by reply e-mail message and destroy all copies of the
> original message (including attachments).
>
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 9528 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indexing puzzle
  2012-05-26 12:41     ` Alan Bowen
@ 2012-05-26 13:21       ` Rogers, Michael K
  2012-05-26 14:12         ` Alan Bowen
  0 siblings, 1 reply; 7+ messages in thread
From: Rogers, Michael K @ 2012-05-26 13:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 7023 bytes --]

Thanks, Alan.  Actually, I now think MKIV works without any trickery.  I was perhaps too eager to try a Lua solution.  \Passage{Author+Text+Locus} seems to work fine in the beta today.

Cheers,  Michael


On May 26, 2012, at 8:41 AM, Alan Bowen wrote:

Michael—

Thank you so much for your very helpful response.

1. \unskip works well.

2. What I currently have is admittedly an ad hoc system for encoding my indices. As you note, the system works for  page numbers > 99 where line numbers < 99. When line numbers > 99, I adapt the sort key differently: thus, for Cleomedes, Cael. I have [CleomCael105001] for 1.5.1. This works (in MKII) but only because the number of entries is very small.

3. I like your MKII solution—it is much more general, works well on what I have, and is certainly less taxing to encode. Many thanks!

The book that I trying to index right now is the last of my MKII projects. So I am also interested in, and very grateful, for  your MKIV solution.

All best, Alan


On Thu, May 24, 2012 at 5:14 PM, Rogers, Michael K <mroge02@emory.edu<mailto:mroge02@emory.edu>> wrote:
1. For \ab you might want
    \def\ab{\unskip}
since the space is not the same as the width of a digit.

2. Does your solution work with line numbers greater than 99?  I tried to implement your idea and I got the order 25.7, 25.117, 25.37.  Probably more than 99 lines never occurs on a page, so it's a non-issue.  But Homer, for instance, is often referred to by Book.Line, and the lines go past 100.  Again, perhaps a non-issue for you.

3.  My own attempts:  At first I though what a nice opportunity for me to learn a little more Lua, which it was.  After, I read you wanted a MKII solution.  Well, I'm embarrassed at how long I took to do the MKII, but I'm not good at controlling expansion.  Anyway, it automatically generates sort keys for the pages by converting digits to letters and padding with initial a's, so that each page or line number is a fixed length (4 in this case, up to 10000 pages/lines).  For instance,
    123.4--56 is mapped to  abcdaaaeaafg
MKII does not seem to sort digit-based keys reliably; MKIV does, and you can just pad out the digits with zeros.  The complete sort key that worked was the catenation of the author, text, and locus key, which is similar to what you have.

MKII:
\defineregister[Passage][Passages]
...
% interface to register -- \locuskey indirectly returns a key in \nextkey
\def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}}
\def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}}
% Def. of \locuskey#1
%    In: #1<-p1[.l2[--l3]] Out: key stored in \nextkey
... (see attached file, if interested)

MKIV:
% interface to register -- expansion in MKIV must be different, because a direct approach works:
\def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}}
% Def. of \locuskey
\startluacode
userdata = userdata or { }
function userdata.locuskey(x)
    context(string.gsub(x,"(%d+)",function (s) return string.format("%04d",tonumber(s)) end))
end
\stopluacode
\def\locuskey#1{\ctxlua{userdata.locuskey("#1")}}

The Mark IV/Luatex one was much nicer, less frustrating to figure out.


On May 24, 2012, at 7:06 AM, Alan Bowen wrote:

For anyone interested in producing classical indices locorum, I have devised a way that seems to work, although it is not that elegant.

The first step is to modify the sort keys by counting the number of digits in the page number:
thus,
[AuthorText01] for pages 1–9,
[AuthorText02] for pages 10–99, and so on

The next is to insert the command “ \ab” (note the space) when the line number is a single digit:
thus
391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line}

For \ab, I have:

\newdimen\digitwidth
\setbox0=\hbox{\tfx\char32}
\digitwidth=\wd0

\def\ab{\tfx\kern-\digitwidth}

The hitch here is that the font size is not context dependent.

Alan

On Tue, May 22, 2012 at 6:39 PM, Alan Bowen <bowenalan03@gmail.com<mailto:bowenalan03@gmail.com>> wrote:
I have been trying to index the passages cited in a book and would be grateful for some tactical advice.

There are several works by a single author, and it is customary to cite each text by page and line number, as in 1253.12 (page 1253, line12), for example.

I have a sort key for each work. But now I need a way to get the entry

1253.7 (page 1253, line 7) before the entry
1253.12 (page 1253, line 12).

\[Passage[AuthorText]{Author+Text+1253.07}1253.7 or
\[Passage[AuthorText]{Author+Text+1253.07}1253. 7
would work, but it is really better to have the index entry as “1253.7” rather than as “1253.07” or “1253. 7”

I have experimented with different sort keys—e.g., AuthorText125307—and can generate an index with the 1235.7 and so on in the proper place and form, say, before 1253.12.

But then the problem is that I also get entire sequences of entries out of order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring the sort key AuthorText removes the latter problems but then leaves 1253.7 in the wrong place.)

If anyone has experience with this or just some ideas for a solution, their suggestions will be most welcome.

I am using the MKII in the latest ConTeXt standalone.

Alan


________________________________

This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl<mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl<http://www.pragma-ade.nl/> / http://tex.aanhet.net<http://tex.aanhet.net/>
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net<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<mailto: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
___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 11200 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indexing puzzle
  2012-05-26 13:21       ` Rogers, Michael K
@ 2012-05-26 14:12         ` Alan Bowen
  2012-05-26 14:54           ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Bowen @ 2012-05-26 14:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 8044 bytes --]

It does indeed! Excellent!

A.

On Sat, May 26, 2012 at 9:21 AM, Rogers, Michael K <mroge02@emory.edu>wrote:

>  Thanks, Alan.  Actually, I now think MKIV works without any trickery.  I
> was perhaps too eager to try a Lua solution.  \Passage{Author+Text+Locus}
> seems to work fine in the beta today.
>
>  Cheers,  Michael
>
>
>
>  On May 26, 2012, at 8:41 AM, Alan Bowen wrote:
>
> Michael—
>
>  Thank you so much for your very helpful response.
>
>  1. \unskip works well.
>
>  2. What I currently have is admittedly an ad hoc system for encoding my
> indices. As you note, the system works for  page numbers > 99 where line
> numbers < 99. When line numbers > 99, I adapt the sort key differently:
> thus, for Cleomedes, *Cael*. I have [CleomCael105001] for 1.5.1. This
> works (in MKII) but only because the number of entries is very small.
>
>  3. I like your MKII solution—it is much more general, works well on what
> I have, and is certainly less taxing to encode. Many thanks!
>
>  The book that I trying to index right now is the last of my MKII
> projects. So I am also interested in, and very grateful, for  your MKIV
> solution.
>
>  All best, Alan
>
>
> On Thu, May 24, 2012 at 5:14 PM, Rogers, Michael K <mroge02@emory.edu>wrote:
>
>>  1. For \ab you might want
>>     \def\ab{\unskip}
>> since the space is not the same as the width of a digit.
>>
>>  2. Does your solution work with line numbers greater than 99?  I tried
>> to implement your idea and I got the order 25.7, 25.117, 25.37.  Probably
>> more than 99 lines never occurs on a page, so it's a non-issue.  But Homer,
>> for instance, is often referred to by Book.Line, and the lines go past 100.
>>  Again, perhaps a non-issue for you.
>>
>>  3.  My own attempts:  At first I though what a nice opportunity for me
>> to learn a little more Lua, which it was.  After, I read you wanted a MKII
>> solution.  Well, I'm embarrassed at how long I took to do the MKII, but I'm
>> not good at controlling expansion.  Anyway, it automatically generates sort
>> keys for the pages by converting digits to letters and padding with initial
>> a's, so that each page or line number is a fixed length (4 in this case, up
>> to 10000 pages/lines).  For instance,
>>     123.4--56 is mapped to  abcdaaaeaafg
>> MKII does not seem to sort digit-based keys reliably; MKIV does, and you
>> can just pad out the digits with zeros.  The complete sort key that worked
>> was the catenation of the author, text, and locus key, which is similar to
>> what you have.
>>
>>  MKII:
>>  \defineregister[Passage][Passages]
>> ...
>> % interface to register -- \locuskey indirectly returns a key in \nextkey
>>
>> \def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}}
>> \def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}}
>> % Def. of \locuskey#1
>> %    In: #1<-p1[.l2[--l3]] Out: key stored in \nextkey
>> ... (see attached file, if interested)
>>
>>  MKIV:
>>  % interface to register -- expansion in MKIV must be different, because
>> a direct approach works:
>>  \def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}}
>>  % Def. of \locuskey
>>  \startluacode
>> userdata = userdata or { }
>>  function userdata.locuskey(x)
>>     context(string.gsub(x,"(%d+)",function (s) return
>> string.format("%04d",tonumber(s)) end))
>> end
>> \stopluacode
>> \def\locuskey#1{\ctxlua{userdata.locuskey("#1")}}
>>
>>  The Mark IV/Luatex one was much nicer, less frustrating to figure out.
>>
>>
>>  On May 24, 2012, at 7:06 AM, Alan Bowen wrote:
>>
>> For anyone interested in producing classical indices locorum, I have
>> devised a way that seems to work, although it is not that elegant.
>>
>>  The first step is to modify the sort keys by counting the number of
>> digits in the page number:
>> thus,
>> [AuthorText01] for pages 1–9,
>> [AuthorText02] for pages 10–99, and so on
>>
>>  The next is to insert the command “ \ab” (note the space) when the line
>> number is a single digit:
>> thus
>> 391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line}
>>
>>  For \ab, I have:
>>
>>  \newdimen\digitwidth
>> \setbox0=\hbox{\tfx\char32}
>> \digitwidth=\wd0
>>
>>  \def\ab{\tfx\kern-\digitwidth}
>>
>>  The hitch here is that the font size is not context dependent.
>>
>>  Alan
>>
>> On Tue, May 22, 2012 at 6:39 PM, Alan Bowen <bowenalan03@gmail.com>wrote:
>>
>> I have been trying to index the passages cited in a book and would be
>> grateful for some tactical advice.
>>
>>  There are several works by a single author, and it is customary to cite
>> each text by page and line number, as in 1253.12 (page 1253, line12), for
>> example.
>>
>>  I have a sort key for each work. But now I need a way to get the entry
>>
>>  1253.7 (page 1253, line 7) before the entry
>> 1253.12 (page 1253, line 12).
>>
>>  \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or
>> \[Passage[AuthorText]{Author+Text+1253.07}1253. 7
>> would work, but it is really better to have the index entry as “1253.7”
>> rather than as “1253.07” or “1253. 7”
>>
>>  I have experimented with different sort keys—e.g., AuthorText125307—and
>> can generate an index with the 1235.7 and so on in the proper place and
>> form, say, before 1253.12.
>>
>>  But then the problem is that I also get entire sequences of entries out
>> of order (485.19, 485.21 before 477.31, and so on). Very puzzling.
>> (Restoring the sort key AuthorText removes the latter problems but then
>> leaves 1253.7 in the wrong place.)
>>
>>  If anyone has experience with this or just some ideas for a solution,
>> their suggestions will be most welcome.
>>
>>  I am using the MKII in the latest ConTeXt standalone.
>>
>>  Alan
>>
>>
>>
>> ------------------------------
>>
>> This e-mail message (including any attachments) is for the sole use of
>> the intended recipient(s) and may contain confidential and privileged
>> information. If the reader of this message is not the intended
>> recipient, you are hereby notified that any dissemination, distribution
>> or copying of this message (including any attachments) is strictly
>> prohibited.
>>
>> If you have received this message in error, please contact
>> the sender by reply e-mail message and destroy all copies of the
>> original message (including attachments).
>>
>>
>> ___________________________________________________________________________________
>> 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
>>
>> ___________________________________________________________________________________
>>
>
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________
>
>
>
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 12224 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indexing puzzle
  2012-05-26 14:12         ` Alan Bowen
@ 2012-05-26 14:54           ` Hans Hagen
  0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2012-05-26 14:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 26-5-2012 16:12, Alan Bowen wrote:

>>   Thanks, Alan.  Actually, I now think MKIV works without any trickery.  I
>> was perhaps too eager to try a Lua solution.  \Passage{Author+Text+Locus}
>> seems to work fine in the beta today.

If you dont' like the + you can do:

\setregisterentry
     [Passage]
     [entries:1={Author},
      entries:2={Text},
      entries:3={Locus}]

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-05-26 14:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-22 22:39 indexing puzzle Alan Bowen
2012-05-24 11:06 ` Alan Bowen
2012-05-24 21:14   ` Rogers, Michael K
2012-05-26 12:41     ` Alan Bowen
2012-05-26 13:21       ` Rogers, Michael K
2012-05-26 14:12         ` Alan Bowen
2012-05-26 14:54           ` 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).