# How can I completely suppress ligatures?

The `microtype` package allows to completely suppress ligatures. However, this feature requires pdfTeX 1.30 or newer. That's unfortunate if I'm using LaTeX or XeLaTeX while having to avoid ligatures.

Is there any other way to disable ligatures for a complete document or just an environment?

-
the last time i checked, microtype is not compatible with xetex or xelatex. –  Mica Nov 15 '10 at 19:11
Just curious: why would you want to? I've never understood this feature. –  Will Robertson Nov 15 '10 at 23:55
@Will: Normally I don't suppress ligatures. But I also don't like to be patronized and so I wish to know how to disable features. Reading Tacos helpful answer and dealing with it gave me a deeper insight. –  Stefan Kottwitz Nov 16 '10 at 1:26
@stefank Okay, that's sensible :-) One common example for suppressing ligatures is for verbatim text, but I'm not aware of any others. –  Will Robertson Nov 16 '10 at 2:23
@Will: It may also be advisable to suppress ligatures in letterspaced text. –  lockstep Nov 16 '10 at 18:31

In XeLaTeX (or LuaLaTeX), if you are using an opentype/truetype font, you can just load it with the default ligature features (usually just `liga`) turned off.

In standard LaTeX, the only safe solution that I know is to create special tfm files that do not contain ligatures. The new primitive, '`\noligs`' in pdftex 1.30 was created specifically so that you do not have to mess with these tfm files. The modification to the tfm files is not that hard, but I do not know how to make latex make use of the results.

To patch a tfm file, say 'cmr10.tfm', first find the file and go to its location, then do this:

``````\$ tftopl cmr10.tfm > cmr10-noligs.pl
``````

The output file `cmr10-noligs.pl` is a 'human readable' representation of the tfm contents. You can open it in any text editor. Close to the top, there is a table that starts like this:

``````(LIGTABLE
(LABEL O 40)
(KRN C l R -0.277779)
(KRN C L R -0.319446)
(STOP)
(LABEL C f)
(LIG C i O 14)
(LIG C f O 13)
(LIG C l O 15)
``````

within the `LIGTABLE`, delete all lines with `LIG` in it (most fonts have only `LIG`, but there are some variations possible like `/LIG` and `LIG/>`). When you have done that, you may end up with combinations of `LABEL` and `STOP` on consecutive lines. Whenever that happens, delete both those lines also.

Then save the file, and run the shell command

``````\$ pltotf cmr10-noligs.pl
``````

This creates the new metrics file, `cmr10-noligs.tfm`, that can then be used to do typesetting without any automatic ligatures.

Before you can actually use this font, you (usually) also have to add a dvips/pdftex map file entry for it, otherwise these programs will believe you have created a completely new metafont font. In this case, my `pdftex.map` contains this line for `cmr10`:

`````` cmr10 CMR10 <cmr10.pfb
``````

all that is needed is a copy of that line with the new tfm name

`````` cmr10-noligs CMR10 <cmr10.pfb
``````

Note: it is actually possible that there is no matching map line for the original font because it was itself a virtual font. In that case, you do not need an extra map line at all, but you do need to copy the `<fontname>.vf` file (use `kpsewhich` to find it, it is on your disk somewhere) to `<fontname>-noligs.vf`.

Someone else will have to explain how to create a LaTeX package from new tfm files, I do not remember how to do that any more.

-
Wow! Is there really no simpler way to do this? –  András Salamon Aug 16 '10 at 20:58
You could use fontinst of afm2tfm or something similar from the original font files, but whether that is easier depends on your point of view. When I was still doing typesetting-for-hire, I had a script that did the above steps, and that was reasonably convenient. But I lost it in a disk crash, and when I needed it again a year or so later, implementing \noligs was easier than rewriting the script from scratch. –  Taco Hoekwater Aug 16 '10 at 21:29
Thank you very much for this explanation! Removing LIG entries but keeping the KRN lines should still preserve the kerning, as I understand. In contrary, microtype would switch off kerning by `\DisableLigatures`, according to its manual. –  Stefan Kottwitz Aug 17 '10 at 1:08
Yes, that is true. Using \DisableLigatures is equivalent to deleting the entire LIGTABLE construct. –  Taco Hoekwater Aug 17 '10 at 6:28
I get `undefined control sequence` for `\noligs`. Is there some mantra needed to invoke it? –  Loop Space Jan 21 '13 at 15:16
show 1 more comment

If you are using XeTeX (or LuaTeX) then you are most likely using fontspec as well to load OpenType font, so the following should disable any ligatures in the loaded font:

``````\setmainfont[Ligatures={NoRequired,NoCommon,NoContextual}]{Font Name}
``````

-

Try

``````\usepackage{microtype}
\DisableLigatures{encoding = *, family = * }
``````

It works in LaTeX, not only pdfTeX.

-
I use the typewriter font `\tentt` to avoid ligature. This is not really supression, its the nature of the font, fewer or no ligatures.
I wish I knew a way (simpler than the above tfm approach) to supress then in `\tenrm`.