Can one (more or less) automatically suppress ligatures for certain words?

In LuaTeX you can intercept the input and change it before TeX sees it. This can be used to disable certain ligatures. Here is a proof of concept in ConTeXt.

\usemodule[translate]

\translateinput[selfish][self|*|ish]
\translateinput[halflife][half|*|life]

\starttext

A selfish person has a small halflife.

\enableinputtranslation 

A selfish person has a small halflife.

\disableinputtranslation

A selfish person has a small halflife.

\stoptext

which gives

enter image description here

See m-translate.mkiv in the ConTeXt distribution for implementation details. Keep in mind that this will change all occurrences of "selfish" to "self|*|fish", including those in csname. For example, if you have a selfish environment, it will fail! The advantage of this approach is that it will work for all words that contain selfish; for example, selfishness, unselfish, etc.

|*| disables ligatures and does not affect hyphenation. But it introduces a 0.05em kern between the two letters. If you do not like that add

\definetextmodediscretionary *
  {\prewordbreak\discretionary{-}{}{}\prewordbreak}

Just today I discovered a blog-entry on this issue. As it turns out there are two ready-to-use different solutions to this problem on CTAN:

  • rmligs uses a word-list from Ispell
  • ligatex uses a syllable-based approach, not unlike TeX's hyphenation

Both are TeX-independend programs which modify the source before compiling. Both are only for German, but are supposed to be customisable for other languages.


In case one use LuaLaTeX, you can use the selnolig package. Be aware that one has to use the fontspec package then.

English:

\usepackage[english]{selnolig}

German:

\usepackage[ngerman]{selnolig}

More information:

  • New package, selnolig, that automates suppression of typographic ligatures
  • Explanation of selnolig vs. babels "| shortcut: https://tex.stackexchange.com/a/389439/9075
  • Discussion regarding fontspec and lualatex: Can we stop recommending fontspec as first choice in case lualatex is used?