Short answer: commands for styles, environments for blocks
LaTeX formats text with markup rather than buttons. You write the text and mark it up: \textbf{bold} makes a word bold, and an environment such as center centers a block. The formatting appears when you compile the file to a PDF.
Two rules cover most cases:
- A command takes its text as an argument in braces, as in
\textbf{...}. - An environment wraps a block between
\begin{...}and\end{...}.
Bold, italic, and emphasis
\textbf{Bold text}, \textit{italic text}, and \emph{emphasized text}.
\textbf sets bold, and \textit sets italic. \emph is for emphasis. In normal text it sets italic, but inside italic text it switches back to upright. That makes it useful when the emphasis should depend on its context. Use \textit when you want italic no matter what surrounds the text.
To combine styles, nest the commands:
\textbf{\textit{bold and italic}}
Underline, small caps, and slanted text
\underline{underlined}, \textsc{Small Caps}, and \textsl{slanted text}.
\textsc sets lowercase letters as small capitals, so type the text in normal case. \textsl slants an upright font without switching to a true italic design.
\underline does not break neatly across lines. If underlined text needs to wrap, load the ulem package, which provides underlining that can break across lines.
Font families and sizes
Typefaces and sizes have their own commands:
\texttt{Typewriter text}, \textsf{sans serif text}, and {\large a larger phrase}.
The LaTeX fonts and font families guide covers the full set of families, series, shapes, and sizes.
Alignment and paragraph layout
Environments set the alignment of a block:
\begin{center}
A centered line
\end{center}
\begin{flushright}
A line flush right
\end{flushright}
The flushleft environment aligns left. A blank line starts a new paragraph, and \noindent removes the indent from one paragraph. A single forced line break inside a paragraph is written with \\, but a blank line usually does the job better.
For right-aligned text on a single line, see right-aligning text in LaTeX. For the choice between left alignment and justified text, see is it better to align left or justify.
Superscripts and subscripts
Outside math mode, use \textsuperscript and \textsubscript:
The 4\textsuperscript{th} edition, with a subscript\textsubscript{2}.
Inside math mode, use ^ and _, as in $x^2$ and $x_i$. For more on math subscripts, see how to use subscript in LaTeX.
Quotation marks and dashes
Use two backticks for opening double quotes and two apostrophes for closing ones, as in ``quoted text’’. Single quotes follow the same pattern, with one backtick and one apostrophe.
LaTeX has three dash lengths, and each has its own job:
- Hyphen
-joins compound words, as in well-known. - En dash
--marks ranges, as in pages 10–20. - Em dash
---marks a break in a sentence—like this.
Colors and line spacing
To color text, see how to change text color in LaTeX with xcolor. To change the space between lines, see how to change line spacing in LaTeX with setspace.
Frequently asked questions
Why does my text not change when I use a command?
Check three things. Are the braces closed? Did you load any package the command needs? Are you inside the group you think you are? A switch such as \bfseries only lasts until the end of its group.
What is the difference between \textbf and \bfseries?
\textbf{...} applies bold to the text inside its braces. \bfseries is a switch, so it applies until the end of the group or until another font switch. Both produce bold text. Use the command for a short phrase and the switch for a longer block.