(click anywhere to close)
OPEN MENU

[LaTeX] Spaces & Reserved Characters

category: Writing | course: LaTeX | difficulty:

Like most markup languages, LaTeX collapses whitespace. This simply means that when it encounters multiple white spaces, it reduces it to a single one. This also means that it ignores a single return. An empty line between text, instead, starts a new paragraph.

These words are                 not that far apart.
Neither are these

But this is a new paragraph.
LatexEatingWhiteSpace

If you’re wondering why LaTeX does that, it’s because it regards multiple whitespaces and newlines as different from the single white space and return key, and requires different commands to produce them.

Reserved Characters

There are some preserved characters that make LaTeX do special things when you type them in the regular way. These are:

# $ % ^ & _ { } ~ \

That’s fine, but if you want to use them as a character in-text, you need to escape them. This can be done, in most cases, by adding a backslash in front:

\# \$ \% \^ \& \_ \{ \} \~

But, if you need an actual backslash, you can’t escape it with another backslash. For that, use the \textbackslash command.

These are two dollar signs: \$\$            \par
This is a math environment: $H_{2}O$
LatexReservedCharacters

Built-In Strings

There are four commands that transform into a built-in string.

Command

Visual

Description

\today

December 20, 2015

Current date

\TeX

TeX

What you’re learning (kind of)

\LaTeX

LaTeX

What you’re actually learning

\LaTeXe

LaTeX 2ε

The current version

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 \<space> command.

Isn't \LaTeX cool? Isn't \LaTeX{} cool? Yes \ \ \ it is!
LatexWhiteSpaceAfterCommands

Of course, commands that, by default, have a required argument, already display this behaviour.

CONTINUE WITH THIS COURSE
Do you like my tutorials?
To keep this site running, donate some motivational food!
Crisps
(€2.00)
Chocolate Milk
(€3.50)
Pizza
(€5.00)