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:
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: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 betweenand
because in the second case LaTeX adds the "italic correction" that compensates for the "f" bumping into the interword space.