To structure my sourcecode, I often use spaces for padding:

    \emph{Student} & \emph{Score}\\

Can this ever cause problems? Like putting no % at the end some lines.

  • Spaces at the beginning of a line are irrelevant to TeX? You can put as many as you want.
    – Johannes_B
    Nov 27, 2013 at 13:35
  • 3
    Except in verbatim like context spaces at start of line are ignored, but note you have missing % on lines 1 and 5 which could produce anomalous white space in the result. Nov 27, 2013 at 13:37
  • @DavidCarlisle: Thanks, good call on the missing % :-). Someone add it as an answer so I can accept it.
    – u17
    Nov 27, 2013 at 13:41
  • @Johannes_B you were first:-) Nov 27, 2013 at 13:43

2 Answers 2


Usually, spaces at the beginning of a line are ignored by TeX. However, this is not the case when writing in a verbatim like context. Tabulators at the beginning of a line are ignored as well.

Whitespace characters like NO-BREAK SPACE (U+00A0) behave in a different way. To use them properly, a modern engine like LuaLaTeX in conjunction with fontspec is needed.

Please be aware, that the end of a line is nothing more than a (space) for LaTeX, if in M-mode (middle of a line), so you have to be careful in the definition of your own commands.

\testa \par \testb

  • 1
    Does the same apply for tabs or other whitespace characters?
    – ComFreek
    Nov 27, 2013 at 15:33
  • @ComFreek Good question, I added the information to the answer. Can somebody please varify the behaviour for »other whitespace character«? I somehow would have guessed a different behaviour.
    – Johannes_B
    Nov 27, 2013 at 17:11
  • I'm not really sure about U+00A0, which in the normal setting of LuaLaTeX and XeLaTeX has category code 12 when fontspec is loaded.
    – egreg
    Nov 27, 2013 at 17:12
  • @egreg I tried it out myself, but as I said, i don't think this should happen. Am i missing something?
    – Johannes_B
    Nov 27, 2013 at 17:14
  • @Johannes_B Try loading fontspec
    – egreg
    Nov 27, 2013 at 17:17

The comment environment (comment package) should start in a new line without a space before. From the manual:

The opening and closing commands should appear on a line of their own. No starting spaces, nothing after it.

Otherwise it won't work and cause strange errors.

  • 3
    the same is true for \end{verbatim} Nov 27, 2013 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .