LaTeX forum ⇒ Text FormattingLine break at a hyphen/dash

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Line break at a hyphen/dash

Postby meho_r » Sun Aug 16, 2009 2:52 pm

Hi

This "issue" is bothering me for some time now. Here's the plot:

1. In words where a hyphen exists there usually should be no linebreak (that is in case of hyphenation) after it. E.g. "Al-Ghazali" shouldn't be broken at the end of the line after "Al-", so that the next line begins with "Ghazali". I solved this with \nobreakdash-\hspace{0pt}

  1. Al\nobreakdash-\hspace{0pt}Ghazali


With this, there will be absolutely no break/hyphenation in any case, which isn't always what I want (especially when transcribing arabic sentences with a lot of hyphens). This leads to the point 2.

2. In some cases I would like to have the word broken after the hyphen, but the rules of my language demand that in that case a hyphen must exist at the end of the line as well as in the beginning of the next line (that is, two hyphens. Note that this DO NOT apply for hyphenation of ordinary words, only if the word is hyphenated after the hyphen that is part of the word). It will look as follows:

  1. Line 1. Some text ... Al-
  2. Line 2. -Ghazali ...


So, the question is: how to make this additional hyphen on the line 2 appears only in case the word is broken after the hyphen and doesn't appear when it isn't broken?

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Postby phi » Sun Aug 16, 2009 3:32 pm

Hello,
try
  1. \discretionary{-}{-}{-}

User avatar
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Postby meho_r » Sun Aug 16, 2009 6:45 pm

Great! Thanks a lot, phi. I tested it and works nice :-)

A thought comes in mind, is there a way to make this behavior default for hyphens, so that, whenever I enter "Al-Ghazali" it applies automatically, so I don't have to create a command with \discretionary{-}{-}{-} in it which will do this? Pointing on the literature where I can find out will do the trick too ;-)

Thanks again.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 7 guests