Prevent hyphenation in `type-II` with LuaLaTeX

I want to prevent the hyphenation of `type-II` at the dash. I tried `type\nobreakdash-II` and `mbox` as workaround, but

• this is not very readable in the code and
• I want to separate layout information from the text where possiple.

How can I configure LuaLaTeX that it should never hyphenate a word at the dash, if less than 3 characters are left in the first or second part?

``````% Checked the variables:
\the\lefthyphenmin and \the\righthyphenmin
2 and 3
``````

I wonder why I got a hyphenation `type-` `II` while `\righthyphenmin` is set to 3.

• “In the case of plain TeX, empty discretionaries are therefore inserted after hyphens and dashes. (Each font has an associated `\hyphenchar`, which we can assume for simplicity is equal to ‘`-`’.)” The TeXbook, page 95. Apr 24 '19 at 9:36
• @HenriMenke I see, but what is the consequence? Does this mean `type-II` has a `\hyphenchar` inside which overwrites `\righthyphenmin`? Apr 24 '19 at 9:56
• No, `type-II` becomes `type-\discrectionary{}{}{}II` and for explicit discretionaries word hyphenation limits do not apply. Apr 24 '19 at 10:00
• You can insert an explicit kern to suppress the automatic discretionary `type-\kern0pt II`. Apr 24 '19 at 10:08

One option is to define a more-readable macro `\typeII` and `\TypeII` that expand to `\mbox` or `\nobreakdash` and prevent hyphenation. You might want to add the `xspace` package to avoid the need to write `\typeII{}` or `{\TypeII}`.
Another is to `\usepackage[shortcuts]{extdash}`, which allows you to write `type\=/II`.
Including `microtype` on LuaLaTeX or PDFLaTeX might help, since font expansion can drastically cut down on the amount of hyphenation.
• @JonasStein There are a few ways to suppress hyphenation, but the only one I can think of that doesn’t involve any code at all would be to load `fontspec` and insert a look-alike character such as U+2010. Apr 24 '19 at 15:42