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
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
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
On Tue, 24 Oct 2006 18:39:22 +0200
Steffen Wolfrum
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
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/
On Tue, 24 Oct 2006 21:31:29 +0200 (CEST)
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 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
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 -----------------------------------------------------------------
" \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
On Wed, 25 Oct 2006 11:02:15 +0200
Steffen Wolfrum
" \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
participants (5)
-
Hans Hagen
-
Peter Münster
-
Steffen Wolfrum
-
Taco Hoekwater
-
Wolfgang Schuster