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?
Asked
Active
Viewed 7,961 times
16
Peter Grill
- 223,288
Peter
- 163
-
Welcome to TeX.SE. I am sure there is an exact question on this site about generating bold text using the same horizontal space, but haven't found it yet... – Peter Grill Jan 02 '13 at 16:05
-
What typeface are you using? Is it the default Computer Modern? – egreg Jan 02 '13 at 16:25
-
Yes, I'm using the default typeface. – Peter Jan 02 '13 at 16:28
-
This is apparently known as known "Duplexing" and is a important feature of "Tabular Figures" (as contrasted to "Proportional Figures" used outside of tables). Maybe these keywords should be added to the question as this doesn't show up in google. – Frames Catherine White Jun 20 '18 at 03:54
1 Answers
18
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}

Note. From your question I gather that you're using \bf{13} or something like that. It's wrong for two reasons:
\bfis an obsolete command;- 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).
egreg
- 1,121,712
-
1Note that whether this works seems to depend on the font and the fontsize. E.g. scriptsize cmr
bis too narrow (whilebxis still too wide, andbsxdoesn't exist). – oulenz Jun 12 '20 at 13:18 -
what if I want to use bold for multiple chunks of text? For example,
\bftab 0.673 $\pm$ 0.017only makes 0.017 bold. While{\bftab 0.673 $\pm$ 0.017}works but alters the alignment of the cell. – Luca Clissa Aug 06 '23 at 10:30 -
1@LucaClissa You should use
siunitxfeatures, in this case those related to uncertainty. – egreg Aug 06 '23 at 12:42 -
@egreg Can you elaborate more? I can open a new post if you think it's better – Luca Clissa Aug 07 '23 at 08:54
-
-
@egreg I tried to, but it didn't help. Anyway I found out I can use
\bftabin conjunction withdetect-weightoption to make the whole thing (number \pm uncertainty) bold. Specifically, I used something like\begin{tabular}{@{} l *{5}{S[detect-weight]} @{}}in the column definition and thenbftabin the cell I wanted to make bold. – Luca Clissa Aug 08 '23 at 07:31