In the amsmath
package documentation it is written:
\newcommand{\n}[1]{$n$\nobreakdash-\hspace{0pt}}
The last example shows how to prohibit a linebreak after the hyphen but allow normal hyphenation in the following word. (It suffices to add a zero-width space after the hyphen.)
I am thinking that this can be used to make the more general commands \nbhyphen
and \nbendash
like this :
\documentclass{minimal}
\usepackage{mathtools}
\newcommand{\nbhyphen}{\nobreakdash-\hspace{0pt}}
\newcommand{\nbendash}{\nobreakdash--\hspace{0pt}}
\begin{document}
Electron\nbhyphen electron interaction. Maxwell\nbendash{}Boltzmann distribution.
\end{document}
and then use them in my document instead of writing the dashes explicitly.
Questions:
Is this a good idea? Will it work everywhere, or is it like to cause unforeseen problems? Should I use the commands with space after, or {}
?
Why is this not default behavior in LaTeX?