Can spaces at the beginning of a line ever cause problems?
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.
\documentclass{article}
\newcommand\testa{h
ello}
\newcommand\testb{h%
ello}
\begin{document}
\testa \par \testb
\begin{verbatim}
h
a
ll
o
\end{verbatim}
\end{document}
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.