I'm writing a text in Spanish, and I have a phrase wrote between em-dashes (that work like parentheses). The problem is that if the "opening" em-dash is too near the end of the line, then it may happen that it remains in that line but the next word falls to the next:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a leo quis
libero ---accumsan vulputate---. Praesent pretium dapibus est interdum
hendrerit.
What I need to get in this example, is the opening em-dash and its next word to be in the same line, like this:
where I had to use
\mbox{---accumsan}
Is there a simple way to make LaTeX not to break the opening em-dash with its next word, and also the ending em-dash with its previous word?
Best Answer
Since you are writing in Spanish, you surely are using the
spanish
option forbabel
. If this is the case, then you can use the shorthand"+--
to prevent a possible line break. A little example:
Another option is to use the
\nobreakdash
command implemented by theamsmath
package; this command suppresses any line break after the dash (or hyphen). Of course, if you are going to use this a lot, you can define a new command to simplify the writing. In the following example I defined two commands using\nobreakdash
: the first variant will prevent hyphenation of the word following the em-dash; the second variant will allow normal hyphenation in the following word: