2

I have searched the web but did not find anything besides the command \texorpdfstring for including math symbols which did btw not work for me

I simply want to add a percent symbol in my subsection i.e.

\subsection{under 5%}
  • 4
    Welcome to TeX.SE. Since % means the comment character in (La)TeX it must be escaped, i.e. use \%: \subsection{Under 5\%} or with siunitx package: \subsection{Under \SI{5}{\percent}} for a better display – user31729 Apr 4 '17 at 10:57
3

The % means the comment character in (La)TeX usually (unless catcodes are changed, but let us assume this hasn't be done).

Now \subsection{under 5%} will fail of course, since the closing } bracket of the \subsection command isn't read any longer and TeX chokes on this.

As usual, a special character like % must be escaped with \, i.e. \% or the special command \textpercent or \SI{5}{\percent}, the later form does not work with bookmark pdf strings, however, in this case, apply \textorpdfstring{\SI{5}{\percent}}{\num{5}\textpercent}}.

\documentclass{article}

\usepackage{siunitx}

\usepackage[bookmarksopen=true]{hyperref}
\begin{document}
\tableofcontents
\section{under 5\%}
\section{under \texorpdfstring{\SI{5}{\percent}}{\num{5}\textpercent}}
\end{document}

I omitted a screenshot

  • I would add that 5\% and \num{5}\textpercent set the per cent sign up close, while \SI{5}{\percent} inserts a thinspace between number and unit. The latter is correct according to Oxford Style, but other style guides prefer to set per cent signs up close to the number. If you want to replicate the version with thinspace for the former two varieties, you have to use 5\,\% or \num{5}\,\textpercent, respectively. – Manuel Weinkauf Apr 4 '17 at 13:03
  • @ManuelWeinkauf: I will add you suggestions later on, thanks! – user31729 Apr 4 '17 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.