trailing spaces in macro argument
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
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
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 ___________________________________________________________________________________
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
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…
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
participants (2)
-
Daniel Schopper
-
Wolfgang Schuster