Is there a \return command to end the current macro

errorspackage-writing

Is there a \return statement in Latex to end the current macro from being processed?

\if some condition
  \PackageError{mypackage}{main text}{help text}
  \return
\fi

I just think it would be more elegant than putting the main function of the macro within an \else statement. Or what is standard practice among package writers?

Best Answer

A macro is not a function call, it is textual expansion. So if you have

\def\abc{111  \return I don't want 222}

and used

  aaa \abc\ bbb

then the first thing that happens is that \abc gets expanded into the input buffer so TeX has seen aaa already but then the input is

aaa
   111  \return I don't want 222\ bbb

So if you want your \return to skip everything from \return to the end of the replacement text you are responsible for adding some marker at that point.

Related Question