I have two requirements. I can achieve each one of these two requirements separately but I have not been able to combine them.
First, I need to allow the hyphenation of dashed words (eg: "entendendo-se"), which by default it isn't possible. Example:
enten-
dendo-se
or
en-
tendendo-se
Then, when a word is hyphenated, if the line break occurs on the dash, it should add another dash in the following line (this is a portuguese language rule). Example:
entendendo-
-se
I know that I can achieve the first one by using the extdash
package with \-/
and I can achieve the second one by defining a macro that will replace the dashes with \discretionary{-}{-}{-}
.
But how can I combine both requirements in a solution?
And finally, but not required, would it be possible to apply the solution to all the dashes throughout some part of the text (so that I don't need to replace every dash with a command [or whatever would be used])?
PS: I am currently using the XeLaTeX compiler.
EDIT with more information
Minimal working example
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage{hyphenat}
\begin{document}
\chapter{Exemplo}
Texto completamente aleatório, foi feito para demonstrar o porquê de entendendo-se não ser hifenizado corretamente.
\end{document}
In this example, the word entendendo-se
breaks on the dash but it could have been broken sooner.
- The solution for my first requirement would be to add
\usepackage[shortcuts]{extdash}
and replaceentendendo-se
withentendendo\-/se
. This is needed because LaTeX doesn't break dashed words by default. You will see that the word breaks sooner (because LaTeX believes it makes the first line prettier) and this is one of the things I want to achieve. The word appears like this:enten- dendo-se
- The solution for my second requirement would be to replace
entendendo-se
withentendendo\discretionary{-}{-}{-}se
. You will see that, when the word breaks on the dash, another dash is added in the next line (which is a portuguese rule) and this is my second requirement. The word appears like this:entendendo- -se
. Please note that if the word does not break on the dash, no additional dash should be added!
However, I have not been able to combine both...