[Tex/LaTex] How to redefine “\ ” (that is “ “)

macrosspacing

In (La)TeX, is there a way to redefine the command (that is "<backslash> <space>")?

I have lots of texts where is used as non-breakable space after "." characters like in Dr.\  or Mr.\  and I want to make that space in the output just a bit shorter than the normal space.

Please note, I do not want to change the texts, but rather redefine the macro in the preamble. Is this possible?

Best Answer

I would strongly recommend against this, but it can be done. The command is a primitive meaning 'a normal space' so shows up in various places, in particular the definition of \nonbreakspace. Thus a 'safe' redefinition of must at least deal with that:

\documentclass{article}
\let\hardspace\ %
\DeclareRobustCommand*\nobreakspace{\leavevmode\nobreak\hardspace}
%\let\ ~
\begin{document}

Some text to show that this is now a non-breaking space in a demo:
Mr.\ Black.

\let\ ~

Some text to show that this is now a non-breaking space in a demo:
Mr.\ Black.

\end{document}

I've commented out \let\ ~ in the preamble in the above so that the demo shows the effect of the change, but in a real case you'd apply it to everything. As pointed out by others, you really should use the correct mark-up to differentiate between a 'forced' normal space and a non-breaking space.

Related Question