TransWikia.com

Description list items: selective misbehaviour with Ligatures=TeX, fonts, xeLaTeX, and luaLaTeX

TeX - LaTeX Asked by Brent.Longborough on September 26, 2021

I’ve just come across this curiosity. Can anyone tell me what’s going on? Here’s the mwe:

documentclass[12pt]{article}
usepackage{fontspec}
setmonofont{Consolas}
begin{document}
texttt{
begin{description}
item[--help] Help
item[-{}-help] Help
end{description}}
end{document}

And here are the results:

LuaLaTeX:

enter image description here

XeLaTeX:

enter image description here

I get similar results with Source Code Pro in place of Consolas.

Now, I have two issues with this:

  1. -()- is, I believe, the canonical way to ‘break’ an automatic ligature. Why is LuaLaTeX producing incorrect output?
  2. In defiance of texttt{}, the description list [item]s are being set in Latin Modern Roman, rather than Consolas. Why?

(BTW, I appreciate I may be able to fix #2 with the enumitem package, but I shouldn’t have to, IMO.)

2 Answers

You don't need to break the ligatures if you set the mono font for the labels, because the monospaced font is loaded without the Ligatures=TeX option.

documentclass[12pt]{article}
usepackage{fontspec}
usepackage{enumitem}

setmonofont{Consolas}

newlist{ttdescriptioninner}{description}{1}
setlist[ttdescriptioninner]{font=ttfamily}
newenvironment{ttdescription}
 {ttfamilyttdescriptioninner}
 {endttdescriptioninner}

begin{document}

begin{ttdescription}
item[--help] Help
item[--help] Help
end{ttdescription}

end{document}

enter image description here

Correct answer by egreg on September 26, 2021

My thanks to Henri Menke and Ulrike Fischer for their observations.

  1. I am mistaken. -{}- is not the canonical way to break a ligature; rather, the correct way is -kern0pt-.
  2. This does not indicate an error in LuaLaTeX, but, rather, a design decision on the treatment of -{}-
  3. The enumitem package provides features to adjust the typesetting of the item label.

Answered by Brent.Longborough on September 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP