## LaTeX forum ⇒ Fonts & Character Sets ⇒ Better looking Percent Symbol Topic is solved

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm

### Better looking Percent Symbol

I know that the percent symbol is \% in LaTeX, but I don't like its appearance with a number close to it. It's a bit too big. See for example this code :
\documentclass[12pt]{article}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage[french]{babel}\usepackage{amsmath} \begin{document}This $v \approx 58\% \, c$ looks ugly to me.\end{document}

Is there any other "better looking" percent symbols?

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
“better looking” is awfully subjective... If your goal is a smaller percent sign you can always scale it although this might not be the best solution:

\documentclass[12pt]{article}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage[french]{babel}\usepackage{amsmath} \usepackage{graphicx}\newcommand*\pct{\scalebox{.9}{\%}} \begin{document}This $v \approx 58\% \, c$ looks ugly to me. This $v \approx 58\pct \, c$ looks ugly to me.\end{document}

Alternatively you could choose another font where the sign is more to your liking. Maybe this one?
\documentclass[12pt]{article}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage[french]{babel}\usepackage{amsmath} \usepackage{mathpazo} \begin{document}This $v \approx 58\% \, c$ looks ugly to me. \end{document}

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm
Aaah ! The first solution is the right one !

Thanks a lot !

Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm
Now this is weird.

The above solution works very well, except when I'm using it inside a caption :

\documentclass[12pt,twoside,nofootinbib]{book}\usepackage[T1]{fontenc}\usepackage{microtype}\usepackage{amsmath}\usepackage{graphicx} \newcommand*\pct{\scalebox{0.9}{\%}} \begin{document} Here, it works : $x = 2.0\pct$. \begin{figure}	Test	\caption{Here, it gives a compilation error : $x = 1.0\pct$.}\end{figure} \end{document}

So what is happening here ?

Johannes_B
Site Moderator
Posts: 3803
Joined: Thu Nov 01, 2012 4:08 pm
Some things like glass vases are sensible and can break when moving. You have to protect them from breaking using protection, for example using bubble wrap.
The same with LaTeX. Some commands in moving arguments are fragile, so you have to protect them.
\documentclass[12pt,twoside,%nofootinbib%unknown]{book}\usepackage[T1]{fontenc}\usepackage{microtype}\usepackage{amsmath}\usepackage{graphicx} \newcommand*\pct{\protect\scalebox{0.9}{\%}} \begin{document} Here, it works : $x = 2.0\,\pct$. \begin{figure}	Test	\caption{Here, it gives a compilation error : $x = 1.0\,\pct$.}\end{figure} \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm
Ow ! What is the \protect command doing ? (well, I mean except to use some "bubbles" to protect the macro ! )

Johannes_B
Site Moderator
Posts: 3803
Joined: Thu Nov 01, 2012 4:08 pm
Compare Section12.9 in texdoc latex2e, the unofficial reference manual.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
Johannes_B wrote:
\newcommand*\pct{\protect\scalebox{0.9}{\%}}

Maybe it's easier and even more robust to make \pct itself robust:
\DeclareRobustCommand*\pct{\scalebox{.9}{\%}}

Cham wrote:What is the \protect command doing ?