# How to type a non-breaking hyphen (dash, "-" character) in scientific or technical documents

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.

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):

$p$\nobreakdash-adic
$n$\nobreakdash-dimensional
pages 1\nobreakdash--9


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 write

$n$\nobreakdash-\hspace{0pt}dimensional


That 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 and sional 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 as

\newcommand\ndim{$n$\nobreakdash-\hspace{0pt}dimensional}


in the preamble and to write \ndim{} everywhere in the body of the document.

With the babel package loaded there is \babelhyphen{nobreak} available (alongside \babelhyphen{soft}, \babelhyphen{hard} and a few others). While it prohibits a break after the dash the following word may still be hyphenated:

$n$\babelhyphen{nobreak}dimensional


The language ngerman (maybe others, too) defines a shorthand for a non-breaking hyphen: "~. With \addto\extrasenglish{\languageshorthands{ngerman}} it (and the other ngerman shorthands) can be added to english for example. (It probably must be activated with \useshorthands{"}. Contrary to \babelhyphen{nobreak} "~ does not allow the following word to be hyphenated.

% preamble
\usepackage[ngerman,english]{babel}
...
% document
$n$"~dimensional


You can also define the shorthand yourself – either general

\defineshorthand{"~}{\babelhyphen{nobreak}}
\useshorthands{"}


or explicitly for one language (english as example):

\defineshorthand[english]{"~}{\babelhyphen{nobreak}}
\languageshorthands{english}
\useshorthands{"}
}


A complete example:

\documentclass{article}

\usepackage[ngerman,english]{babel}

\defineshorthand[english]{"~}{\babelhyphen{nobreak}}
\languageshorthands{english}
\useshorthands{"}
}

\begin{document}

% default:
\parbox{3em}{$n$-dimensional}

\bigskip
% \babelhyphen{nobreak}:
\parbox{3em}{$n$\babelhyphen{nobreak}dimensional}

\bigskip
% new english' shorthand:
\parbox{3em}{$n$"~dimensional}

\bigskip\selectlanguage{ngerman}
% ngerman' shorthand:
\parbox{3em}{$n$"~dimensional}

\end{document}


• I am open to criticism: if the downvoter kindly would tell me in which respect my answer is bad/wrong? I'll gladly edit/delete if I know why. Aug 30 '15 at 21:50
• I, for one, upvoted your answer. :-) Absent some clear criticism, I tend to no longer worry too much about any downvotes. Quite a few of the downvotes I've received over time turned out to be entirely accidental, of the "fat-finger" variety -- where somebody meant to upvote but managed to downvote instead. Plus, the fat-finger problem has afflicted me too at times, i.e., I've accidentally downvoted other postings. (I correct those mistakes, though!)
– Mico
Aug 30 '15 at 22:02
• @Mico i don't worry but I'm curious :) Aug 30 '15 at 22:06

It is also possible to wrap part of text that should not be wrapped or only the dash in \mbox{…}:

\mbox{non-linear}
non\mbox{-}linear

• Wrapping only part of the text will compromise the kerning in the word. But also, wrapping any part of the string in braces will suppress all hyphenation within the string May 13 at 19:21
• this is the way, no additional packages necessary Oct 26 at 22:15
• @Sergiu - why does the fact that no additional packages are necessary that "this is the way"?
– Mico
Nov 14 at 23:24
• @Mico the fewer packages the better, as in my experiences when submitting papers to conferences or journals there is tons of resistance to using many packages, because imagine 100 papers accepted from different authors and each using their preferred packages, then putting the content together in one document can be a hassle with conflicting packages Nov 15 at 0:23
• @Sergiu - There are plenty of obscure and largely undebugged LaTeX packages out there. However, babel and amsmath -- the two packages whose used by the other two answers to this query -- are definitely not in that category; indeed, quite the opposite is the case. To use your rhetoric: Imagine 100 papers accepted from different authors; if the clear majority of these papers did not employ either amsmath or babel (or both), one would very much have to worry about the apparent lack of basic LaTeX competence of the set of authors.
– Mico
Nov 15 at 1:29