Re: [NTG-context] Simple backgrounds not working

2012-05-26 Thread Wolfgang Schuster

Am 26.05.2012 um 04:57 schrieb Aditya Mahajan:

 Hi,
 
 Simple backgrounds are not working with the latest beta. The following has no 
 background color.
 
 \setupbackground
  [background=color, backgroundcolor=red]
 \starttext
 \startbackground
  ABC
 \stopbackground
 \stoptext

Name clash in pack-rul.mkiv.

\startbackgorund uses \currentbackground for the instance of the environment 
and \framed uses also \currentbackground when it does process the list of 
backgrounds, changing the macro name in pack-rul.mkiv to \m_framed_background 
helps.

\unprotect

%\let\currentbackground\empty
\let\m_framed_background\empty

\def\pack_framed_process_background
%  {\ifcsname\??overlaybuiltin\currentbackground\endcsname
  {\ifcsname\??overlaybuiltin\m_framed_background\endcsname
 \pack_framed_process_background_indeed_internal
%   \else\ifcsname\??overlay\currentbackground\endcsname
   \else\ifcsname\??overlay\m_framed_background\endcsname
 \pack_framed_process_background_indeed_external
   \fi\fi}

\def\pack_framed_process_background_indeed_internal % : in name
  {\bgroup
   \setbox\b_framed_extra\hbox{%\bgroup
 \ifzeropt\framedbackgroundoffset
%   \csname\??overlaybuiltin\currentbackground\endcsname
   \csname\??overlaybuiltin\m_framed_background\endcsname
 \else
   \kern-\framedbackgroundoffset
%   \hbox{\csname\??overlaybuiltin\currentbackground\endcsname}%
   \hbox{\csname\??overlaybuiltin\m_framed_background\endcsname}%
 \fi
   }%\egroup
   \wd\b_framed_extra\zeropoint
   \ht\b_framed_extra\framedbackgroundheight
   \dp\b_framed_extra\framedbackgrounddepth
   \box\b_framed_extra
   \egroup}

\def\pack_framed_process_background_indeed_external
  {\pack_framed_overlay_initialize
   \bgroup
   \setbox\b_framed_extra\hbox{%\bgroup
 \ifzeropt\framedbackgroundoffset
%   \csname\??overlay\currentbackground\endcsname
   \csname\??overlay\m_framed_background\endcsname
 \else
   \kern-\framedbackgroundoffset
%   \hbox{\csname\??overlay\currentbackground\endcsname}%
   \hbox{\csname\??overlay\m_framed_background\endcsname}%
 \fi
   }%\egroup
   \wd\b_framed_extra\zeropoint
   \ht\b_framed_extra\framedbackgroundheight
   \dp\b_framed_extra\framedbackgrounddepth
   \box\b_framed_extra
   \egroup}

\def\pack_framed_process_backgrounds#1,#2% #2 gobbles spaces (we could avoid 
one catch if we have nextbackground)
%  {\edef\currentbackground{#1}%
  {\edef\m_framed_background{#1}%
%   \ifx\currentbackground\s!unknown\else
   \ifx\m_framed_background\s!unknown\else
 \pack_framed_process_background
 \expandafter\pack_framed_process_backgrounds
   \fi#2}

\protect

\setupbackground
 [background=color,
  backgroundcolor=yellow]

\starttext

\startbackground
 ABC
\stopbackground

\stoptext

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


Re: [NTG-context] Simple backgrounds not working

2012-05-26 Thread Hans Hagen

On 26-5-2012 10:56, Wolfgang Schuster wrote:


Am 26.05.2012 um 04:57 schrieb Aditya Mahajan:


Hi,

Simple backgrounds are not working with the latest beta. The following has no 
background color.

\setupbackground
  [background=color, backgroundcolor=red]
\starttext
\startbackground
  ABC
\stopbackground
\stoptext


Name clash in pack-rul.mkiv.

\startbackgorund uses \currentbackground for the instance of the environment 
and \framed uses also \currentbackground when it does process the list of 
backgrounds, changing the macro name in pack-rul.mkiv to \m_framed_background 
helps.

\unprotect

%\let\currentbackground\empty
\let\m_framed_background\empty


Ha, you beat me in maling ... i just changed that in the same way ... 
but i was wondering why a public name was used .. can it be that 
\currentbackground is used in modules or styles (e.g. implementing 
alternative built in backgrounds as I remember that Aditya has some 
plugs)?  If so then at some point we might need a public name but let's 
wait till it shows up.


Hans



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


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Hans Hagen

On 26-5-2012 04:08, Aditya Mahajan wrote:

\starttext
 \externalfigure[something]
 \stoptext


weird ... here it works ... can you runt with tracing?

\enabletrackers[graphics.locating]

\starttext
\externalfigure[cow]
\stoptext

Hans

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


Re: [NTG-context] Is there some easy way to do tufte-style side note?

2012-05-26 Thread Jano Kula

Hello Andy,

On 05/23/2012 04:09 PM, Andy Thomas wrote:

I finished a first version of a tufte style sample document that is based on a 
predecessor in another macro language. The auto alignment of the marginals has 
to be improved, but the rest looks already quite decent.

Please see: 
https://pub.uni-bielefeld.de/luur/download?func=downloadFilerecordOId=2303165fileOId=2303168

for a full sample document.


Nice work! Decent and nice design, good typesetting, I assume some hand 
work which of course cannot be avoided to make the result pleasing.


Just two remarks to the layout. Figure descriptions set in to the block 
(narrow column) produces too large spaces in the lines often. Ragged 
text would suit it better, I think.


Side notes set ragged left (rigth justyfied) on left pages are quite 
difficult to read, I would make them ragged right (left justified) on 
all pages and it would break the overall design at all.


Just wondering, why is Optima-Regular embeded so many times?

Regards,

Jano

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


Re: [NTG-context] indexing puzzle

2012-05-26 Thread Alan Bowen
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 mrog...@emory.eduwrote:

  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 1 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 bowenala...@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 

Re: [NTG-context] indexing puzzle

2012-05-26 Thread Rogers, Michael K
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 
mrog...@emory.edumailto:mrog...@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 1 
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 
bowenala...@gmail.commailto:bowenala...@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 

Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Hans Hagen

On 26-5-2012 04:08, Aditya Mahajan wrote:

Currently, ConTeXt only recognizes the type of figure from the file
extension. If a filename does not have an extension, \externalfigure fails.

For example:

$ cp `luatools hacker.jpg` something


ah .. i see, no extension .. too tricky to support that as they we'd 
need to run an identify on the image which is probably not what we want


i've made a simple 'identify' but am yet unsure how to use that in the 
current lookup strategy (as i want to avoid too much overhead ... using 
images without suffix is bad anyway)


Hans

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


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Aditya Mahajan

On Sat, 26 May 2012, Hans Hagen wrote:


On 26-5-2012 04:08, Aditya Mahajan wrote:

Currently, ConTeXt only recognizes the type of figure from the file
extension. If a filename does not have an extension, \externalfigure fails.

For example:

$ cp `luatools hacker.jpg` something


ah .. i see, no extension .. too tricky to support that as they we'd need to 
run an identify on the image which is probably not what we want


However adding `method=jpeg` works, even if the image is not a jpeg!

i've made a simple 'identify' but am yet unsure how to use that in the 
current lookup strategy (as i want to avoid too much overhead ... using 
images without suffix is bad anyway)


I am using a script to typeset rss feed to a pdf for reading on kindle. 
Some blog engines (e.g. typepad) do not set an extension for the image. As 
such, I cannot control the input. For the moment, I am using a workaround:


\let\normalexternalfigure\externalfigure
\unexpanded\def\externalfigure
{\dodoubleargument\rssfeed_externalfigure}

\def\rssfeed_externalfigure[#1][#2]%
{\normalexternalfigure[#1][\c!scale=2000, \c!method=JPEG, #2]}}

Notice the method=JPEG.

But, I think that I'll need to wrap a custom wrapper anyways, and some 
pages contain gif images which cause luatex to crash.


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


Re: [NTG-context] Simple backgrounds not working

2012-05-26 Thread Aditya Mahajan

On Sat, 26 May 2012, Hans Hagen wrote:


Ha, you beat me in maling ... i just changed that in the same way ...


Thanks to both of you.

 but i 
was wondering why a public name was used .. can it be that \currentbackground 
is used in modules or styles (e.g. implementing alternative built in 
backgrounds as I remember that Aditya has some plugs)?  If so then at some 
point we might need a public name but let's wait till it shows up.


I remeber using

\setupbackgrounds[page][background={bck1, \currentbackground, bck2}]

in some of my local styles. It is easy for me to adapt that.

\currentbackground is not used in any of my public modules.

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


Re: [NTG-context] indexing puzzle

2012-05-26 Thread Alan Bowen
It does indeed! Excellent!

A.

On Sat, May 26, 2012 at 9:21 AM, Rogers, Michael K mrog...@emory.eduwrote:

  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 mrog...@emory.eduwrote:

  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 1 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 bowenala...@gmail.comwrote:

 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 

Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Hans Hagen

On 26-5-2012 16:04, Aditya Mahajan wrote:

On Sat, 26 May 2012, Hans Hagen wrote:


On 26-5-2012 04:08, Aditya Mahajan wrote:

Currently, ConTeXt only recognizes the type of figure from the file
extension. If a filename does not have an extension, \externalfigure
fails.

For example:

$ cp `luatools hacker.jpg` something


ah .. i see, no extension .. too tricky to support that as they we'd
need to run an identify on the image which is probably not what we want


However adding `method=jpeg` works, even if the image is not a jpeg!


i've made a simple 'identify' but am yet unsure how to use that in the
current lookup strategy (as i want to avoid too much overhead ...
using images without suffix is bad anyway)


I am using a script to typeset rss feed to a pdf for reading on kindle.
Some blog engines (e.g. typepad) do not set an extension for the image.
As such, I cannot control the input. For the moment, I am using a
workaround:

\let\normalexternalfigure\externalfigure
\unexpanded\def\externalfigure
{\dodoubleargument\rssfeed_externalfigure}

\def\rssfeed_externalfigure[#1][#2]%
{\normalexternalfigure[#1][\c!scale=2000, \c!method=JPEG, #2]}}

Notice the method=JPEG.

But, I think that I'll need to wrap a custom wrapper anyways, and some
pages contain gif images which cause luatex to crash.


I'll add a virtual type 'auto':

\externalfigure[yourname.auto]



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


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread luigi scarso
On Sat, May 26, 2012 at 4:23 PM, Hans Hagen pra...@wxs.nl wrote:
 On 26-5-2012 16:04, Aditya Mahajan wrote:

 On Sat, 26 May 2012, Hans Hagen wrote:

 On 26-5-2012 04:08, Aditya Mahajan wrote:

 Currently, ConTeXt only recognizes the type of figure from the file
 extension. If a filename does not have an extension, \externalfigure
 fails.

 For example:

 $ cp `luatools hacker.jpg` something


 ah .. i see, no extension .. too tricky to support that as they we'd
 need to run an identify on the image which is probably not what we want


 However adding `method=jpeg` works, even if the image is not a jpeg!

 i've made a simple 'identify' but am yet unsure how to use that in the
 current lookup strategy (as i want to avoid too much overhead ...
 using images without suffix is bad anyway)


 I am using a script to typeset rss feed to a pdf for reading on kindle.
 Some blog engines (e.g. typepad) do not set an extension for the image.
 As such, I cannot control the input. For the moment, I am using a
 workaround:

 \let\normalexternalfigure\externalfigure
 \unexpanded\def\externalfigure
 {\dodoubleargument\rssfeed_externalfigure}

 \def\rssfeed_externalfigure[#1][#2]%
 {\normalexternalfigure[#1][\c!scale=2000, \c!method=JPEG, #2]}}

 Notice the method=JPEG.

 But, I think that I'll need to wrap a custom wrapper anyways, and some
 pages contain gif images which cause luatex to crash.


 I'll add a virtual type 'auto':

 \externalfigure[yourname.auto]
This can be interesting
http://www.garykessler.net/library/file_sigs.html

-- 
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Simple backgrounds not working

2012-05-26 Thread Hans Hagen

On 26-5-2012 16:07, Aditya Mahajan wrote:

On Sat, 26 May 2012, Hans Hagen wrote:


Ha, you beat me in maling ... i just changed that in the same way ...


Thanks to both of you.


but i was wondering why a public name was used .. can it be that
\currentbackground is used in modules or styles (e.g. implementing
alternative built in backgrounds as I remember that Aditya has some
plugs)? If so then at some point we might need a public name but let's
wait till it shows up.


I remeber using

\setupbackgrounds[page][background={bck1, \currentbackground, bck2}]

in some of my local styles. It is easy for me to adapt that.

\currentbackground is not used in any of my public modules.


maybe we can have \currentframedbackground then (if needed)

Hans

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


Re: [NTG-context] indexing puzzle

2012-05-26 Thread Hans Hagen

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
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Rogers, Michael K
I don't know if this helps but the following tells what the type of the image 
file is.  (In my case I copied a jpg to img1 and a png to img2, without 
extensions of course.)

\startluacode
userdata = userdata or { }
function userdata.mytype(s)
context(img.scan({filename=s}).imagetype)
end
\stopluacode
\starttext
img1 is \ctxlua{userdata.mytype(img1)}\par
img2 is \ctxlua{userdata.mytype(img2)}
\stoptext

Michael



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
___


Re: [NTG-context] Use figures without file extension

2012-05-26 Thread Aditya Mahajan

On Sun, 27 May 2012, Rogers, Michael K wrote:

I don't know if this helps but the following tells what the type of the 
image file is.  (In my case I copied a jpg to img1 and a png to img2, 
without extensions of course.)


Thanks.

Hans implemented a version of unix file command for checking the type of 
images, but using the inbuilt library is definely simpler!



\startluacode
userdata = userdata or { }
function userdata.mytype(s)
   context(img.scan({filename=s}).imagetype)
end
\stopluacode


@Hans, btw I also noticed that \locfilename does not work for files 
without extension. Create a file one in the current directory and then 
run:


\message{\locfilename{one}}
\end

Aditya

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