* trailing spaces in macro argument
@ 2011-07-26 19:22 Daniel Schopper
2011-07-26 20:25 ` Wolfgang Schuster
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Schopper @ 2011-07-26 19:22 UTC (permalink / raw)
To: mailing list for ConTeXt users
Dear list,
could anyone be so kind to explain to me why in the following MWE the
trailing space are missing in the output of the \test-macro? I’m kind of
puzzled as I supposed it wouldn’t be possible for \stopline to influence
the behaviour of its preceding tokens. apologies for what's probably a
most straight-forward question to many of you…
\def\test#1{%
\startline[line:0]%
\pagereference[page:0]%
{#1}%
\stopline[line:0]%D commenting this out makes the trailing spaces in
the argument appear as expected.
}
\starttext
\startlinenumbering
One \test{ two three }four
\stoplinenumbering
\stoptext
Thanks!
Daniel
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: trailing spaces in macro argument
2011-07-26 19:22 trailing spaces in macro argument Daniel Schopper
@ 2011-07-26 20:25 ` Wolfgang Schuster
2011-07-26 20:57 ` Daniel Schopper
0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Schuster @ 2011-07-26 20:25 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 26.07.2011 um 21:22 schrieb Daniel Schopper:
> Dear list,
> could anyone be so kind to explain to me why in the following MWE the trailing space are missing in the output of the \test-macro? I’m kind of puzzled as I supposed it wouldn’t be possible for \stopline to influence the behaviour of its preceding tokens. apologies for what's probably a most straight-forward question to many of you…
It is possible as you can see in the following example:
\starttext
a b c
a b \removeunwantedspaces c
\stoptext
\stopline use \removeunwatedspaces and this is was the space was removed from the output.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: trailing spaces in macro argument
2011-07-26 20:25 ` Wolfgang Schuster
@ 2011-07-26 20:57 ` Daniel Schopper
2011-07-26 21:04 ` Wolfgang Schuster
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Schopper @ 2011-07-26 20:57 UTC (permalink / raw)
To: ntg-context
Thanks for the enlightenment!
So doing \def\removeunwantedspaces{} inside the macro definition does
the trick (although in a barbaric way)
Am 26.07.11 22:25, schrieb Wolfgang Schuster:
>
> Am 26.07.2011 um 21:22 schrieb Daniel Schopper:
>
>> Dear list,
>> could anyone be so kind to explain to me why in the following MWE the trailing space are missing in the output of the \test-macro? I’m kind of puzzled as I supposed it wouldn’t be possible for \stopline to influence the behaviour of its preceding tokens. apologies for what's probably a most straight-forward question to many of you…
>
> It is possible as you can see in the following example:
>
> \starttext
> a b c
>
> a b \removeunwantedspaces c
> \stoptext
>
> \stopline use \removeunwatedspaces and this is was the space was removed from the output.
>
> Wolfgang
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: trailing spaces in macro argument
2011-07-26 20:57 ` Daniel Schopper
@ 2011-07-26 21:04 ` Wolfgang Schuster
2011-07-26 21:28 ` Daniel Schopper
0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Schuster @ 2011-07-26 21:04 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 26.07.2011 um 22:57 schrieb Daniel Schopper:
> Thanks for the enlightenment!
> So doing \def\removeunwantedspaces{} inside the macro definition does the trick (although in a barbaric way)
Better add a space after the closing brace of the \test argument. As you don’t use grouping your redefinition is global and can break many other things.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: trailing spaces in macro argument
2011-07-26 21:04 ` Wolfgang Schuster
@ 2011-07-26 21:28 ` Daniel Schopper
2011-07-27 8:47 ` Wolfgang Schuster
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Schopper @ 2011-07-26 21:28 UTC (permalink / raw)
To: mailing list for ConTeXt users
>> So doing \def\removeunwantedspaces{} inside the macro definition
does the trick (although in a barbaric way)
> As you don’t use grouping your redefinition is global and can break
many other things.
Of course, I missed that! Adding \bgroup and \egroup right before and
after the \def does make it local and should prevent side effects then,
right? Thanks again…
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: trailing spaces in macro argument
2011-07-26 21:28 ` Daniel Schopper
@ 2011-07-27 8:47 ` Wolfgang Schuster
0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Schuster @ 2011-07-27 8:47 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 26.07.2011 um 23:28 schrieb Daniel Schopper:
> >> So doing \def\removeunwantedspaces{} inside the macro definition does the trick (although in a barbaric way)
> > As you don’t use grouping your redefinition is global and can break many other things.
>
> Of course, I missed that! Adding \bgroup and \egroup right before and after the \def does make it local and should prevent side effects then, right? Thanks again…
That’s not better, i would go with the following (although a better method to pass the references is necessary):
\def\test#1%
{\dontleavehmode
\startline[line:0]\pagereference[page:0]%
#1%
\stopline[line:0]}
\starttext
\startlinenumbering
One \test{two three} four
\stoplinenumbering
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-07-27 8:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 19:22 trailing spaces in macro argument Daniel Schopper
2011-07-26 20:25 ` Wolfgang Schuster
2011-07-26 20:57 ` Daniel Schopper
2011-07-26 21:04 ` Wolfgang Schuster
2011-07-26 21:28 ` Daniel Schopper
2011-07-27 8:47 ` 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).