Extending the black circled numbers
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
Hello, For those who know, I'm trying to have the DocBook callout mechanism with context. Basically, there are some numbers in lines of verbatim text, and below the verbatim text the numbers are used to explain the portion of the text (kind of footnote). Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99. The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?) - What should I do to make them as anchors, so that it can be cross-referenced (I mean, one can click on a hot spot that jump to the number in the verbatim text). Thanks for any hint, \newdimen \cowidth % Maximum size of the circle fits for number 99 \def\evalwidth% {\bgroup% \setbox0\hbox{\small\bf{\ss 99}}% \global\cowidth=1.2\wd0% \egroup} % Background black circle \startuniqueMPgraphic{CoCircle} fill fullcircle scaled \overlaywidth withcolor black ; \stopuniqueMPgraphic \defineoverlay[cocircle][\uniqueMPgraphic{CoCircle}] % Display the black circled number \def\conum#1% {\evalwidth% \framed[background=cocircle,strut=no,frame=off, width=\the\cowidth,height=\the\cowidth,offset=overlay] {\color[white]{\small\bf{\ss #1}}}} \starttext \dorecurse{99}{\conum{\recurselevel}, } \stoptext Regards, BG
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
nico wrote:
Hello,
For those who know, I'm trying to have the DocBook callout mechanism with context. Basically, there are some numbers in lines of verbatim text, and below the verbatim text the numbers are used to explain the portion of the text (kind of footnote). Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?)
This is pretty smart, I'd say. Of course it would be better to have an official font with encircled numbers for reasons of efficiency, but this looks pretty good and the code is quite clean so i believe you did well enough. One remark only: if you would know that want them all the same size (beforehand), you can call \evalwidth only once.
- What should I do to make them as anchors, so that it can be cross-referenced (I mean, one can click on a hot spot that jump to the number in the verbatim text).
Like this maybe: \def\markline#1% {\conum{#1}% \expanded{\textreference[line#1]{\noexpand\conum{#1}}}} \def\refline#1{\in{line }[line#1]} \dorecurse{99}{\markline{\recurselevel}, } \dorecurse{99}{\refline{\recurselevel}, } Cheers, taco
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Tue, 04 Apr 2006 11:40:30 +0200, Taco Hoekwater
nico wrote:
Hello,
For those who know, I'm trying to have the DocBook callout mechanism with context. [...]. Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?)
This is pretty smart, I'd say. Of course it would be better to have an official font with encircled numbers for reasons of efficiency, but this looks pretty good and the code is quite clean so i believe you did well enough.
Ok, thanks.
One remark only: if you would know that want them all the same size (beforehand), you can call \evalwidth only once.
I tried this, but I had a weird behaviour with size (I have the same behaviour with the Hans example), and the other thing is that the size to use depends on the environment where you are. In the verbatim text (where I ask small font) the circled numbers must be smaller than in the current text flow.
- What should I do to make them as anchors, so that it can be cross-referenced (I mean, one can click on a hot spot that jump to the number in the verbatim text).
Like this maybe:
\def\markline#1% {\conum{#1}% \expanded{\textreference[line#1]{\noexpand\conum{#1}}}} \def\refline#1{\in{line }[line#1]}
\dorecurse{99}{\markline{\recurselevel}, } \dorecurse{99}{\refline{\recurselevel}, }
Yes, it works fine! Thanks much! Regards, BG
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
nico wrote:
Hello,
For those who know, I'm trying to have the DocBook callout mechanism with context. Basically, there are some numbers in lines of verbatim text, and below the verbatim text the numbers are used to explain the portion of the text (kind of footnote). Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?) - What should I do to make them as anchors, so that it can be cross-referenced (I mean, one can click on a hot spot that jump to the number in the verbatim text).
Thanks for any hint,
\newdimen \cowidth
% Maximum size of the circle fits for number 99 \def\evalwidth% {\bgroup% \setbox0\hbox{\small\bf{\ss 99}}% \global\cowidth=1.2\wd0% \egroup}
% Background black circle \startuniqueMPgraphic{CoCircle} fill fullcircle scaled \overlaywidth withcolor black ; \stopuniqueMPgraphic
\defineoverlay[cocircle][\uniqueMPgraphic{CoCircle}]
% Display the black circled number \def\conum#1% {\evalwidth% \framed[background=cocircle,strut=no,frame=off, width=\the\cowidth,height=\the\cowidth,offset=overlay] {\color[white]{\small\bf{\ss #1}}}}
\starttext
\dorecurse{99}{\conum{\recurselevel}, }
\stoptext
\setupcolors[state=start] \startuniqueMPgraphic{CoCircle} fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor OverlayColor ; \stopuniqueMPgraphic \defineoverlay[cocircle][\uniqueMPgraphic{CoCircle}] \definecolor[CoBackgroundColor] [red] \definecolor[CoForegroundColor] [white] \def\conum#1% {\setbox\scratchbox\hbox {\small\ss\bf \setbox\scratchbox\hbox{99}% \hbox to 1.2\wd\scratchbox{\hss#1\hss}}% \framed [background=cocircle, offset=overlay, frame=off, width=\the\wd\scratchbox, height=\the\wd\scratchbox, backgroundcolor=CoBackgroundColor, foregroundcolor=CoForegroundColor] {\box\scratchbox}} \starttext \dontleavehmode \dorecurse{99}{\conum{\recurselevel}, } \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Tue, 04 Apr 2006 14:44:28 +0200, Hans Hagen
nico wrote:
Hello,
Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?)
\setupcolors[state=start]
\startuniqueMPgraphic{CoCircle} fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor OverlayColor ; \stopuniqueMPgraphic
I see here the Hans touch again: it's better and I don't really understand how it works :-) But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this? Thanks much! Regards, BG
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
nico wrote:
On Tue, 04 Apr 2006 14:44:28 +0200, Hans Hagen
wrote: nico wrote:
Hello,
Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?)
\setupcolors[state=start]
\startuniqueMPgraphic{CoCircle} fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor OverlayColor ; \stopuniqueMPgraphic
I see here the Hans touch again: it's better and I don't really understand how it works :-) But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this?
what os the exact code that you use?how many mp runs do yuo have? Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Tue, 04 Apr 2006 22:50:58 +0200, Hans Hagen
nico wrote:
On Tue, 04 Apr 2006 14:44:28 +0200, Hans Hagen
wrote: nico wrote:
Hello,
Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?)
\setupcolors[state=start]
\startuniqueMPgraphic{CoCircle} fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor OverlayColor ; \stopuniqueMPgraphic
I see here the Hans touch again: it's better and I don't really understand how it works :-) But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this?
what os the exact code that you use?how many mp runs do yuo have?
It's exactly the one you gave. I attach the file I compile. Two mpruns; I attach the log too. Regards, BG
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
nico wrote:
On Tue, 04 Apr 2006 22:50:58 +0200, Hans Hagen
wrote: nico wrote:
On Tue, 04 Apr 2006 14:44:28 +0200, Hans Hagen
wrote: nico wrote:
Hello,
Typically the numbers are rendered white in black circle. I could use the Dingbats numbers, but it is limited to 10, so that I emulated them with the following code to be able to go up to 99.
The questions I have: - Is it the right way to do it in context (do I really need metafont? Simpler, smarter method?)
\setupcolors[state=start]
\startuniqueMPgraphic{CoCircle} fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor OverlayColor ; \stopuniqueMPgraphic
I see here the Hans touch again: it's better and I don't really understand how it works :-) But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this?
what os the exact code that you use?how many mp runs do yuo have?
It's exactly the one you gave. I attach the file I compile. Two mpruns; I attach the log too. one run here .. can you try the beta? i remember a spurious space problem someplace
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Wed, 05 Apr 2006 09:42:51 +0200, Hans Hagen
But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this?
what os the exact code that you use?how many mp runs do yuo have?
It's exactly the one you gave. I attach the file I compile. Two mpruns; I attach the log too. one run here .. can you try the beta? i remember a spurious space problem someplace
Same thing. I've found that I haven't the problem with producing dvi instead of pdf. I've limited the case to: \starttext \setbox\scratchbox\hbox {\small\ss\bf \setbox\scratchbox\hbox{99}% \hbox to 1.2\wd\scratchbox{\hss1\hss}} \writestatus{co}{width=\the\wd\scratchbox}% \setbox\scratchbox\hbox {\small\ss\bf \setbox\scratchbox\hbox{99}% \hbox to 1.2\wd\scratchbox{\hss1\hss}} \writestatus{co}{width=\the\wd\scratchbox}% \stoptext With --output=pdftex I have the log: (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) (./try.tuo) systems : begin file try at line 1 (/usr/local/share/texmf-local/tex/context/base/pdfr-ec.tex) co : width=16.5333pt co : width=13.19997pt systems : end file try at line 15 ) Should I update something else? texexec --version gives: TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005 texexec : TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005 texutil : TeXUtil 9.0.1 - ConTeXt / PRAGMA ADE 1992-2006 tex : pdfeTeX, 3.141592-1.21a-2.2 (Web2C 7.5.4) context : ver: 2006.04.05 20:06 cont-en : ver: 2006.04.05 20:06 fmt: 2006.4.5 mes: english Regards, BG
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Wed, 05 Apr 2006 21:59:36 +0200, nico
On Wed, 05 Apr 2006 09:42:51 +0200, Hans Hagen
wrote: But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this?
what os the exact code that you use?how many mp runs do yuo have?
It's exactly the one you gave. I attach the file I compile. Two mpruns; I attach the log too. one run here .. can you try the beta? i remember a spurious space problem someplace
Well, here is an even smaller test that shows the problem: \starttext \setbox0\hbox{\ss 99} \writestatus{co}{width=\the\wd0}% \setbox0\hbox{\ss 99} \writestatus{co}{width=\the\wd0}% \stoptext It seems to be related to some font loading stuff, since when I don't put \ss I haven't this. So, if I put the following in the test I have no more the problem. \setbox\scratchbox\hbox{\ss 99} % workaround to fix the strange size initialization... \starttext \dontleavehmode \dorecurse{99}{\conum{\recurselevel}, } \stoptext Regards, BG
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
nico wrote:
On Wed, 05 Apr 2006 21:59:36 +0200, nico
wrote: On Wed, 05 Apr 2006 09:42:51 +0200, Hans Hagen
wrote: But there's something strange: the first circle is greater than the others (but the numbers have all the same size). Tracing a bit I see that the first circle has a width=16.5333pt, the others 13.19997pt. What's the reason for this?
what os the exact code that you use?how many mp runs do yuo have?
It's exactly the one you gave. I attach the file I compile. Two mpruns; I attach the log too.
one run here .. can you try the beta? i remember a spurious space problem someplace
Well, here is an even smaller test that shows the problem:
\starttext
\setbox0\hbox{\ss 99} \writestatus{co}{width=\the\wd0}%
\setbox0\hbox{\ss 99} \writestatus{co}{width=\the\wd0}%
\stoptext
actually that file faile here because of a bug in pdftex that i ran into earlier todat (no text on the page, so an empty document, but an incomplete object being flushed) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
nico wrote:
It seems to be related to some font loading stuff, since when I don't put \ss I haven't this. So, if I put the following in the test I have no more the problem.
strange, here it shows twice the same size \starttext {\tracingall\setbox0\hbox{\ss 99}\the\wd0} \stoptext may give some info where a blank space (or so) creeps in Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Wed, 05 Apr 2006 22:52:33 +0200, Hans Hagen
nico wrote:
It seems to be related to some font loading stuff, since when I don't put \ss I haven't this. So, if I put the following in the test I have no more the problem.
strange, here it shows twice the same size
\starttext {\tracingall\setbox0\hbox{\ss 99}\the\wd0} \stoptext
may give some info where a blank space (or so) creeps in
Ok, you don't need to waste your time with this minor thing (that you cannot reproduce). Within the long verbose log there is: {into \box0= \hbox(8.333+0.0)x15.66658 []} {vertical mode: \setbox} {entering hbox group (level 2) at line 2} In fact a second setbox after gives: {leaving hbox group (level 2) entered at line 2} {changing \box0= \hbox(8.333+0.0)x15.66658 []} {into \box0= \hbox(8.333+0.0)x11.74997 []} {vertical mode: end-group character }} If you are still interested I can send you the full bzipped log (15KB), but you can stay at this step since I've an easy workaround. Thanks for your patience. Regards, BG
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Wed, 05 Apr 2006 22:52:33 +0200, Hans Hagen
nico wrote:
It seems to be related to some font loading stuff, since when I don't put \ss I haven't this. So, if I put the following in the test I have no more the problem.
strange, here it shows twice the same size
\starttext {\tracingall\setbox0\hbox{\ss 99}\the\wd0} \stoptext
may give some info where a blank space (or so) creeps in
Looking at the log, I've found blank spaces after "\pdfobj reserveobjnum" in enco-pfr.tex. Removing them makes the file compile ok (the bubbles are all the same :-). \def\dodoincludepdffontresource {% does this font has an encoding specified vector \doifsomething\currentencoding % no \ifx {% is there a pdf font encoding resource file defined \ifcsname\pdffontresource\endcsname % (fake) object defined \else\ifcsname\pdffontfileresource\endcsname % is there a resource already included \doifsomething\pdffontfileresource % --> {\pdfobj reserveobjnum {}% <-- blank space {\pdfobj reserveobjnum{}% \setxvalue\pdffontresource{\the\pdflastobj}% \flushatshipout{\dododoincludepdffontresource{\currentencoding}}}% % \doglobal\appendetoks % \noexpand\dododoincludepdffontresource{\currentencoding}% % \to \everybeforeshipout}% prevent multiple loading \fi\fi \ifcsname\pdffontresource\endcsname \expanded{\pdffontattr\font{/ToUnicode \csname\pdffontresource\endcsname\space0 R}}% % do it only once for each font \letgvalue{\s!ucmap\fontfile}\empty \fi}} ... \def\dodoincludepdffontresource {\doifsomething\currentencoding % no \ifx {\expandafter\ifx\csname\pdffontresource\endcsname\relax \expandafter\ifx\csname\pdffontfileresource\endcsname\relax\else \doifsomething\pdffontfileresource % --> {\pdfobj reserveobjnum {}% <-- blank space {\pdfobj reserveobjnum{}% \setxvalue\pdffontresource{\the\pdflastobj}% \flushatshipout{\dododoincludepdffontresource{\currentencoding}}}% % \doglobal\appendetoks % \noexpand\dododoincludepdffontresource{\currentencoding}% % \to \everybeforeshipout}% prevent multiple loading \fi \fi \expandafter\ifx\csname\pdffontresource\endcsname\relax\else \expanded{\pdffontattr\font{/ToUnicode \csname\pdffontresource\endcsname\space0 R}}% % do it only once for each font \letgvalue{\s!ucmap\fontfile}\empty \fi}} Regards, BG
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
nico wrote:
On Wed, 05 Apr 2006 22:52:33 +0200, Hans Hagen
wrote: nico wrote:
It seems to be related to some font loading stuff, since when I don't put \ss I haven't this. So, if I put the following in the test I have no more the problem.
strange, here it shows twice the same size
\starttext {\tracingall\setbox0\hbox{\ss 99}\the\wd0} \stoptext
may give some info where a blank space (or so) creeps in
Looking at the log, I've found blank spaces after "\pdfobj reserveobjnum" in enco-pfr.tex. Removing them makes the file compile ok (the bubbles are all the same :-).
indeed ... that code has been 'adapted' to the latest pdftex recently; clever deduction, once you can read such logs, you're an expert Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
nico
-
Taco Hoekwater