Avoid line break between em-dash and the next word
Since you are writing in Spanish, you surely are using the spanish
option for babel
. If this is the case, then you can use the shorthand "+--
to prevent a possible line break. A little example:
\documentclass{article}
\usepackage[spanish]{babel}
\begin{document}
%wrong output:
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a leo quis
---accumsan vulputate---. Praesent pretium dapibus est interdum
hendrerit.
%right output:
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a leo quis
"+--accumsan vulputate"+--. Praesent pretium dapibus est interdum
hendrerit.
\end{document}
Another option is to use the \nobreakdash
command implemented by the amsmath
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:
\documentclass{article}
\usepackage{amsmath}
\newcommand\RayaN{\nobreakdash---}
\newcommand\Rayan{\nobreakdash---\hspace{0pt}}
\begin{document}
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a leo quis
---accumsan vulputate---. Praesent pretium dapibus est interdum
hendrerit.
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a leo quis
\RayaN accumsan vulputate\RayaN. Praesent pretium dapibus est interdum
hendrerit.
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a leo quis
\Rayan accumsan vulputate\Rayan. Praesent pretium dapibus est interdum
hendrerit.
\end{document}
You can set \exhyphenpenalty=10000
. After this, the hyphen-like places (generated by -
or --
or ---
are unbreakable.
Advantage: The setting can be done only once at beginning of the document. You needn't to change the markup of the document.
Disadvantage: the word immediately followed after ---
is not hyphenated. If this brings the problem, you can insert explicitly hyphen points in this word by \-
.