Take the 2-minute tour ×
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.

I am looking to produce directional variants of the en-dash. A "left en-dash" should have half of ordinary inter-word spacing on its right and allow line-breaks only on its left; a "right en-dash" should have half of ordinary inter-word spacing on its left and allow line-breaks only on its right. This is intended to aid the visual parsing of parenthetical phrases: "Here - as in his other works - the composer alludes to Italian folk dances."

What is the best way to define such commands? Let's name them \ldash and \rdash.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You can use

\newcommand{\ldash}{--\nobreak\,\nobreak\ignorespaces}
\newcommand{\rdash}{\unskip\nobreak\,\nobreak--}

\nobreak inserts a large \penalty, discouraging (not avoiding) a line or page break at that location. A small space on the sides are offered by \,, while \unskip and \ignorespaces removes the whitespace naturally inserted between words.

share|improve this answer
    
Usage for your solution would be some words \ldash parenthetical expression \rdash{} some words. Is there an easy way to modify the \rdash macro so that I can omit {} after it? –  Lover of Structure Oct 26 '12 at 4:38
1  
@user14996: xspace can be used: \usepackage{xspace}\newcommand{\rdash}{\unskip\nobreak\,\nobreak--\xspace} –  Werner Oct 26 '12 at 4:44
    
Isn't \nolinebreak instead of \nobreak cleaner here? –  Lover of Structure Jun 16 '13 at 11:36
    
Actually, a better approach might be to prepend \leavevmode to \rdash: \leavevmode\unskip\nobreak\,\nobreak--\xspace; otherwise the first \nobreak will be equivalent to a \nopagebreak if \rdash is used paragraph-initially, right? It does make sense for \rdash to have no spacing if used paragraph-initially (for whatever reason; of course this shouldn't normally occur), but I'm not sure how to get this effect. This case won't occur in normal code, but I think it might occur accidentally, so perhaps one should guard against it? –  Lover of Structure Jun 17 '13 at 15:51
    
If \ldash happens to be typeset at the beginning of a line, it might strut into the margin. Writing \hspace*{0pt}\ldash fixes this. –  Lover of Structure Jul 4 '13 at 10:16

Your Answer

 
discard

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.