* pictures for numbers
@ 2001-11-16 9:55 Andres Loeh
2001-11-16 10:36 ` Taco Hoekwater
2001-11-16 11:53 ` Hans Hagen
0 siblings, 2 replies; 10+ messages in thread
From: Andres Loeh @ 2001-11-16 9:55 UTC (permalink / raw)
Hello,
I am writing a document where I want to give the chapter numbers as roman
numerals, but with each letter replaced by a (hand-drawn) picture (I have
them in .jpg ,.png,.eps).
I wonder what would be the best approach to do it:
(1) make some kind of virtual (or real) font out of the pictures
(but how?)
(2) write a macro that expands numbers to a sequence of
\useexternalfigure calls; then define a conversion that
makes use of that macro
(3) write a macro that transforms the output of \romannumeral
into a sequence of \useexternalfigure calls; then define
a conversion that makes use of that macro
(4) ... ?
I succeeded in writing something like (2), but I would find both (1) and
(3) more elegant. What do you think is the best way to proceed? Am I
missing something completely?
Thanks for your help,
Andres
--
Andres Loeh, Universiteit Utrecht
mailto:andres@cs.uu.nl mailto:mail@andres-loeh.de
http://www.andres-loeh.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pictures for numbers
2001-11-16 9:55 pictures for numbers Andres Loeh
@ 2001-11-16 10:36 ` Taco Hoekwater
2001-11-16 11:55 ` Hans Hagen
2001-11-16 11:53 ` Hans Hagen
1 sibling, 1 reply; 10+ messages in thread
From: Taco Hoekwater @ 2001-11-16 10:36 UTC (permalink / raw)
Cc: ntg-context
"Andres Loeh" <andres@cs.uu.nl> wrote:
> Hello,
>
> I am writing a document where I want to give the chapter numbers as roman
> numerals, but with each letter replaced by a (hand-drawn) picture (I have
> them in .jpg ,.png,.eps).
>
> I wonder what would be the best approach to do it:
>
> (1) make some kind of virtual (or real) font out of the pictures
> (but how?)
This definately sounds elegant, but it is quite a large amount of work.
> (3) write a macro that transforms the output of \romannumeral
> into a sequence of \useexternalfigure calls; then define
> a conversion that makes use of that macro
This is the next best bet, I think. Here is a macro that does the
key work. You have to change the \message to do what you want:
\def\expandromannumerals#1%
{\expandafter\expandromannumeral\romannumeral #1\relax}
\def\expandromannumeral#1%
{\if #1\relax
\let\next\relax
\else
\message{#1}%
\let\next\expandromannumeral
\fi
\next }
\expandromannumerals{19}% call example
--
groeten,
Taco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pictures for numbers
2001-11-16 10:36 ` Taco Hoekwater
@ 2001-11-16 11:55 ` Hans Hagen
0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2001-11-16 11:55 UTC (permalink / raw)
Cc: Andres Loeh, ntg-context
Hi Taco,
fyi: there is now a fully expandable \Romannumerals
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | pragma@wxs.nl
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pictures for numbers
2001-11-16 9:55 pictures for numbers Andres Loeh
2001-11-16 10:36 ` Taco Hoekwater
@ 2001-11-16 11:53 ` Hans Hagen
2001-11-16 15:06 ` [ConTeXt] " Andres Loeh
2001-11-16 15:29 ` Andres Loeh
1 sibling, 2 replies; 10+ messages in thread
From: Hans Hagen @ 2001-11-16 11:53 UTC (permalink / raw)
Cc: ntg-context
At 10:55 AM 11/16/2001 +0100, Andres Loeh wrote:
>Hello,
>
>I am writing a document where I want to give the chapter numbers as roman
>numerals, but with each letter replaced by a (hand-drawn) picture (I have
>them in .jpg ,.png,.eps).
>
>I wonder what would be the best approach to do it:
>
>(1) make some kind of virtual (or real) font out of the pictures
> (but how?)
>
>(2) write a macro that expands numbers to a sequence of
> \useexternalfigure calls; then define a conversion that
> makes use of that macro
>
>(3) write a macro that transforms the output of \romannumeral
> into a sequence of \useexternalfigure calls; then define
> a conversion that makes use of that macro
>
>(4) ... ?
>
>I succeeded in writing something like (2), but I would find both (1) and
>(3) more elegant. What do you think is the best way to proceed? Am I
>missing something completely?
given that you have figures like picture-number you can define a conversion
like:
\def\HandDrawnRomanNumeral#1{\externalfigure[picture-#1][height=1cm]}
\defineconversion[handdrawnromannumeral][\HandDrawnRomanNumeral]
but, this is probably not what you want, so better is:
\setuphead[chapter][numbercommand=\NumberCommand]
\def\NumberCommand#1%
{\externalfigure[picture-\currentheadnumber][height=1cm]}
we cannot use #1 because it is more that the number; \currentheadnumber is
available in the latest version
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | pragma@wxs.nl
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [ConTeXt] Re: pictures for numbers
2001-11-16 11:53 ` Hans Hagen
@ 2001-11-16 15:06 ` Andres Loeh
2001-11-16 16:37 ` Hans Hagen
2001-11-16 15:29 ` Andres Loeh
1 sibling, 1 reply; 10+ messages in thread
From: Andres Loeh @ 2001-11-16 15:06 UTC (permalink / raw)
Cc: ntg-context
> Date: Fri, 16 Nov 2001 12:53:14 +0100
> From: Hans Hagen <pragma@wxs.nl>
> Subject: [ConTeXt] Re: pictures for numbers
Hello again,
thanks for your help so far. I tried to construct a solution out of
Taco's and your remarks, and I got that far:
%--BEGIN
\useexternalfigure [sleutelI] [sleutelsI_new] [height=3ex]
\useexternalfigure [sleutelV] [sleutelsV_new] [height=3ex]
\useexternalfigure [sleutelX] [sleutelsX_new] [height=3ex]
\def\Sleutels#1%
{\hbox{\expandafter\DoSleutels\romannumeral #1\relax}\relax}
\def\DoSleutels#1%
{\if #1\relax
\let\next\relax
\else
\if #1i%
\externalfigure[sleutelI]
\else
\if #1v%
\externalfigure[sleutelV]
\else
\if #1x%
\externalfigure[sleutelX]
\else
\relax
\fi
\fi
\fi
\let\next\DoSleutels
\fi
\next}
%(1)% \setuphead[chapter][numbercommand=\Sleutels]
%(2)% \defineconversion[sleutels][\Sleutels]
%(2)% \setupsection [section-2] [conversion=sleutels]
\starttext
\Sleutels{34}
\chapter {Test}
\stoptext
%--END
The generation of the pictures works perfectly as
a standalone function. However, I want them to appear
as chapter numbers. If I uncomment either the line marked
%(1)% or the lines marked %(2)%, I get errors:
(1):
! Missing number, treated as zero.
<to be read again>
\edef
\setstrutdimen ...strutdimen =#3\strutdimen \edef
#1{\the \strutdimen }
\setstrut ...ht \strutheightfactor \spacingfactor
\setstrutdimen \strutdepth...
<argument> \setstrut
\begstrut \sectiebloklabel {\v!hoofdstuk }{\finalsectio...
\Sleutels ...andafter \DoSleutels \romannumeral #1
\relax }\relax
<argument> ...k }{\finalsectionnumber }\endstrut }
\else \getvalue {\??ko \v!...
..
l.39 \chapter {Test}
(2):
! Extra \else.
\DoSleutels ...f #1\relax \let \next \relax \else
\if #1i\externalfigure [sl...
\DoSleutels ...\fi \fi \let \next \DoSleutels \fi
\next
<to be read again>
\relax
\Sleutels ...r \DoSleutels \romannumeral #1\relax
}\relax
\@@sectionconversion ...??se #1\c!conversie }}{#2}
\fi \else \getvalue {\??cv...
\@@shortsectionnumber ...#1}{\@@sectionvalue {#1}}
\fi \else \@@sectionconver...
..
l.39 \chapter {Test}
What am I doing wrong? [I am using the ConTeXt version from the
newest TeXLive CD.]
Groeten,
Andres
--
Andres Loeh, Universiteit Utrecht
mailto:andres@cs.uu.nl mailto:mail@andres-loeh.de
http://www.andres-loeh.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [ConTeXt] Re: pictures for numbers
2001-11-16 15:06 ` [ConTeXt] " Andres Loeh
@ 2001-11-16 16:37 ` Hans Hagen
0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2001-11-16 16:37 UTC (permalink / raw)
Cc: ntg-context
At 04:06 PM 11/16/2001 +0100, Andres Loeh wrote:
> > Date: Fri, 16 Nov 2001 12:53:14 +0100
> > From: Hans Hagen <pragma@wxs.nl>
> > Subject: [ConTeXt] Re: pictures for numbers
>
>Hello again,
>
>thanks for your help so far. I tried to construct a solution out of
>Taco's and your remarks, and I got that far:
>
>%--BEGIN
>\useexternalfigure [sleutelI] [sleutelsI_new] [height=3ex]
>\useexternalfigure [sleutelV] [sleutelsV_new] [height=3ex]
>\useexternalfigure [sleutelX] [sleutelsX_new] [height=3ex]
>
>\def\Sleutels#1%
> {\hbox{\expandafter\DoSleutels\romannumeral #1\relax}\relax}
>
>\def\DoSleutels#1%
> {\if #1\relax
> \let\next\relax
> \else
> \if #1i%
> \externalfigure[sleutelI]
> \else
> \if #1v%
> \externalfigure[sleutelV]
> \else
> \if #1x%
> \externalfigure[sleutelX]
> \else
> \relax
> \fi
> \fi
> \fi
> \let\next\DoSleutels
> \fi
> \next}
>
>The generation of the pictures works perfectly as
>a standalone function. However, I want them to appear
>as chapter numbers. If I uncomment either the line marked
>%(1)% or the lines marked %(2)%, I get errors:
>
>(1):
As said, the #1 is not really a number but a whole bunch of info, liek font
switches; try \showargument{#1} in your macro and you will see what i mean.
This is why you need the alternative that i send you. That one uses the raw
number. If you want an uppercase rommannumeral, use
\def\MyNiceNumber#1%
{\edef\TheRomanNumber{\Romannumerals\currentheadnumber}%
\expandafter\handletokens\TheRomanNumber\with\MyRomanPicture}
\def\MyRomanPicture#1%
{\hbox{\externalfigure[RomanDigit#1][widyh=1cm]}}
\setuphead[chapter][numbercommand=\MyNiceNumber]
\dorecurse{25}{\chapter{It Works}}
For this to work you need the following macro (which i made for patrick
some weeks ago, in core-con, but that one generates a \relax:
\def\doRomannumerals#1#2\relax % spaces after ifcase prevent \relax
{\ifnum#1#2<10
\ifcase0#1#2 \or I\or II\or III\or IV\or V\or VI\or VII\or VIII\or IX\fi
\else\ifnum#1#2<100
\ifcase0#1 \or X\or XX\or XXX\or XL\or L\or LX\or LXX\or LXXX\or XC\fi
\doRomannumerals#2\relax
\else\ifnum#1#2<1000
\ifcase0#1 \or C\or CC\or CCC\or CD\or D\or DC\or DCC\or DCCC\or CM\fi
\doRomannumerals#2\relax
\else\ifnum#1#2<4000
\ifcase0#1 \or M\or MM\or MMM\fi
\doRomannumerals#2\relax
\else
\uppercase\expandafter{\romannumeral#1#2}%
\fi\fi\fi\fi}
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | pragma@wxs.nl
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pictures for numbers
2001-11-16 11:53 ` Hans Hagen
2001-11-16 15:06 ` [ConTeXt] " Andres Loeh
@ 2001-11-16 15:29 ` Andres Loeh
2001-11-16 16:38 ` Hans Hagen
1 sibling, 1 reply; 10+ messages in thread
From: Andres Loeh @ 2001-11-16 15:29 UTC (permalink / raw)
Cc: ntg-context
> \setuphead[chapter][numbercommand=\NumberCommand]
>
> \def\NumberCommand#1%
> {\externalfigure[picture-\currentheadnumber][height=1cm]}
>
> we cannot use #1 because it is more that the number; \currentheadnumber is
> available in the latest version
Sorry, in the previous mail I did not make use of your comment about
\currentheadnumber. The solution to add
\setuphead[chapter][numbercommand=\MakeSleutels]
\def\MakeSleutels#1%
{\Sleutels\currentheadnumber}
^^^^^^^^^^^^^^^^^^ (instead of #1)
actually seems to work perfectly. But nevertheless I'd still be interested
why defining the conversion does not work ...
Groeten,
Andres
--
Andres Loeh, Universiteit Utrecht
mailto:andres@cs.uu.nl mailto:mail@andres-loeh.de
http://www.andres-loeh.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pictures for numbers
2001-11-16 15:29 ` Andres Loeh
@ 2001-11-16 16:38 ` Hans Hagen
0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2001-11-16 16:38 UTC (permalink / raw)
Cc: ntg-context
At 04:29 PM 11/16/2001 +0100, Andres Loeh wrote:
> > \setuphead[chapter][numbercommand=\NumberCommand]
> >
> > \def\NumberCommand#1%
> > {\externalfigure[picture-\currentheadnumber][height=1cm]}
> >
> > we cannot use #1 because it is more that the number; \currentheadnumber is
> > available in the latest version
>
>Sorry, in the previous mail I did not make use of your comment about
>\currentheadnumber. The solution to add
>
>\setuphead[chapter][numbercommand=\MakeSleutels]
>
>\def\MakeSleutels#1%
> {\Sleutels\currentheadnumber}
> ^^^^^^^^^^^^^^^^^^ (instead of #1)
>
>actually seems to work perfectly. But nevertheless I'd still be interested
>why defining the conversion does not work ...
try: \showargument{#1} inside \MakeSleutels
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | pragma@wxs.nl
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <Your message of "Fri, 16 Nov 2001 16:06:37 +0100." <20011116160637.G29519@cs.uu.nl>]
* Re: [ConTeXt] Re: pictures for numbers
@ 2001-11-16 15:47 ` Patrick Gundlach
2001-11-16 16:48 ` Hans Hagen
0 siblings, 1 reply; 10+ messages in thread
From: Patrick Gundlach @ 2001-11-16 15:47 UTC (permalink / raw)
Hi!
[...]
> \def\Sleutels#1%
> {\hbox{\expandafter\DoSleutels\romannumeral #1\relax}\relax}
[...]
> %(1)% \setuphead[chapter][numbercommand=\Sleutels]
> (1):
> ! Missing number, treated as zero.
> <to be read again>
> \edef
> \setstrutdimen ...strutdimen =#3\strutdimen \edef
> #1{\the \strutdimen }
maybe this is the same problem I had a short time ago.
In the new core-con.tex there is:
\def\Romannumerals#1%
{\expandafter\doRomannumerals\number#1\relax}
\def\doRomannumerals#1#2\relax
{\ifnum#1#2<10
\ifcase0#1#2\or I\or II\or III\or IV\or V\or VI\or VII\or VIII\or IX\fi
\else\ifnum#1#2<100
\ifcase 0#1\or X\or XX\or XXX\or XL\or L\or LX\or LXX\or LXXX\or XC\fi
\doRomannumerals#2\relax
\else\ifnum#1#2<1000
\ifcase 0#1\or C\or CC\or CCC\or CD\or D\or DC\or DCC\or DCCC\or CM\fi
\doRomannumerals#2\relax
\else\ifnum#1#2<4000
\ifcase 0#1\or M\or MM\or MMM\fi
\doRomannumerals#2\relax
\else
\uppercase\expandafter{\romannumeral#1#2}%
\fi\fi\fi\fi}
[this should go in core-con.tex]
Viele Grüße,
Patrick Gundlach
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [ConTeXt] Re: pictures for numbers
2001-11-16 15:47 ` [ConTeXt] " Patrick Gundlach
@ 2001-11-16 16:48 ` Hans Hagen
0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2001-11-16 16:48 UTC (permalink / raw)
Cc: ntg-context
At 04:47 PM 11/16/2001 +0100, Patrick Gundlach wrote
>[this should go in core-con.tex]
it is already; watch out for the patch in the previous mail
[to avoid tex's auto inserted \relax's]
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | pragma@wxs.nl
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2001-11-16 16:48 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-16 9:55 pictures for numbers Andres Loeh
2001-11-16 10:36 ` Taco Hoekwater
2001-11-16 11:55 ` Hans Hagen
2001-11-16 11:53 ` Hans Hagen
2001-11-16 15:06 ` [ConTeXt] " Andres Loeh
2001-11-16 16:37 ` Hans Hagen
2001-11-16 15:29 ` Andres Loeh
2001-11-16 16:38 ` Hans Hagen
[not found] <Your message of "Fri, 16 Nov 2001 16:06:37 +0100." <20011116160637.G29519@cs.uu.nl>
2001-11-16 15:47 ` [ConTeXt] " Patrick Gundlach
2001-11-16 16:48 ` 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).