Print the percent (%) symbol in LaTeX
In LaTeX, the Percent (%) symbol is used for commenting out a single line, so you can not directly type this symbol into the source code and print it.
Since this symbol (%) is a special character in LaTeX, so you have to use the \ escape character before the % character like this \%.
\documentclass{article}
\begin{document}
% In-line comment out
$$ \% $$
$$ 100\% $$
\end{document}Output:

Percent symbol with stix package
If you want a slightly different style of percent symbol you can load the stix package with \usepackage{stix} in the preamble and then use \%.
\documentclass{article}
\usepackage{stix}
\begin{document}
% In-line comment out
$$ \% $$
$$ 100\% $$
\end{document}Output:

Colored percent symbol in LaTeX
To add color first of all you have to load the xcolor package then you can use the \textcolor{<color-name>}{\%} command.
Also, you can use the siunitx package. This package provides \qty[<option>]{<value>}{\percent} command to add color to the unit and percent symbol.
- Use
\qty[unit-color=<color>]{<value>}{\percent}to add color to both unit and symbol. - Use
\qty[color=<color>]{<value>}{\percent}to add color only on the percent symbol.
\documentclass{article}
\usepackage{xcolor}
\usepackage{siunitx}
\begin{document}
% In-line comment out
$$ 100\textcolor{blue}{\%} $$
$$ \textcolor{red}{100\%} $$
\centering
Using \texttt{siunitx} package:
$$ \qty{50}{\percent} $$
$$ \qty[color=red]{100}{\percent} $$
$$ \qty[unit-color=red]{70}{\percent} $$
\end{document}Output:

Leave a Reply