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.

My language, Portuguese, have undergone another orthography reform (those committees simply can't avoid themselves from doing this mess from time to time.) Now we have to adapt, which brings us to my problem.

By the new rule, when a line break occurs at one word's literal hyphen, it should be doubled, appearing at the end of the first line and at the beginning of the second one.

A phrase like “Terão que adaptar-se ou perecer!”, broken at the hyphen, should look like this:

Terão que adaptar-
-se ou perecer!

In TeX terms, each literal hyphen should be replaced by

\discretionary{-}{-}{-}

or followed by

\discretionary{}{-}{}

But TeX's (apparently) hard coded discretionary for literal hyphen is \discretionary{}{}{} (called “empty discretionary”), inserted after every “-” [The TeXBook, p. 95].

The obvious solution

\chardef\hyphen=`\-
\catcode`\-=13
\def-{\penalty\exhyphenpenalty
\discretionary{\hyphen}{\hyphen}{\hyphen}}

is hardly usable because you cannot redefine a character like “-”, heavy used by TeX assignments, without getting too much trouble.

Is there a right way to get this effect? Or only by diving into TeX's source code or waiting for LuaTeX?

share|improve this question
4  
The standard babel way to proceed would be to activate " and define a shortcut "-. The activation of - can be done, either, but one has to remember to say \string- when the hyphen is needed in the context of a numeric assignment. –  egreg Jul 15 '11 at 7:54
    
@Caio: Interesting, I was unaware of that specific rule, thanks for bringing this up. Sadly, we have to adapt (I think the transition period ends this year), but I'll resist until the very last minute. =) –  Paulo Cereda Jul 16 '11 at 20:32

2 Answers 2

up vote 8 down vote accepted

One approach without requiring LuaTeX would be to take a similar tack to the way hyphenation is/used to be handled in German. Something like

\documentclass{article}
\catcode`\"=\active
\def"#1{\ifx#1-\discretionary{-}{-}{-}\fi}
\begin{document}
Some filler text. 
Some filler text.
Some filler text.
Some filler text.
Some"-hyphenated word.
\end{document}

Of course, this requires the use of one additional character, which may not be desirable. On the other hand, I don't think that there is a hook in the TeX engine to alter things, so the only 'no input change' way to alter things is I guess to use LuaTeX.

share|improve this answer
    
Hyphenated words are badly common in Portuguese, using this method would make the manuscript too messy. Thanks for the advice, I'll research LuaTeX for an answer and give a feedback to this forum. –  Caio Lopes Jul 16 '11 at 3:32

The alternative I commonly use is the redefinition of the underscore to provide this doubled-when-broken hyphen:

\let\oldunderscode=_
\catcode`\_\active
\def_{\ifmmode\oldunderscore\else\discretionary{-}{-}{-}\fi}

This keeps the meaning of _ in mathematical mode, which is essential!! Also, take care not to use _ in your labels, as they will not work. I usually write \label{my-section} anyway, so this is not a problem for me.

Now, you just need to write Terão que adaptar_se ou perecer!, which I think is still very readable and has the advantage of using a single character as well.

I usually place code similar to that in a separate .sty file which I import whenever I need it. This package helps me write small portions of Portuguese text inside documents with English as main language, which changes hyphenation rules (provided babel is loaded with Portuguese language) and also emits a \frenchspacing that disables the "double space" at the end of sentences that is traditional in English typography but not in Portuguese.

share|improve this answer

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.