LaTeX underbrace with text

The underbrace command makes an underbrace and insert a text if it has an underscore.

\[
\underbrace{PQ} \\~\\
\underbrace{a_1 \cdots a_n} \\~\\
\underbrace{a_1 \cdots a_n}_{n}
\]

\[ \underbrace{PQ} \\~\\ \underbrace{a_1 \cdots a_n} \\~\\ \underbrace{a_1 \cdots a_n}_{n} \]

LaTeX equation

LaTeX