[Tex/LaTex] How to completely suppress ligatures

ligaturesmicrotype

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?

Best Answer

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.