5

This question already has an answer here:

I have recently falled into an error because I didn't use % when I was supposed to. My question is now: When do I have to use % at the end of the line and when should I leave it out?

marked as duplicate by Werner, Gonzalo Medina, egreg, percusse, user11232 Oct 13 '15 at 23:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7

An end of line is a space so your question is asking when to add a space.

foo
bar

is the same as

foo bar

but

foo%
bar

is the same as

foobar

so it just depends on the context. Sometimes a space is needed to separate words, or for TeX syntactic reasons, sometimes a space is not needed but ignored anyway, and sometimes a space is definitely wrong at that point.

  • ...except for things like verbatim, where an EOL is not a space. – Steven B. Segletes Oct 13 '15 at 23:29
  • I also think it worth to explicitly mention that spaces (and thus %) are ignored after \if family of conditionals, as well as after \else and \fi...since they are used pervasively in macros. – Steven B. Segletes Oct 13 '15 at 23:32
  • @StevenB.Segletes ??? \if has no special treatment of spaces. – David Carlisle Oct 14 '15 at 6:53
  • Did I say that? Must have been my alter-ego. Need to adjust the meds. – Steven B. Segletes Oct 14 '15 at 10:00

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