Spaces & Reserved Characters
Like most markup languages, LaTeX collapses whitespace. When it encounters multiple spaces, it reduces them to a single one. This also means it ignores a single return. Instead, only a completely blank line starts a new paragraph.
1These words are not that far apart. Neither are these
2
3But this is a new paragraph.
Why does LaTeX do that?
- Because it’s flexible. You don’t need to worry about accidentally leaving a space somewhere, or pressing the RETURN key too few (or too many) times, and the whole document being messed up.
- To us all white space is equal. But a computer sees symbols in more detail and ascribes different meaning to it. For example, turn on “paragraph marks” (or something named similarly) in Microsoft Word, and it will show you all the hidden symbols it automatically adds for you.
Reserved Characters
There are some reserved characters in Latex. This means they have special meaning and will be interpreted as something else than just their visual symbol. I explain these in advance, at the start of the course, to prevent all sorts of errors and confusion in the near future.
The reserved characters are:
1# $ % ^ & _ { } ~ \
That’s fine, but what if you want to simply type them as a character? Then you need to escape them. This can be done, in most cases, by adding a backslash in front:
1\# \$ \% \^ \& \_ \{ \} \~
Okay. Great. But, what if we want an actual backslash? Escape it with another backslash? Use infinite backslashes?
No, the creators of Latex were smart enough to just make a command for it. Use \textbackslash
.
1These are two dollar signs: \$\$
2
3This is a math environment: $H_{2}O$
Whitespace after Commands
Commands eat up all the white space right after it. To prevent this, add an empty required argument after it with empty braces. Alternatively, you can use the empty \>
command.
1Isn't \LaTeX cool? Isn't \LaTeX{} cool? Yes \> \> \> it is!
Commands that have a required argument, of course, already display this behaviour.
Built-In Strings
Four commands exist that transform into a built-in string. These aren’t that important, but I mention them for completeness’ sake. They are: \today
(current date), \TeX
, LaTeX
, \LaTexE
(to display the logo of what you’re learning right now, in different ways).
Want to support me?
Buy one of my projects. You get something nice, I get something nice.
Donate through a popular platform using the link below.
Simply giving feedback or spreading the word is also worth a lot.