8

Is there a way to selectively disable a specific ligature in XeLaTex? I cannot see how. The selnolig package seems to do what I need but I don't even know how to use Lualatex with my Texshop setup on Mac.

Specifics: I am using XeLaTex, new to it and trying to figure my way around and set up some standard templates for my own use, e.g. academic papers. I am mostly using Linux Libertine O. I have the same issue with Adobe Caslon Pro.

Why: The "Th" ligature bothers me, particularly in titles. I never see it used in print. See, for example, the New Yorker magazine which uses Caslon, most ligatures are set but never Th. I never see it in books either. (I know this is picky).

  • Welcome to TeX.SX! Does T\/h not work? – user31729 Nov 8 '14 at 22:16
  • 1
    I find the “Th” ligature too pompous and usually awful. – egreg Nov 8 '14 at 22:39
  • Christian, is there a way to use T\/h as a macro instead of for each individual case? – jhg540 Nov 8 '14 at 22:41
  • 1
    Unfortunately “Th” is in the base ligatures, at least in Linux Libertine, which in my opinion is a wrong decision. – egreg Nov 9 '14 at 0:03
  • 1
    To run LuaLaTeX from TeXshop, select "LuaLaTeX" from the drop-down menu located next to the "Typeset" button. Then, click on "Typeset" to compile your document with LuaLaTeX (instead of, say, XeLaTeX). – Mico Nov 9 '14 at 23:09
6

As far as I know, there is no official way to disable a specific ligature. There are two workarounds: defining a new mapping, as egreg suggested, or using the XeTeXinterchartokenstate mechanism.

The latter is the one I prefer. I start by defining two character classes: FirstClass for T and SecondClass for h:

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\FirstClass
\XeTeXcharclass`T\FirstClass
\newXeTeXintercharclass\SecondClass
\XeTeXcharclass`h\SecondClass

I then instruct XeTeX to insert zero-size glue between T and h:

\XeTeXinterchartoks\FirstClass\SecondClass={\penalty\@M\hskip\z@}

Note that I'm using \hskip, which inserts glue, rather than \kern, which inserts a kern, as the latter has the side-effect of disabling hyphenation. However glue allows line breaks, which I disable by inserting a penalty.

No kerning will be applied between the T and the h, so you might need to tweak the width of the glue.

  • Nice trick; however just the penalty and a single class suffice. – egreg Nov 9 '14 at 11:19
  • @egreg probably true about just needing the penalty, but in practice you're going to need to do some manual kerning. How do you manage with just a single class? – jch Nov 9 '14 at 13:52
  • 2
    \newXeTeXintercharclass\noTh\XeTeXcharclass`T\noTh\XeTeXcharclass`h\noTh \XeTeXinterchartoks\noTh\noTh={\penalty10000 } – egreg Nov 9 '14 at 14:53
  • That's going to have the side effect of disabling any kerning between h and T. Probably not an issue, though. – jch Nov 9 '14 at 14:56
  • I'd be quite surprised if a kerning between h and T was defined in the first place. ;-) – egreg Nov 9 '14 at 15:00
5

Assuming you can figure out how to use LuaLaTeX instead of XeLaTeX from within TeXshop (not a difficult switch to make, really), you could indeed use the selnolig package to suppress the Th ligature globally throughout your document. Consider the following example (compiled under TeXshop, having selected "LuaLaTeX" from the drop-down menu):

enter image description here

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Adobe Caslon Pro}
\usepackage{selnolig}
\nolig{Th}{T|h} % suppress "Th" ligature globally
\begin{document}
The There They Then (Th-ligature disabled)

vs.
\selnoligoff %% suspend operation of selnolig's rules

The There They Then (Th-ligature re-enabled)
\end{document}
5

This is the least trickier solution, but it worked for me many times. Just before compiling do a search and replace of all Th by \Th (with a trailing space), with

\newcommand*\Th{T\kern0pt h}

This might seem less fun, but I think it's enough (it won't really pollute your source with tons of macros, just \Th once in a while).

  • I do not discuss if \penalty\@M\hskip\z@ is better (because of hyphenation), I just wanted to point out how easy is to use a macro (for this specific case). – Manuel Nov 9 '14 at 23:29
  • +1 for sheer ingenuity! Do note that because TeX doesn't hyphenate words that contain an explicit kern, words such as \Th inspace and \Th ickness may no longer be hyphenated with this approach. – Mico Nov 9 '14 at 23:40
  • If you just want to modify a single bit of text, this solution is great. I have a title with Listing of Figures in which I wanted to suppress the flourish of an st ligature. Using kern-space solution above (e.g., Lis\kern-1pt ting of figures) without the \newcommand allowed me to simply adjust one title without needing to modify the whole document. – Omar Wasow Oct 21 '18 at 19:07
3

In Linux Libertine, the Th ligature is among the basic ones, so either you disable all of them or you get it.

A way out is to load a special mapping. Copy the tex-text.map file you find in your TeX distribution and rename it tex-text-noth.map, adding a bottom line so that it becomes

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "TeX-text-noth"
RHSName "UNICODE"

pass(Unicode)

; ligatures from Knuth's original CMR fonts
U+002D U+002D           <>  U+2013  ; -- -> en dash
U+002D U+002D U+002D    <>  U+2014  ; --- -> em dash

U+0027          <>  U+2019  ; ' -> right single quote
U+0027 U+0027   <>  U+201D  ; '' -> right double quote
U+0022           >  U+201D  ; " -> right double quote

U+0060          <>  U+2018  ; ` -> left single quote
U+0060 U+0060   <>  U+201C  ; `` -> left double quote

U+0021 U+0060   <>  U+00A1  ; !` -> inverted exclam
U+003F U+0060   <>  U+00BF  ; ?` -> inverted question

; additions supported in T1 encoding
U+002C U+002C   <>  U+201E  ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C   <>  U+00AB  ; << -> LEFT POINTING GUILLEMET
U+003E U+003E   <>  U+00BB  ; >> -> RIGHT POINTING GUILLEMET

; disable Th
U+0054 U+0068   <>      U+0054 U+200C U+0068

Then run

teckit_compile tex-text-noth.map

and try the following example

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text-noth]{Linux Libertine O}

\begin{document}
The
\end{document}

Here's what I get:

enter image description here

You can move the files tex-text-noth.map and tex-text-noth.tex in your personal TeX tree (or have them in the same folder as your main file); on a Unix system you should do

mkdir -p $(kpsewhich -var-value TEXMFHOME)/fonts/misc/xetex/fontmapping/noth
cp tex-text-noth.* $(kpsewhich -var-value TEXMFHOME)/fonts/misc/xetex/fontmapping/noth/

No idea if you're using MiKTeX, sorry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.