[Tex/LaTex] Portuguese: line break at an hyphen in an explicitly hyphenated word

hyphenationline-breaking

In Portuguese, many words are explicitly hyphenated, such as "anti-inflamatório".

According to Portuguese hyphenation rules, if the line is broken at the hyphen, another hyphen should be added to be beginning of the next line (otherwise we do as everyone else…).

Example 1: An example of "normal" hyphenation:

Necessito de pensar em tomar um anti-infla-
matório e bem depressa.

Example 2: An example of hyphenation at the hyphen (notice the extra hyphen in the next line):

Necessito de pensar em tomar um anti-
-inflamatório e bem depressa.

How can I achieve the behaviour of Example 2? (Babel does not add the extra hyphen in the next line by default…)

Thank you.

João Lourenço

Best Answer

A recent babel (>=3.37) with luatex can do it for you:

\documentclass{article}

\usepackage[portuguese]{babel}

\babelposthyphenation{portuguese}{.=.}{
  {},
  { no = -, pre = -, post = -, data = 1 },
  {}
}

\begin{document}

Necessito de pensar em tomar um anti-inflamatório e bem depressa.

zzz zzz zzz zzz zzz zzz zzz zzz zzz
Necessito de pensar em tomar um anti-inflamatório e bem depressa.

\end{document}

Here, \babelposthyphenation defines a non-standard hyphenation rule. Currently the code is not very efficient, but in many cases it's hardly noticed. For further details, see Non–standard hyphenation with luatex.

Edit. Now babel provides a predefined transform for this task, which can be enabled with the following preamble:

\documentclass{article}
\usepackage[portuguese]{babel}
\babelprovide[transforms = hyphen.repeat]{portuguese}