9

In order to switch off ligatures for a whole document using LuaLaTeX, I put the following lines into the preamble:

\usepackage{fontspec}   
\defaultfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}}

However, the output document still shows ligatures. I also tried this command:

\usepackage{fontspec}   
\defaultfontfeatures{
  Ligatures={-Required, +NoRequired, -Common, +NoCommon, -Contextual, +NoContextual,
             -TeX, -Rare, -Historic}}

but with the same result.

Any ideas why switching off ligatures is not working?

EDIT: The anser to my question is hidden in one of the comments on Patrick's answer: It is necessary to explicitly select a font via one of the fontspec commands afterwards, in order to have the Ligaturessetting take effect. For example:

\usepackage{fontspec} 
\defaultfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}}
\setmainfont{Latin Modern Roman}
Dieter
  • 221
  • LuaTeX is at version 5? – Simurgh12 May 05 '12 at 09:09
  • 5.1 is at least the number my MieKTeX Package Manager mentions for the Lua binaries (miktex-lua51-bin-2.9). – Dieter May 05 '12 at 09:56
  • that would be lua not LuaTeX. Your distribution will come with a version of the lua compiler (as in a compiler of the lua programming language) and this is what you describe. LuaTeX is currently at version 0.70.something – ArTourter May 05 '12 at 10:22
  • 1
    You should provide a MWE. Without that (see the comments) we can only guess what you're trying to do. – topskip May 05 '12 at 17:38
  • related: https://tex.stackexchange.com/questions/103238/removing-ligatures-when-using-fontspec – matth May 12 '19 at 20:03

2 Answers2

12

You have three choices to instruct fontspec to suppress ligatures:

The first is to name the default font features that are valid for the next font assignments:

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\defaultfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}}
\setmainfont{Linux Libertine O}
I eat  -- the fluffiest `? ``fish''.
\end{document}

You can also add font features to the current font:

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\setmainfont{Linux Libertine O}
\addfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}}
I eat  -- the fluffiest `? ``fish''.
\end{document}

Or you can instruct fontspec to load a font with the given features:

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\setmainfont[Ligatures={NoRequired, NoCommon, NoContextual}]{Linux Libertine O}
I eat  -- the fluffiest `? ``fish''.
\end{document}

All of these result in:

enter image description here

topskip
  • 37,020
  • For me that means that I need to set again the default font, whatever that is, because I use LuaLaTeX as a rendering engine for a .NET application. Therefore, I do not know which font is actually the default one on the current system. Is there a command that I can use inside the \setmainfont{} command to advise it to use the current mainfont? – Dieter May 05 '12 at 10:07
  • 1
    @Dieter you can use \addfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}} for that purpose. – topskip May 05 '12 at 10:55
  • 1
    if you use fontspec without specifying the fonts, luatex should default to Linux Modern. Without fontspec it should behave like any other latex compiler and use CM (unless you specify a fontencoding. – ArTourter May 05 '12 at 10:58
  • @ArTourter It should be "Latin Modern". – egreg May 05 '12 at 14:04
  • \documentclass[]{article} \usepackage{fontspec} \addfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}} \begin{document} I eat -- the fluffiest? ``fish''. \end{document}` – Dieter May 05 '12 at 16:47
  • I tried the following code, but without success:

    \documentclass[]{article} \usepackage{fontspec} \addfontfeatures{Ligatures={NoRequired, NoCommon, NoContextual}} \begin{document} I eat -- the fluffiest? ``fish''. \end{document}`

    It still gives me ligatures (in a serif font).

    When I attempt to change the font, LuaLaTeX trys to generate a font names database, but crashes after about half a minute. I tried to run mkluatexfontdb manually, but it again crashed with a fatal error. I am using an up-to-date MiKTeX 2.9 on Windows Vista in an Administrator shell.

    – Dieter May 05 '12 at 16:59
  • @Dieter if you use the default font, then why do you load fontspec at all? Fontspec does not work with a font that is not loaded by fontspec. – topskip May 05 '12 at 17:36
  • @Patrick that was not apparent to me. I mistakingly thought by loading the fontspec package it would take over the whole font management including adjusting the default font. -- What would be the best practice for selecting a default font for different systems (Win, Linux, Mac) in the same source file? – Dieter May 05 '12 at 17:52
  • @Dieter A default font is, well, a default font. No need to select anything. – topskip May 05 '12 at 18:00
  • @Patrick I ment: If Fontspec does not work with a font that is not loaded by fontspec, I need somehow to specify the default font again with a Fontspec command, correct? What is the best way to do this platform neutral? – Dieter May 05 '12 at 20:37
  • @Dieter \setmainfont[Ligatures={NoRequired, NoCommon, NoContextual}]{Latin Modern Roman} should do the trick. If not, please ask a separate question here on this site. This way more people can help you. – topskip May 05 '12 at 20:50
0

In case you only want to suppress the "bad" ligatures, you can go for 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

Discussion regarding fontspec and lualatex: Can we stop recommending fontspec as first choice in case lualatex is used?

koppor
  • 3,252