[Tex/LaTex] \textbf has wider space than \bf with own command

macrosspacing

How come the \textbf command results in a wider space between words, than the deprecated \bf when using this own command?

\documentclass{article}
\usepackage{hyperref}
\begin{document}    
    \makeatletter
        \newcommand*{\textlabel}[2]{
            \edef\@currentlabel{#1}
            \phantomsection
            #1\label{#2}
        }
    \makeatother

\begin{description}
    \item[item] \textbf{\textlabel{First text}{ref1}} \\
    Description!
    \item[item] {\bf \textlabel{Second text}{ref2}} \\
    Description!
\end{description}
\end{document}

Output:

enter image description here

Best Answer

You have three spurious spaces in your definition of \textlabel. If you remove them by masking the end-of-lines, the result is the same:

\makeatletter
\newcommand*{\textlabel}[2]{% <- Here
  \edef\@currentlabel{#1}% <- Here
  \phantomsection
  #1\label{#2}% <- Here
}
\makeatother

Why don't the spaces show up in the second case? Because \textbf starts a paragraph by itself, while \bf doesn't. So in the second case the spaces are ignored because TeX is still not typesetting a paragraph.

The correct command to use with a syntax similar to \bf is \bfseries: it's a declaration, so it needs a pair of braces or it can be issued in an environment. But it's preferable to use \textbf in running text: you can see a difference between

{\bf stuff} boldfaced

and

\textbf{stuff} boldfaced

because in the second case LaTeX adds the "italic correction" that compensates for the "f" bumping into the interword space.