Changes

Jump to navigation Jump to search
489 bytes added ,  00:47, 4 August 2005
Edited text for clarity (and extraneous commas), added examples.
\framed{\obeyspaces{A gap from here to there!}}
</texcode>
 
<context>
\framed{\obeyspaces{A gap from here to there!}}
</context>
But if you pass this text as a parameter for your own macro
<texcode>
\def\TextWithSpaces#1{\framed{\obeyspaces#1}}%
\TextWithSpaces{A gap from here to there!}
</texcode>
<context>
\def\TextWithSpaces#1{\framed{\obeyspaces#1}}%
\TextWithSpaces{A gap from here to there!}
</texcodecontext>
the additional spaces are '''ignored'''.
The cause for this behaviour is, that This happens because the category code changeis not yet in effect whenstill has no effect herethe argument is parsed, and the spaces are removed during parsing. The To keepthe spaces, the catcode change must be done, '''before''' youpass the parameterargument is parsed.
Here is a two-part solution for the problem (''suggested by Taco Hoekwater''):
\def\doTextWithSpaces #1{#1\egroup}
</texcode>
 
Both of these produce the desired result:
 
<context>
\def \TextWithSpaces {\framed\bgroup\obeyspaces\doTextWithSpaces}
\def\doTextWithSpaces #1{#1\egroup}
 
\TextWithSpaces{A gap from here to there!}
</context>
Anonymous user

Navigation menu