As Martin has already commented, adding %
to the end of a line prevents TeX from turning the end-of-line character into a space. This is needed at the end of every line except those where TeX is already skipping spaces, for example after a macro name which takes no arguments:
\newcommand{\examplemacro}{%
\somecommand{}%
\othercommand
}
Here, the line with \othercommand
does not need a %
as TeX will skip the space here anyway.
The use of braces for the first argument of \newcommand
is 'optional' due to the way TeX grabs arguments. We use a brace group in LaTeX to indicate a single argument, but TeX will grab either a brace group or a single token as an undelimited argument. In the example, \examplemacro
is a single token (a control sequence), and so TeX will grab it in one go.
There are places where the braces are required. For example
\newcommand\test{a}
will work but
\newcommand{\test}b
will not, as the 'replacement text' argument for \newcommand
has to be given in braces.
As LaTeX is built on TeX, some TeX ideas leak through. The formal LaTeX syntax always includes braces, but as TeX does not always need them people 'in the know' take shortcuts.