ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* character width
@ 2006-10-24 11:31 Steffen Wolfrum
  2006-10-24 12:55 ` Taco Hoekwater
  0 siblings, 1 reply; 9+ messages in thread
From: Steffen Wolfrum @ 2006-10-24 11:31 UTC (permalink / raw)


Hi,

for fine-adjusting I need to have a variable horizontal space  
sometimes the width of "999" sometimes of "1", for example.
Is there a command that reads the width of a character so it can be  
used in some kind of horizontal space?

Steffen

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 11:31 character width Steffen Wolfrum
@ 2006-10-24 12:55 ` Taco Hoekwater
  2006-10-24 16:39   ` Steffen Wolfrum
  0 siblings, 1 reply; 9+ messages in thread
From: Taco Hoekwater @ 2006-10-24 12:55 UTC (permalink / raw)




Steffen Wolfrum wrote:
> Hi,
> 
> for fine-adjusting I need to have a variable horizontal space  
> sometimes the width of "999" sometimes of "1", for example.
> Is there a command that reads the width of a character so it can be  
> used in some kind of horizontal space?

There is a \fontcharwd primitive to measure the width of a single
character is a specific font:

   \hskip \the\fontcharwd \font `1

but it may be easier to put the number(s) in a box and measure the
width of that:

   \setbox\scratchbox=\hbox{999}%
   \hskip \the\wd \scratchbox

Greetings, Taco

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 12:55 ` Taco Hoekwater
@ 2006-10-24 16:39   ` Steffen Wolfrum
  2006-10-24 18:45     ` Wolfgang Schuster
  0 siblings, 1 reply; 9+ messages in thread
From: Steffen Wolfrum @ 2006-10-24 16:39 UTC (permalink / raw)


Yes, that's it. Thank you!

But can it also be defined in a more handy   \MySpace[999]   ?
Sorry, I tried some \def ... but didn't succeed.

Steffen



Am 24.10.2006 um 14:55 schrieb Taco Hoekwater:

>
>
> Steffen Wolfrum wrote:
>> Hi,
>>
>> for fine-adjusting I need to have a variable horizontal space
>> sometimes the width of "999" sometimes of "1", for example.
>> Is there a command that reads the width of a character so it can be
>> used in some kind of horizontal space?
>
> There is a \fontcharwd primitive to measure the width of a single
> character is a specific font:
>
>    \hskip \the\fontcharwd \font `1
>
> but it may be easier to put the number(s) in a box and measure the
> width of that:
>
>    \setbox\scratchbox=\hbox{999}%
>    \hskip \the\wd \scratchbox
>
> Greetings, Taco
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 16:39   ` Steffen Wolfrum
@ 2006-10-24 18:45     ` Wolfgang Schuster
  2006-10-24 19:31       ` Peter Münster
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2006-10-24 18:45 UTC (permalink / raw)


On Tue, 24 Oct 2006 18:39:22 +0200
Steffen Wolfrum <context@st.estfiles.de> wrote:

> Yes, that's it. Thank you!
> 
> But can it also be defined in a more handy   \MySpace[999]   ?
> Sorry, I tried some \def ... but didn't succeed.
> 
> Steffen
> 
> 
> 
> Am 24.10.2006 um 14:55 schrieb Taco Hoekwater:
> 
> >
> >
> > Steffen Wolfrum wrote:
> >> Hi,
> >>
> >> for fine-adjusting I need to have a variable horizontal space
> >> sometimes the width of "999" sometimes of "1", for example.
> >> Is there a command that reads the width of a character so it can be
> >> used in some kind of horizontal space?
> >
> > There is a \fontcharwd primitive to measure the width of a single
> > character is a specific font:
> >
> >    \hskip \the\fontcharwd \font `1
> >
> > but it may be easier to put the number(s) in a box and measure the
> > width of that:
> >
> >    \setbox\scratchbox=\hbox{999}%
> >    \hskip \the\wd \scratchbox
> >
> > Greetings, Taco

Hi Steffen,

your solution based on the method provided by Taco.

\def\MySpace
  {\dosingleempty\doMySpace}

\def\doMySpace[#1]%
  {\setbox\scratchbox=\hbox{#1}%
   \unskip\hskip \the\wd \scratchbox}

\starttext

Text\MySpace[999]Text

Text\MySpace[999] Text

Text \MySpace[999]Text

Text \MySpace[999] Text

\stoptext

Wolfgang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 18:45     ` Wolfgang Schuster
@ 2006-10-24 19:31       ` Peter Münster
  2006-10-24 20:01         ` Wolfgang Schuster
  2006-10-25  9:02         ` Steffen Wolfrum
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Münster @ 2006-10-24 19:31 UTC (permalink / raw)


On Tue, 24 Oct 2006, Wolfgang Schuster wrote:

> \def\MySpace
>   {\dosingleempty\doMySpace}
> 
> \def\doMySpace[#1]%
>   {\setbox\scratchbox=\hbox{#1}%
>    \unskip\hskip \the\wd \scratchbox}

Or perhaps just:

\starttext
Text\hphantom{999}Text
\stoptext

?

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 19:31       ` Peter Münster
@ 2006-10-24 20:01         ` Wolfgang Schuster
  2006-10-25 20:38           ` Hans Hagen
  2006-10-25  9:02         ` Steffen Wolfrum
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2006-10-24 20:01 UTC (permalink / raw)


On Tue, 24 Oct 2006 21:31:29 +0200 (CEST)
Peter Münster <pmlists@free.fr> wrote:

> On Tue, 24 Oct 2006, Wolfgang Schuster wrote:
> 
> > \def\MySpace
> >   {\dosingleempty\doMySpace}
> > 
> > \def\doMySpace[#1]%
> >   {\setbox\scratchbox=\hbox{#1}%
> >    \unskip\hskip \the\wd \scratchbox}
> 
> Or perhaps just:
> 
> \starttext
> Text\hphantom{999}Text
> \stoptext
> 
> ?
> 
> Cheers, Peter
> 

Hi Peter,

right this also works but we wont care about spaces in the souce.

Look:

\starttext

Text\hphantom{999}Text

Text\hphantom{999} Text

Text \hphantom{999} Text

\stoptext


Antoher solution for the spacemacro:

\def\MySpace
  {\dosingleempty\doMySpace}

\def\doMySpace[#1]%
  {\unskip\hphantom{#1}\ignorespaces}

\starttext

Text\hphantom{999}Text

Text\hphantom{999} Text

Text \hphantom{999} Text

\stoptext

and we have always the same gap.

Wolfgang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 19:31       ` Peter Münster
  2006-10-24 20:01         ` Wolfgang Schuster
@ 2006-10-25  9:02         ` Steffen Wolfrum
  2006-10-30 18:56           ` Wolfgang Schuster
  1 sibling, 1 reply; 9+ messages in thread
From: Steffen Wolfrum @ 2006-10-25  9:02 UTC (permalink / raw)


" \hphantom " ! What a promising word for exactly what I needed!
Again and again I am surprised how many (strange) commands there  
exist. Where does \hphantom come frome? Where is it documented?

Thank you for your replies! But it could be even better:

As I need, finally, a construct like ...
\writetolist[Test]{}{{\hphantom{999}}{\hfill}\bf{Nicely centers TOC  
entry}{\hfill}\it 999}
... I would like to make sure that both manually entered numbers are  
the same (I don't want to risk a typo!).

So I'd like to use something like \def\FakePageNumber{999}, using  
\FakePageNumber at the beginning and the end of the above line.

The following worked ...
\expanded{\writetolist[Test]{}{\hfill {\bf Nicely centers TOC entry}  
\hfill \FakePageNumber}}
... but not in combination with \MySpace or \hphantom anymore:
\expanded{\writetolist[Test]{}{???\hfill {\bf Nicely centers TOC  
entry} \hfill \FakePageNumber}}

Could someone please help me over this "expanded/argument/ 
whateveristheproblem" gap?


Thank you very much,
Steffen




Am 24.10.2006 um 21:31 schrieb Peter Münster:

> On Tue, 24 Oct 2006, Wolfgang Schuster wrote:
>
>> \def\MySpace
>>   {\dosingleempty\doMySpace}
>>
>> \def\doMySpace[#1]%
>>   {\setbox\scratchbox=\hbox{#1}%
>>    \unskip\hskip \the\wd \scratchbox}
>
> Or perhaps just:
>
> \starttext
> Text\hphantom{999}Text
> \stoptext
>
> ?
>
> Cheers, Peter
>
> -- 
> http://pmrb.free.fr/contact/
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-24 20:01         ` Wolfgang Schuster
@ 2006-10-25 20:38           ` Hans Hagen
  0 siblings, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2006-10-25 20:38 UTC (permalink / raw)


Wolfgang Schuster wrote:
>
> \def\doMySpace[#1]%
>   {\unskip\hphantom{#1}\ignorespaces}
>   
\ifhmode\unskip\fi

or use \removeunwantedspaces

 

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: character width
  2006-10-25  9:02         ` Steffen Wolfrum
@ 2006-10-30 18:56           ` Wolfgang Schuster
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2006-10-30 18:56 UTC (permalink / raw)


On Wed, 25 Oct 2006 11:02:15 +0200
Steffen Wolfrum <context@st.estfiles.de> wrote:

> " \hphantom " ! What a promising word for exactly what I needed!
> Again and again I am surprised how many (strange) commands there  
> exist. Where does \hphantom come frome? Where is it documented?
> 
> Thank you for your replies! But it could be even better:
> 
> As I need, finally, a construct like ...
> \writetolist[Test]{}{{\hphantom{999}}{\hfill}\bf{Nicely centers TOC  
> entry}{\hfill}\it 999}
> ... I would like to make sure that both manually entered numbers are  
> the same (I don't want to risk a typo!).
> 
> So I'd like to use something like \def\FakePageNumber{999}, using  
> \FakePageNumber at the beginning and the end of the above line.
> 
> The following worked ...
> \expanded{\writetolist[Test]{}{\hfill {\bf Nicely centers TOC entry}  
> \hfill \FakePageNumber}}
> ... but not in combination with \MySpace or \hphantom anymore:
> \expanded{\writetolist[Test]{}{???\hfill {\bf Nicely centers TOC  
> entry} \hfill \FakePageNumber}}
> 
> Could someone please help me over this "expanded/argument/ 
> whateveristheproblem" gap?
> 
> 
> Thank you very much,
> Steffen
> 
> 
> 
> 
> Am 24.10.2006 um 21:31 schrieb Peter Münster:
> 
> > On Tue, 24 Oct 2006, Wolfgang Schuster wrote:
> >
> >> \def\MySpace
> >>   {\dosingleempty\doMySpace}
> >>
> >> \def\doMySpace[#1]%
> >>   {\setbox\scratchbox=\hbox{#1}%
> >>    \unskip\hskip \the\wd \scratchbox}
> >
> > Or perhaps just:
> >
> > \starttext
> > Text\hphantom{999}Text
> > \stoptext
> >
> > ?
> >
> > Cheers, Peter
> >

Hi Steffen,

I presnt you a few solution to your problem, I don't how it 
should look to you. 

<example>

\def\FakePageNumber{999}

\starttext

\placecontent

\section{Knuth}

\input knuth

% your solution

\expanded{\writetolist[section]{}{\hfill{\bf Nicely centers TOC entry}
\hfill\FakePageNumber}}

% solution 1

\writetolist[section]{}{\hfill {\bf Nicely centers TOC entry} \hfill \llap{\FakePageNumber}}

% solution 2

\writetolist[section]{}{\hfilll bla \hfilll \llap{\FakePageNumber}}

% solution 3

\writebetweenlist[section]{\hfilll bla \hfilll \llap{\FakePageNumber}}

\section{Knuth}

\input knuth

\stoptext

</example>


Wolfgang

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-10-30 18:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-24 11:31 character width Steffen Wolfrum
2006-10-24 12:55 ` Taco Hoekwater
2006-10-24 16:39   ` Steffen Wolfrum
2006-10-24 18:45     ` Wolfgang Schuster
2006-10-24 19:31       ` Peter Münster
2006-10-24 20:01         ` Wolfgang Schuster
2006-10-25 20:38           ` Hans Hagen
2006-10-25  9:02         ` Steffen Wolfrum
2006-10-30 18:56           ` Wolfgang Schuster

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).