1

Is it possible to define a macro in ConTeXt which gobbles space after the argument? For example, given this input:

\def\thing{\dosingleargument\dothing}
\def\dothing[#1]{thing#1}

\starttext

\thing[hello]
\thing[world]

\stoptext

This produces the following output:

thinghello thingworld

But, ideally, I'd like it to run together, like this:

thinghellothingworld

I realise I can use \thing[hello]%, but just wondering whether there's something easy I may have missed here. These \thing commands are currently being generated by a script. I could configure the script to output the %, but the TeX file is likely to be tweaked by hand afterwards, where it's possible the % may end up missing, and then the space appears again, so I'd like to try and reduce this possible human error and keep the TeX file looking tidy.

6
  • Plain TeX and LaTeX have \ignorespaces, so probably context has too.
    – campa
    Feb 18 '21 at 12:26
  • It worked! Please post it as an answer.
    – dreamlax
    Feb 18 '21 at 12:31
  • 1
    Erm, it was a guess, I don't even know how to run context, so no, I won't post an answer. Feel free to post it yourself.
    – campa
    Feb 18 '21 at 12:32
  • Suit yourself :)
    – dreamlax
    Feb 18 '21 at 13:08
  • @campa As easy as context <jobname> Feb 18 '21 at 13:51
2

There may be a better way to do this in ConTeXt, but the spurious space was removed after placing \ignorespaces as the end of the macro definition:

\def\thing{\dosingleargument\dothing}
\def\dothing[#1]{thing#1\ignorespaces}
1
  • 1
    \ignorespaces is the canonical way to do this in ConTeXt.
    – Aditya
    Mar 4 '21 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.