I found this answer on http://www.oipapio.com/question-79176
\documentclass[10pt,a5paper,twoside]{article}
\usepackage{hyphenat}
\cs_new:Npn \hyphenfix_emdash:c {---}
\cs_new:Npn \hyphenfix_endash:c {--}
\cs_new:Npn \hyphenfix_discardnext:NN #1#2{#1}
\catcode`\-=\active
\cs_new_protected:Npn -{
\futurelet\hyphenfix_nexttok\hyphenfix_i:w
}
\cs_new:Npn \hyphenfix_i:w {
\cs_if_eq:NNTF{\hyphenfix_nexttok}{-}{
%discard the next `-` token
\hyphenfix_discardnext:NN{\futurelet\hyphenfix_nexttok\hyphenfix_ii:w}
}{
% from package hyphenat
\hyp
}
}
\cs_new:Npn \hyphenfix_ii:w {
\cs_if_eq:NNTF{\hyphenfix_nexttok}{-}{
\hyphenfix_discardnext:NN{\hyphenfix_emdash:c}
}{
\hyphenfix_endash:c
}
}
\begin{document}
\section{Show font}
Tests.
Encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding.
Encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding.
\end{document}
It should allow me to use - as \hyp{} and two -- as one -, but when compiling it throws this error:
Package: hyphenat 2009/09/02 v2.3c hyphenation utilities
\langwohyphens=\language77
LaTeX Info: Redefining \_ on input line 43.
)test1.tex:4: Undefined control sequence
Here is how much of TeX's memory you used:
232 strings out of 493314
This feature would be very welcomed because, in my language, I use a lot of - (hyphens) and it is horrible to keep typing (and remembering to type) \hyp{} everywhere.
Related questions:
- Adequate hyphenation of words already containing a hyphen
- Hyphenat not hyphenating words with hyphens
- How to copy minus as hyphen?
- Problem expanding acronyms containing \hyp{} in captions
- Hyphenation problem
Update
I managed to get it working after adding the expl3 package. I thought it was not required. Full example:
\documentclass[10pt,a5paper,twoside]{article}
\usepackage{hyphenat}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new:Npn \hyphenfix_emdash:c {---}
\cs_new:Npn \hyphenfix_endash:c {--}
\cs_new:Npn \hyphenfix_discardnext:NN #1#2{#1}
\catcode`\-=\active
\cs_new_protected:Npn -{
\futurelet\hyphenfix_nexttok\hyphenfix_i:w
}
\cs_new:Npn \hyphenfix_i:w {
\cs_if_eq:NNTF{\hyphenfix_nexttok}{-}{
%discard the next `-` token
\hyphenfix_discardnext:NN{\futurelet\hyphenfix_nexttok\hyphenfix_ii:w}
}{
% from package hyphenat
\hyp
}
}
\cs_new:Npn \hyphenfix_ii:w {
\cs_if_eq:NNTF{\hyphenfix_nexttok}{-}{
\hyphenfix_discardnext:NN{\hyphenfix_emdash:c}
}{
\hyphenfix_endash:c
}
}
\ExplSyntaxOff
\begin{document}
\section{Show font}
Tests.
Encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding-encoding.
Encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding\hyp{}encoding.
\end{document}
Now, by curiosity. Why I do not see much people using this trick everywhere else?
Does this command is breaking something in latex? Then, is it unadvised to use it?

I actually found out yesterday, that there is a
– The Shadow Sep 06 '19 at 07:29\hyphen{}command, which does basically the same as\hyp{}but without needing the hyphenat package. I could not find out which ressource this command is delivered from. Does anybody know?