Text Formatting
Master the essentials of bolding, italics, underlining, and text alignment in LaTeX.
While LaTeX is renowned for its mathematical typesetting, you still need to know how to format everyday text. In this lesson, we'll cover how to emphasize text, change fonts, and control paragraph alignment.
Bold, Italics, and Underlines
The three most common text formatting commands in LaTeX are incredibly straightforward:
This is some normal text.
This word is \textbf{bold}.
This word is \textit{italicized}.
This word is \underline{underlined}.You can even nest these commands inside each other to combine effects:
\textbf{\textit{This text is both bold and italicized!}}While \textit{} directly forces the font to be italic, LaTeX also provides the \emph{} command.
\emph{text} is generally preferred by LaTeX purists because it is context-aware. If you use \emph{} inside normal text, it italicizes it. But if you use \emph{} inside text that is already italicized, it switches the text back to normal (upright) font to ensure the emphasis remains visible.
Font Families
By default, LaTeX uses a beautiful serif font called Computer Modern. However, you can switch to different font families for specific words or sentences:
This is the default serif font (Roman).
\textsf{This text uses a sans-serif font.}
\texttt{This text uses a monospace (typewriter) font, which is great for code.}Sizing Text
LaTeX discourages manually setting font sizes (like "14pt" or "10pt") in the middle of a document because it breaks the typographic consistency. Instead, LaTeX provides relative sizing commands.
These commands are unique because they do not take an argument in curly braces. Instead, they act as "switches". To limit their effect, you must wrap them in curly braces {...} or an environment.
{\tiny This is tiny text.}
{\scriptsize This is script size.}
{\footnotesize This is footnote size.}
{\small This is small.}
{\normalsize This is normal.}
{\large This is large.}
{\Large This is even larger.}
{\LARGE This is LARGE.}
{\huge This is huge.}
{\Huge This is the biggest size.}Text Alignment
By default, LaTeX fully justifies your text, meaning it aligns evenly on both the left and right margins (just like a printed book). If you want to change this alignment, you can use built-in environments.
Centering
To center a block of text, wrap it in the center environment:
\begin{center}
This text is perfectly centered on the page.
You can use it for titles or special quotes.
\end{center}Left and Right Alignment
If you want to disable full justification and align text strictly to the left or right:
\begin{flushleft}
This text is aligned to the left margin. The right edge will be "ragged" (uneven).
\end{flushleft}
\begin{flushright}
This text is aligned to the right margin.
\end{flushright}