[Tex/LaTex] Make numbers in table bold w/o changing width

boldformattinghorizontal alignmenttables

I want to highlight some numbers in a table using \bf{}. However, the bold numbers also get wider but I want them to neatly line up with the rest. How can I avoid this?

Best Answer

You can use "non extended bold face":

\documentclass{article}
\usepackage{booktabs}

\newcommand{\bftab}{\fontseries{b}\selectfont}

\begin{document}
\begin{tabular}{lc}
\toprule
Class & Value \\
\midrule
A & 10 \\
B & 12 \\
C & \bftab 13 \\
D & 11 \\
\bottomrule
\end{tabular}
\end{document}

enter image description here

Note. From your question I gather that you're using \bf{13} or something like that. It's wrong for two reasons:

  1. \bf is an obsolete command;
  2. it is not a command with argument.

Use \textbf{13} or {\bfseries 13} (the former is preferred for single snippets of boldface text, the latter is for longer passages or in the definition of environments).