Re: [NTG-context] \numstr errors out in chapter star logic

2010-06-30 Thread Tom



Am 28.06.10 23:33, schrieb Tom:
> The "lazy" method below yields eleven pages, each of which is headed by n
> Chapter n, where n represents the numerals from 1 to 11. The text version
of
> the chapter numbers do not appear.
>
>
\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Te
> n,Eleven]
>
> \setuphead[chapter]
>   [conversion=numstring]
>

How should i know you're using mkii! Replace \setuphead with \setupsection:

\setupsection[chapter][conversion=numstring]

Wolfgang

The following example converts chapter numbers to words for the \chapter
logic but also converts chapter numbers to words in unwanted places such as
in the TOC and section numbers in the text.

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Te
n,Eleven]

\setupsection[chapter]
 [conversion=numstring]  

\starttext

\completecontent
\dorecurse{11}{\chapter{Chapter #1}\par\section{Example section}}

\stoptext

Tom Benjey
717-258-9733 voice
717-243-0074 fax
Twitter: @TomBenjey



___
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] \numstr errors out in chapter star logic

2010-06-29 Thread Aditya Mahajan

On Tue, 29 Jun 2010, Mojca Miklavec wrote:


On Mon, Jun 28, 2010 at 23:41, Wolfgang Schuster wrote:


That's abother way but the \numstring code is a mess (why so many
unnecessary comment signs?)
and it needs a proper rewrite (Lua?) before it can be used.


It was written in 2005. I don't remember who wrote it originally
(maybe Hans or maybe it was cloned from LaTeX); I only remember doing
slight modifications on someone else's code.

And yes, it needs to be rewritten in Lua for MKIV.


The fourth post from the bottom
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=10155&page=999

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] \numstr errors out in chapter star logic

2010-06-29 Thread Mojca Miklavec
On Mon, Jun 28, 2010 at 23:41, Wolfgang Schuster wrote:
>
> That's abother way but the \numstring code is a mess (why so many
> unnecessary comment signs?)
> and it needs a proper rewrite (Lua?) before it can be used.

It was written in 2005. I don't remember who wrote it originally
(maybe Hans or maybe it was cloned from LaTeX); I only remember doing
slight modifications on someone else's code.

And yes, it needs to be rewritten in Lua for MKIV. It would be really
nice if a fixed version of this macro would make it into ConTeXt core.

Mojca
___
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] \numstr errors out in chapter star logic

2010-06-29 Thread Tom
\setupsection[chapter][conversion=numstring]

Wolfgang

This change produces the desired results on the first page of each chapter
but also has some, in my case, undesired side-effects. Chapter numbers in
the table of contents are now spelled out (I prefer numerals in the TOC) and
section numbers in the text begin with the words rather than the numerals
(again, I prefer numerals for section numbers). The documentation probably
explains how to deal with this, but I haven't been able to find it.  All I
want to do is make a cosmetic change to the tops of the chapter start pages.

Tom Benjey
717-258-9733 voice
717-243-0074 fax
Twitter: @TomBenjey







___
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] \numstr errors out in chapter star logic

2010-06-29 Thread Wolfgang Schuster

Am 29.06.10 02:26, schrieb Tom:

Sorry for not including that I'm using mkii. This code works.
How do I tell from the ConTeXt Manual and the wiki which commands apply to
mkii and which apply to mkiv? Are documents prepared for mkii upwardly
compatible with mkiv or do some mkii commands not work the same in mkiv?
   

All older manuals are for mkii but most of the explanations and examples
apply to mkiv as well, the biggest differences between mkii and mkiv are
font installation, section numbering and xml handling.

You can see on the Pragma ADE page labels for which version
a manual is written: http://pragma-ade.com/show-man-1.htm

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] \numstr errors out in chapter star logic

2010-06-28 Thread Tom




-Original Message-
From: ntg-context-boun...@ntg.nl [mailto:ntg-context-boun...@ntg.nl] On
Behalf Of Wolfgang Schuster
Sent: Monday, June 28, 2010 5:39 PM
To: mailing list for ConTeXt users
Subject: Re: [NTG-context] \numstr errors out in chapter star logic

Am 28.06.10 23:33, schrieb Tom:
> The "lazy" method below yields eleven pages, each of which is headed by n
> Chapter n, where n represents the numerals from 1 to 11. The text version
of
> the chapter numbers do not appear.
>
>
\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Te
> n,Eleven]
>
> \setuphead[chapter]
>   [conversion=numstring]
>

How should i know you're using mkii! Replace \setuphead with \setupsection:

\setupsection[chapter][conversion=numstring]

Wolfgang

Sorry for not including that I'm using mkii. This code works.
How do I tell from the ConTeXt Manual and the wiki which commands apply to
mkii and which apply to mkiv? Are documents prepared for mkii upwardly
compatible with mkiv or do some mkii commands not work the same in mkiv?

Thank you for all your help.

Tom Benjey
717-258-9733 voice
717-243-0074 fax
Twitter: @TomBenjey


___
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] \numstr errors out in chapter star logic

2010-06-28 Thread Wolfgang Schuster

Am 28.06.10 23:17, schrieb Aditya Mahajan:

On Mon, 28 Jun 2010, Wolfgang Schuster wrote:


Am 28.06.10 23:03, schrieb Tom:
Making the following changes resulted in ! Missing Number, treated 
as zero.




I’m lazy:

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,...] 



or even

\defineconversion[numstring][\numstr]

and then everything works (except capitalization, that is)


That's abother way but the \numstring code is a mess (why so many 
unnecessary comment signs?)

and it needs a proper rewrite (Lua?) before it can be used.

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] \numstr errors out in chapter star logic

2010-06-28 Thread Wolfgang Schuster

Am 28.06.10 23:33, schrieb Tom:

The "lazy" method below yields eleven pages, each of which is headed by n
Chapter n, where n represents the numerals from 1 to 11. The text version of
the chapter numbers do not appear.

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Te
n,Eleven]

\setuphead[chapter]
  [conversion=numstring]
   


How should i know you're using mkii! Replace \setuphead with \setupsection:

\setupsection[chapter][conversion=numstring]

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] \numstr errors out in chapter star logic

2010-06-28 Thread Tom




Am 28.06.10 23:03, schrieb Tom:
> Making the following changes resulted in ! Missing Number, treated as
zero.
>

I'm lazy:

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Te
n,...]
\setuphead[chapter][conversion=numstring]
\starttext
\dorecurse{11}{\chapter{Chapter #1}}
\stoptext

Wolfgang

The "lazy" method below yields eleven pages, each of which is headed by n
Chapter n, where n represents the numerals from 1 to 11. The text version of
the chapter numbers do not appear.

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Te
n,Eleven]

\setuphead[chapter]
 [conversion=numstring]  

\starttext

\dorecurse{11}{\chapter{Chapter #1}}

\stoptext

Tom Benjey
717-258-9733 voice
717-243-0074 fax
Twitter: @TomBenjey


___
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] \numstr errors out in chapter star logic

2010-06-28 Thread Aditya Mahajan

On Mon, 28 Jun 2010, Wolfgang Schuster wrote:


Am 28.06.10 23:03, schrieb Tom:

Making the following changes resulted in ! Missing Number, treated as zero.



I’m lazy:

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,...]


or even

\defineconversion[numstring][\numstr]

and then everything works (except capitalization, that is)


\setuphead[chapter][conversion=numstring]
\starttext
\dorecurse{11}{\chapter{Chapter #1}}
\stoptext


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] \numstr errors out in chapter star logic

2010-06-28 Thread Wolfgang Schuster

Am 28.06.10 23:03, schrieb Tom:

Making the following changes resulted in ! Missing Number, treated as zero.
   


I’m lazy:

\defineconversion[numstring][One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,...]
\setuphead[chapter][conversion=numstring]
\starttext
\dorecurse{11}{\chapter{Chapter #1}}
\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] \numstr errors out in chapter star logic

2010-06-28 Thread Tom

Am 28.06.10 17:59, schrieb Tom:
> \numstr seems to work fine in the body of text but errors out as if #1 was
> not a number when it is used in chapter start loc. Here is an example:
>
> [...]
>
> \setuphead[chapter]
>   [command=\MyChapterCommandA]  %change A to B to eliminate \substr call
>

Try \setuphead[chapter][deepnumbercommand=\numstr]

Wolfgang

Making the following changes resulted in ! Missing Number, treated as zero.


%\def\MyChapterCommandA#1#2% #1 is number, #2 is text
%  {\numstr{#1}}

%\def\MyChapterCommandB#1#2% #1 is number, #2 is text
%  {#1  #2}

\setuphead[chapter]
 [deepnumbercommand=\numstr]  



Tom Benjey
717-258-9733 voice
717-243-0074 fax
Twitter: @TomBenjey


___
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] \numstr errors out in chapter star logic

2010-06-28 Thread Wolfgang Schuster

Am 28.06.10 17:59, schrieb Tom:

\numstr seems to work fine in the body of text but errors out as if #1 was
not a number when it is used in chapter start loc. Here is an example:

[...]

\setuphead[chapter]
  [command=\MyChapterCommandA]  %change A to B to eliminate \substr call
   


Try \setuphead[chapter][deepnumbercommand=\numstr]

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
___


[NTG-context] \numstr errors out in chapter star logic

2010-06-28 Thread Tom
\numstr seems to work fine in the body of text but errors out as if #1 was
not a number when it is used in chapter start loc. Here is an example:


%\numstr begins here

\unprotect

\def\numstring#1{\expandaft...@numstring\csname c...@#1\endcsname}

\d...@numstring#1{\ns@numstr{#1}...@nineteens{null}{}}

\let\nums...@numstring%

\def...@numoutofrange#1#2{\number#1#2}

\def...@numstr#1#2#3#4%
  {\ifnum\number#1<\plusone%
 #3%
   \else\ifnum\number#1<10 %
 \expandafter...@numstring\expandafter{\number#1}#2%
   \else%
 \...@numoutofrange{#1}{#4}%
   \fi\fi}

\def...@numstring#1#2{%
  \expandafter\ns@@numstring%
  \ifcase%
  \ifnum#1<10 1%
  \else\ifnum#1<100 2%
  \else\ifnum#1<\...@m 3%
  \else\ifnum#1<\...@m 4%
  \else\ifnum#1<10 5%
  \else\ifnum#1<100 6%
  \else\ifnum#1<1000 7%
  \else\ifnum#1<1 8%
  \else9%
  \fi\fi\fi\fi\fi\fi\fi\fi %
  \or#1% case 1: Add 8 leading zeros
  \or000#1%  case 2: Add 7 leading zeros
  \or00#1%   case 3: Add 6 leading zeros
  \or0#1%case 4: Add 5 leading zeros
  \or#1% case 5: Add 4 leading zeros
  \or000#1%  case 6: Add 3 leading zeros
  \or00#1%   case 7: Add 2 leading zeros
  \or0#1%case 8: Add 1 leading zero
  \or#1% case 9: Add no leading zeros
  \or%
  \...@nil#2%
  \fi}

\def\ns@@numstring#1#2#3#4#5#6#7\or...@nil#9%
  {\ifnum#1#2#3>\z@
   \...@million#1#2#3%
   \ifnum#4#5#6>\...@\space\fi%
   \fi%
   \ifnum#4#5#6>\...@%
   \...@hundred#4#5#6{#1#2#3}{#4#5}\ns@nineteen%
   \ifnum#4#5#6>\...@\space\fi%
   thousand%
   \ifnum#7>\...@\space\fi%
   \fi%
   \...@hundred#7{#4#5#6}1#9}

\def...@million#1#2#3%
  {\ifnum#1#2#3=\plusone%
   \...@hundred#1#2#301\ns@nineteene%
   \space%
   million%
   \else%
   \...@hundred#1#2#301\ns@nineteens%
   \space%
   millions%
   \fi}

\def...@hundred#1#2#3#4#5#6%
  {\ifnum#1>\...@%
   \ifnum#4#1>\...@\ns@nineteen#1\space\fi%
   hundred%
   \ifnum#2#3>\...@\space and\space\fi%
   \fi%
   \ifnum#2#3<20 %
   \ifnum#5#2#3>\...@#6{#2#3}\fi%
   \else%
   \...@ninety#2\ifnum#3>\...@-\ns@nineteen#3\fi%
   #60%
   \fi}

\def...@nineteen#1%
  {\ifcase#1\empty\or one\or two\or three\or four\or five\or six\or%
   seven\or eight\or nine\or ten\or eleven\or twelve\or thirteen\or%
   fourteen\or fifteen\or sixteen\or seventeen\or%
   eighteen\or nineteen\fi}

\def...@nineteens#1{\ns@nineteen{#1}}

\def...@nineteene#1{\ns@nineteen{#1}}


\def...@ninety#1%
  {\ifcase#1
   \or
   \or twenty%
   \or thirty%
   \or forty%
   \or fifty%
   \or sixty%
   \or seventy%
   \or eighty%
   \or ninety%
   \fi}

\protect


\def\MyChapterCommandA#1#2% #1 is number, #2 is text
  {\numstr{#1}}

\def\MyChapterCommandB#1#2% #1 is number, #2 is text
  {#1  #2}

\setuphead[chapter]
 [command=\MyChapterCommandA]  %change A to B to eliminate \substr call

\starttext

\chapter{First Chapter}

Some sample text. Chapter \numstr{1} numstr logic works correctly when
embedded in the text. Chapter title displays correctly when numstr not in
chapter start logic. Errors out when numstr is in chapter start logic as if
parameter is not a number.

\stoptext


Tom Benjey
717-258-9733 voice
717-243-0074 fax
Twitter: @TomBenjey






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