\numstr errors out in chapter star logic
\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{\expandafter\@numstring\csname c@#1\endcsname} \def\@numstring#1{\ns@numstr{#1}\ns@nineteens{null}{}} \let\numstr\@numstring% \def\ns@numoutofrange#1#2{\number#1#2} \def\ns@numstr#1#2#3#4% {\ifnum\number#1<\plusone% #3% \else\ifnum\number#1<1000000000 % \expandafter\ns@numstring\expandafter{\number#1}#2% \else% \ns@numoutofrange{#1}{#4}% \fi\fi} \def\ns@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<100000 5% \else\ifnum#1<1000000 6% \else\ifnum#1<10000000 7% \else\ifnum#1<100000000 8% \else9% \fi\fi\fi\fi\fi\fi\fi\fi % \or00000000#1% case 1: Add 8 leading zeros \or0000000#1% case 2: Add 7 leading zeros \or000000#1% case 3: Add 6 leading zeros \or00000#1% case 4: Add 5 leading zeros \or0000#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#8\@nil#9% {\ifnum#1#2#3>\z@ \ns@million#1#2#3% \ifnum#4#5#6>\z@\space\fi% \fi% \ifnum#4#5#6>\z@% \ns@hundred#4#5#6{#1#2#3}{#4#5}\ns@nineteen% \ifnum#4#5#6>\z@\space\fi% thousand% \ifnum#7>\z@\space\fi% \fi% \ns@hundred#7{#4#5#6}1#9} \def\ns@million#1#2#3% {\ifnum#1#2#3=\plusone% \ns@hundred#1#2#301\ns@nineteene% \space% million% \else% \ns@hundred#1#2#301\ns@nineteens% \space% millions% \fi} \def\ns@hundred#1#2#3#4#5#6% {\ifnum#1>\z@% \ifnum#4#1>\z@\ns@nineteen#1\space\fi% hundred% \ifnum#2#3>\z@\space and\space\fi% \fi% \ifnum#2#3<20 % \ifnum#5#2#3>\z@#6{#2#3}\fi% \else% \ns@ninety#2\ifnum#3>\z@-\ns@nineteen#3\fi% #60% \fi} \def\ns@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\ns@nineteens#1{\ns@nineteen{#1}} \def\ns@nineteene#1{\ns@nineteen{#1}} \def\ns@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
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
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
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
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
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
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
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
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
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
-----Original Message----- From: ntg-context-bounces@ntg.nl [mailto:ntg-context-bounces@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
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
\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
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
participants (4)
-
Aditya Mahajan
-
Mojca Miklavec
-
Tom
-
Wolfgang Schuster