1

I have been transcribing an old, public-domain novel and am attempting to typeset it using Latex as close as I can to the original formatting of the book. I've taken Memoir template and am modifying it to this end but I'm not much of a Latex expert. One feature on the novel is the common use of em dashes for asides without any spaces between the words preceding or proceeding the dash, like so:

a photo of some text demonstrating the use of em dashes without spaces

When I typeset this (just using the em dash character "—" itself in the files) it caused Latex to treat "neighbours—namely" as one big word that it wouldn't break up, causing lines to run into the margin a lot. To solve this I used the \discretionary command to to allow these to be broken up (based on this answer) like so:

\let\emdash\textemdash
\renewcommand{\textemdash}{\discretionary{\emdash}{}{\emdash}}

This has mostly worked but I have found that when it is applied Latex will only break at the em dashes for these cases, it will not break up the individual words even when that would make more sense. For example:

the word Drumglass followed by an em dash running into the margins of the page

I have a hyphenation rule set up for the word Drumglass.

\hyphenation{Drum-glass}

And I would expect this line to be broken up like so:

  “So the old man is still bent upon being lord of Drum-
glass—monarch of all he surveys—or rather[...]

Rather than running into the margin.

Is there a way to tell Latex to both allow it to break at an em dash but also that it is still fine to hyphenate the individual words if the line is stilling running into the margin after it does that?

Edit: As David Carlisle suggested in the comments I replaced the discretionary command with the following instead:

\let\emdash\textemdash
\renewcommand{\textemdash}{\nolinebreak\hspace{0pt}\emdash\hspace{0pt}}
5
  • 3
    use \nolinebreak\hspace{0pt}\textemdash\hspace{0pt} then it will be two separate words for hyphenation. Jun 5, 2022 at 10:34
  • @DavidCarlisle would it be possible to add a command to the start of the main document to replace all instances of em dashes with this rather than manually replacing each individual instance in the chapter texts?
    – regret
    Jun 5, 2022 at 10:43
  • yes exactly as you did it, but using that form rather than \discretionary Jun 5, 2022 at 10:46
  • Ah yes, I have it now! Thank you.
    – regret
    Jun 5, 2022 at 10:54
  • This might help in explaining the original non-hyphenation: Why can words with hyphen char not be hyphenated? Jun 5, 2022 at 14:49

1 Answer 1

1

I'll post this as an answer so there's one here rather than it just being in the comments, but credit to David Carlisle for providing this solution. I've replaced the \discretionary command with this one and it seems to behave exactly how I want:

\let\emdash\textemdash
\renewcommand{\textemdash}{\nolinebreak\hspace{0pt}\emdash\hspace{0pt}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .