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


    \item[item] \textbf{\textlabel{First text}{ref1}} \\
    \item[item] {\bf \textlabel{Second text}{ref2}} \\


enter image description here


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:

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

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


\textbf{stuff} boldfaced

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

  • Perhaps add a hint that \bfseries features the same behaviour as the obsolete \bf. – lockstep May 13 '12 at 22:50
  • @lockstep But the \bfseries needs including a package right? – cherrung May 13 '12 at 22:53
  • @egreg Awesome. Learned something new again. This actually just happened today, because I had comments after each line and wanted to make the comments look nice, but having a space between the code and the '%' comment symbol. Silly me. – cherrung May 13 '12 at 22:53
  • @lockstep I wouldn't recommend using \bfseries in that situation. – egreg May 13 '12 at 22:53
  • @egreg But would you recommend \bf? (My hint was mainly about that the OP's problem is not due to using an obsolete command.) – lockstep May 13 '12 at 22:55

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.