2

I know how to centre a column about the decimal point using the siunitx package. How do I include a percent sign in the column heading, ie "Heading (%)"? Neither \% or \SI{}{\percent} seem to work.

\documentclass[a4paper]{article} 
\usepackage{siunitx}
\begin{document} 
\begin{table}
    \sisetup{output-decimal-marker = {\cdot}}
    \begin{tabular}{S}
        \hline
        \\ \hline
        3.93  \\ \hline
        3.3  \\ \hline
    \end{tabular}
\end{table}
\end{document}
2
  • 1
    I would use {Heading (\si{\percent})} (outer braces to protect it from being recognized as a numerical entry in the column). Feb 24 '15 at 12:31
  • Correct answer is provided by above comment from @PaulGessler.
    – Mowing Bar
    Feb 24 '15 at 12:43
2

Use {Heading (\si{\percent})}. The outer braces are to protect the heading from being recognized as a numerical entry that siunitx would otherwise attempt to align.

\documentclass[a4paper]{article} 
\usepackage{siunitx}
\begin{document} 
\begin{table}
    \sisetup{output-decimal-marker = {\cdot}}
    \begin{tabular}{S}
        \hline
        {Heading (\si{\percent})} \\ \hline
        3.93  \\ \hline
        3.3  \\ \hline
    \end{tabular}
\end{table}
\end{document}

enter image description here

As noted in a comment by daleif, the brace group is not always sufficient for protecting the header contents. In some situations (namely, where the @{}, !{}, >{}, or <{} constructs from the array package have been used), \multicolumn{1}{c}{<header content>} is required instead.

2
  • 1
    Note also that in some cases, the {...} header feature is actually not good enough, in which case a \multicolumn{1}{c}{...} is a better choice (just left here as a future reference).
    – daleif
    Feb 24 '15 at 12:59
  • 1
    @daleif thanks for this note, I added a mention of it to the answer. Feb 24 '15 at 13:07

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.