Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

With ~ we can enforce that no line break occures between two words.

But this does not seem to work with special characters. I want LaTeX to enforce not to break the line after the - in (re-)creation.

In my document the line breaks between (re- and )creation, which looks a bit ugly.

How can I achieve this?

share|improve this question
Have a look at this. – Marc van Dongen Mar 21 '13 at 12:44
As I wrote here: , this is not exactly a duplicate. What about reopening? – mbork Mar 21 '13 at 14:54
If you use babel you could also use the babel shortcut "~ provided for most languages. For the others see babel: Adding ngerman' s language shorthands to english as the main document language. – Speravir Mar 22 '13 at 0:51

2 Answers 2

up vote 23 down vote accepted

If you put it in a mbox, it can't get broken up:


But that means it can't get broken up anywhere in the word!

share|improve this answer
When I use that, it allows the word to overflow the margins. Is there a way to force it (all) to a new line, if it doesn't fit? – Adam_G Feb 8 at 16:59

I am not sure now why (re-\nobreak)creation does not work, but (re\mbox{-}\nobreak)\nobreak\hspace{0pt}creation does, and does not prevent hyphenation of "creation". (Also, (re\mbox{-)}\nobreak\hspace{0pt}creation is maybe less elegant, but also correct.)

Of course, you might want to have a macro for that, for example:

\newcommand{\optprefix}[2]{% optional prefix

Notice that this macro allows for hyphenation of the prefix (in this case the prefix is just "re", so it does not make sense in this particular case).

Edit: as egreg pointed out in the comments, (re-\nobreak)creation won't work because the hyphen creates a "feasible breakpoint" (that is, a place in which TeX may break the line), and \nobreak comes after that breakpoint, so does not interfere with it. After \mboxing, the breakpoint lands in the box, and is effectively "hidden" from the paragraph-breaking routine.

Now \nobreak\hspace{0pt} has the effect of creating a (zero-width) "inter-word space", so that what comes after it is a new word for TeX (and hence it may consider hyphenating it). However, \nobreak makes sure that this "zero-width interword space" will not be a feasible breakpoint itself.

Also, as egreg pointed out in his comment, one might consider saying


so that you can write just \optprefix{re}creation, or even


which would also allow \optprefix{re} creation - though I personally wouldn't use that, since it is one word and imho should "look like one word" in the source, too.

share|improve this answer
The "unprotected" hyphen in (re-\nobreak)creation creates a feasible break point after it, so the \nobreak has no effect. There is no break point in (re\mbox{-})creation. If you want to enable hyphenation in the main word, then (re\mbox{-})\nobreak\hspace{0pt}creation is the right thing to do; the \nobreak means that the following (zero) glue can't be taken as a break point, but the scanning for hyphenation can take place in creation that's a "new" word to TeX because it comes after glue. – egreg Mar 22 '13 at 0:40
Why not \newcommand{\optprefix}[1]{(#1\mbox{-})} to be called as \optprefix{re}creation? Or even \newcommand{\optprefix}[1]{(#1\mbox{-})\ignorespaces} that would allow \optprefix{re} creation? – egreg Mar 22 '13 at 0:45
@egreg: thanks. I didn't have my copy of The TeXbook, and frankly speaking, didn't remember these details by heart... – mbork Mar 22 '13 at 10:30
Maybe you can edit your answer to add the information. – egreg Mar 22 '13 at 10:36
I'll do it in the afternoon - now I'll have to log out from the computer and take care of my daughter;). – mbork Mar 22 '13 at 10:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.