5

OK, so I use the emdash as follows: someword---anotherword, but the problem is this prevents hyphenation of both words around the dash. I can fix this by replacing --- with \textemdash, but I was wondering, is there any way to redefine the --- "command" with \textemdash?

I use LuaTeX. Related to this issue issue I've found this and this, but neither provides an acceptable solution...

Thanks in advance!

  • Just my opinion, but it would seem to me a bit ugly to have a hyphen in a word that also adjoins an em-dash. – A.Ellett Aug 29 '13 at 17:57
  • True, but having an overlong paragraph manages to be even uglier, so... :-) – wmnorth Aug 29 '13 at 17:59
  • Assuming this does not happen too much you could always fix it ad hoc with optional hyphens, like so: some\-word---another\-word. But clearly that's not the general solution you seek. – Thruston Aug 29 '13 at 21:19
  • Or type someword{}---{}anotherword, but again not general... – Thruston Aug 29 '13 at 21:31
  • Or investigate the extdash package. The reason this is hard is that the --- is defined as a ligature deep down in the TeX fonts rather than as a macro. – Thruston Aug 29 '13 at 21:47
3

The extdash package does what you want, but you have to type \--- instead of ---.

\documentclass{minimal}
\usepackage[shortcuts]{extdash}
\begin{document}
someword\---anotherword
\end{document}

See also this longer discussion elsewhere on TeXSE.

  • This almost right, except for the fact that it adds a small amount of whitespace before and after the dash. I've looked at the package's documentation, but it doesn't mention a way to alter this behaviour. Is there one? – wmnorth Aug 30 '13 at 10:32
  • I don't know extdash that well, but I'll add a pointer to another question and answer with a longer discussion on the same topic. – Thruston Aug 30 '13 at 15:21
  • I actually had already seen that discussion, but had forgotten about it when got myself to type this question. It did not help me much, I'm afraid. Anyway, given that your answer was closest to what I wanted, I'll mark it is as the right one. – wmnorth Sep 3 '13 at 12:08
5

ConTeXt MkIV supports automatic hyphenation of compound words by setting

\setbreakpoints[compound]

Here is an example

\setbreakpoints[compound]
\starttext
 \startframedtext[width=5cm]
  Just some random text to see if someword---anotherword hyphenates or not.
\stopframedtext
\stoptext

which gives

enter image description here

  • And can this somehow be done in LuaLaTeX, too? – Gaussler Aug 15 '15 at 13:43
  • @Gaussler: I am sure that it should be possible to port the ConTeXt code to LaTeX. But I am not familiar with LaTeX internals. It may be better to ask that as a separate question to get the attention of LaTeX experts. – Aditya Aug 15 '15 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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