Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

LaTeX Text Formatting and Lists

LaTeX Text Formatting and Lists

This section covers the "flesh" of the body: how to switch font styles, adjust font sizes, use the three list environments, and control alignment.

The principle remains: these are semantic commands - you tell LaTeX "this is emphasis", and the document class decides how it looks.


Font styles

There are five common styles, all in the form of "command + braces", acting on the text inside the braces.

effect Command Description
bold \textbf{...} bold face
italic \textit{...} Chinese text is automatically mapped to the Kai (Kaiti) font
Underline \underline{...} Use with caution in formal typesetting; Western typography prefers italics instead
Monospace \texttt{...} typewriter, for code, commands, and file names
Emphasis \emph{...} Smart emphasis: becomes italic in normal text, and upright in italic text

Example: Font styles

\

documentclass

{

ctexart}
\begin{document}
\textbf{bold text}, \textit{italic text}, \underline{underlined text}, \texttt{monospace text}.

For Chinese emphasis use \emph{key point}, for English emphasis use \emph{emphasis}.

Combined usage: \textbf{bold and \textit{italic}}, \texttt{you can also use \textbf{bold} in code}.
\end{document

}

Compilation result of font styles

Note a detail in the output: Chinese "italics" actually renders as Kai font - Chinese characters have no italic tradition, and ctex automatically uses Kai font for the "slanted" emphasis role, which is the correct localization.

The difference between \emph and \textit is "smartness": inside already-italic text, \emph automatically switches back to upright, creating contrastive emphasis; prefer \emph when writing papers.

Do not use underlines for emphasis - that is a relic of the typewriter era. In academic typesetting, italics or bold are enough for emphasis.


Font size adjustment

Western font sizes are a set of "declaration-style" commands, ten levels from \tiny to \Huge, scaled proportionally relative to \normalsize.

From small to large Command
Levels 1-5 (small) \tiny, \scriptsize, \footnotesize, \small, \normalsize
Levels 6-10 (large) \large, \Large, \LARGE, \huge, \Huge

Example: Western and Chinese font sizes

\

documentclass

{

ctexart}
\begin{document}
{\tiny tiny footnote level}, {\scriptsize scriptsize}, {\footnotesize footnotesize},
{\small small}, body default normalsize.

  {\large large}、{\Large Large}、{\LARGE LARGE}、{\huge huge}、{\Huge Huge

}

.

% Chinese papers more often specify directly by "hao" number: \zihao{hao number}

Chinese font sizes:

{

\zihao{5} hao 5 (common for body text)}, {\zihao{-4} xiaosi (paper body text)},
{\zihao{4} hao 4 (section title)}.
\end{document

}

Compilation result of font size ladder

Font size commands are "switches", not "scopes" - all text after \large becomes larger until the group ends. So always wrap them in braces: {\large large text}, so the following small text is unaffected.

For Chinese documents, it is recommended to use \zihao{hao number} directly: a minus sign before the number means "xiaohao" (smaller size), and \zihao{-4} is the famous "xiaosi" - the standard font size for theses at Chinese universities.


Three list environments

Lists are the most commonly used "environments" in LaTeX (\begin and \end appear in pairs), and the three environments correspond to three semantics.

Environment Purpose tag
itemize Parallel points, without order Bullets, dashes, and similar symbols
enumerate Ordered steps 1. 2. 3. numbering
description Term definition Custom term name

Example: Three list types and nesting

\

documentclass

{

ctexart}
\begin{document}

Unordered list itemize:

  \begin{itemize}       

  \item first item
  \item second item
    \begin{itemize}
      \item nested sub-item, symbol changes automatically
      \item another sub-item
    \end{itemize}
\end{itemize}

Ordered list enumerate:

  \begin{enumerate}       

  \item install the distribution
  \item choose an editor
  \item compile your first document
\end{enumerate}

Description list description:

  \begin{description}       

  \item[LaTeX] a typesetting system based on TeX
  \item[package] a plug-and-play feature extension
\end{description}

  \end{document

}

Compilation result of three list environments

Nested lists need no extra configuration: each level auto-indents and the symbol changes per level (bullet, dash, asterisk...), up to four nesting levels.

The default list line spacing is loose, often seen as wasting space in papers. The enumitem package provides fine-grained control:

Example: Customizing lists with enumitem

\

usepackage

{

enumitem

}

                         

% load in the preamble

\begin

{

itemize

}[

label=\textsquare, noitemsep

]

 

% square label + remove extra spacing between items

 

\

item

Compact unordered list

 

\

item

Suitable for space-constrained situations

\end

{

itemize}

  \begin{enumerate

}[

label=(\alph*)

]

             

% change numbering style to (a) (b) (c)

 

\

item

First point

 

\

item

Second point

\end

{

enumerate

}


Alignment

The body is justified by default, which is the standard practice for long documents in typography and requires no configuration.

To change alignment locally, use three environments: center, flushleft, flushright.

Example: Centering and right alignment

\

documentclass

{

ctexart}
\begin{document}
The body is justified by default with the last line flush left, which is the standard typographic practice.

  \begin{center}       

Centered text\the second line remains centered
\end{center}

  \begin{flushright}       

Right-aligned text\signatures are commonly right-aligned
\end{flushright}
\end{document

}

Compilation result of alignment environment

Syntax Feature Applicable scenarios
\begin{center}...\end{center} Environment form, with built-in vertical spacing Centering as a standalone paragraph in the body
\centering Declaration command, adds no extra spacing Inside figure/table floats, see Part 8
\begin{flushright}... Right-alignment environment Signature, date

Summary

Requirements Command Common pitfalls
Bold / italic / monospace \textbf / \textit / \texttt Commands only apply to text inside the braces
Emphasis \emph Chinese mapping to Kai font is normal
Changing font size {\large ...} or \zihao{n} Forgetting braces causes everything after to become large
List itemize / enumerate / description When nesting, \begin and \end must come in pairs
Centering center environment or \centering The two have different spacing behavior