I have a macro that (simplified) is defined like this:

     %use #1

I'd like to be able to use it like

\mymacro{Arg 1}
Beginning of paragraph

However, my output PDF file has a bit of horizontal space before the B when I do this.

To get rid of it, I must call it like

\mymacro{Arg 1}Beginning of paragraph

which is not ideal.

If I change \mymacro to not take any arguments, the space goes away too---but I need to be able to take arguments.

  • Welcome to TeX.SE. – Peter Grill Dec 4 '11 at 1:00
  • 2
    By the way, both yours and @PeterGrill's examples have useless %'s: there's no need to put them after the control words \noindent or \ignorespaces. It's possible you were expecting the percent there to gobble spaces following the use of the macro, but in fact, that percent is removed (along with the following newline) when the macro itself is defined. Since spaces are ignored after control words anyway, it has no effect at all. On the other hand, you should take note of @Peter's use of % after the opening brace, which does have an effect. – Ryan Reich Dec 4 '11 at 1:27
  • What is the effect of the % after the opening brace? – Aaron Yodaiken Dec 4 '11 at 1:34
  • 1
    The % after the opening brace suppresses the space that will get inserted otherwise. I normall add a % at end of lines in the preamble even if they are not necessary as I learned my lesson in tex capacity exceeded if remove % after use of macro – Peter Grill Dec 4 '11 at 1:45

Use \par\noindent\ignorespaces in the macro's definition.


  use #1%



\mymacro{Arg 1}
Beginning of paragraph: \lipsum[1]


enter image description here

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.