I am writing scientific or technical documents in LaTeX. Often I need to type a non-breaking space, for example when using equation references:
Equation~\eqref{eq:equation1example} shows blaa...
Is there a way of inserting non-breaking hyphens?
For example, this may be useful for technical terms such as Runge-Kutta
, non-linear
, non-converging
or Van-der-Pol Oscillator
which would not usually be split over lines.
Additionally, this may be desirable for citations and Author names, or publisher names.
Best Answer
If you use the amsmath package, you could employ its
\nobreakdash
macro to insert a dash or en-dash after which no line break is allowed.Three examples (all from the user guide of the
amsmath
package):Basically, where you'd normally write
-
("dash") in the input file, you would now write\nobreakdash-
, and where you'd normally write--
("en-dash"), you would now write\nobreakdash--
.The joined-up expression
$n$\nobreakdash-dimensional
is quite long and might create bad line breaks. To keep this from happening, while still prohibiting a linebreak after$n$-
, you could writeThat way, if need be, LaTeX can find a line break somewhere inside the "dimensional" substring. Presumably, you're OK with
$n$-dimen-
being at the end of one line andsional
at start of the next line. If you have a lot of instances of "n-dimensional" in your document, it may make sense to set up a macro such asin the preamble and to write
\ndim{}
everywhere in the body of the document.