8

I am aware that similar questions have been asked a few times. However, none of the answers solved my problem. This Answer says that it is a bug in luaotfload. But I'm already using a newer version (2.80001).

I'm trying to supress ligatures via selnolig package. It works great, but not for text that was set in capitals. Using microtypes \DisableLigatures or selnolig package \breaklig also has no effect. See MWE:

% !TeX program = lualatex
% !TeX encoding = UTF-8 Unicode
\documentclass[%
    a4paper,
    DIV=9,
    fontsize=14pt,
    parskip=half-
]{scrartcl}

\usepackage[ngerman]{babel}

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}[%
    Ligatures=Common,
    SmallCapsFeatures={Letters=UppercaseSmallCaps},
]

\setkomafont{disposition}{\rmfamily}

\usepackage[tracking=true]{microtype}
\SetTracking{encoding=*,shape=sc}{160}
\usepackage[ngerman]{selnolig}

\RedeclareSectionCommand[%
    font={\scshape\mdseries\Large}
]{section}

\RedeclareSectionCommand[%
    font={\mdseries\Large}
]{subsection}

\begin{document}
% Heading set in caps => ligature still present
\section{Berufliche Praxis}
Berufliche Praxis\par
ff fl fi

% Using \breaklig command => ligature still present
\section{Beruf\breaklig liche Praxis}

% Disabling selnolig => works as expected
\selnoligoff
\section{Berufliche Praxis}
\selnoligon

% No caps => works as expected
\subsection{Berufliche Praxis}

\end{document}

(very high tracking to make it clearer)

So the selnolig package takes care that ligatures in Berufliche gets suppressed. This is correct. But it does not work for headings with small caps. Adding \selnoligoff right before the \section seems to be the only way to supress ligatures in headings with small caps? Or have I missed a setting? I'm wondering which package is responsible for this bug.

  • 3
    \section{Beruf\kern0ptliche Praxis} – Steven B. Segletes Apr 3 at 11:11
  • Okay, \kern0pt works. Although this is rather inconvenient because it must be applied separately to each and every occurrence of all words that contain unwanted ligatures. The shortcut "|(provided by babel) does not work. – schmattes Apr 3 at 11:46
  • 1
    Is \kern0pt any more inconvenient that the attempted \breaklig? – Steven B. Segletes Apr 3 at 11:48
  • 1
    I added an issue here github.com/u-fischer/luaotfload/issues/53. – Ulrike Fischer Apr 3 at 15:28
  • 1
    The next luaotfload version will resolve the problem (for the automatic case, not for \breaklig which inserts a 0pt space). – Ulrike Fischer Apr 5 at 18:58
6

Here is an automated approach that reconditions the arguments of \section to look for specified ligatures, such as fl and to replace them with, for example, f\kern0ptl.

In the MWE, look for the lines between \makeatletter and \makeatother for the approach.

As an aside, I actually used the same method to also increase the default kern of the space character in small-caps section titles.

Shown for ligatures fl and ff. Can easily add more as needed.

EDITED to handle star sections/toc.

% !TeX program = lualatex
% !TeX encoding = UTF-8 Unicode
\documentclass[%
    a4paper,
    DIV=9,
    fontsize=14pt,
    parskip=half-
]{scrartcl}

\usepackage[ngerman]{babel}

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}[%
    Ligatures=Common,
    SmallCapsFeatures={Letters=UppercaseSmallCaps},
]

\setkomafont{disposition}{\rmfamily}

\usepackage[tracking=true]{microtype}
\SetTracking{encoding=*,shape=sc}{160}
\usepackage[ngerman]{selnolig}

\RedeclareSectionCommand[%
    font={\scshape\mdseries\Large}
]{section}

\RedeclareSectionCommand[%
    font={\mdseries\Large}
]{subsection}

\makeatletter
\usepackage{listofitems}
\expandafter\def\csname{fl}lig\endcsname{f\kern0ptl}% fl
\expandafter\def\csname{ff}lig\endcsname{f\kern0ptf}% ff
\expandafter\def\csname{ }lig\endcsname{\hspace{11pt}}% INCREASE SPACE KERN
\setsepchar{fl||ff|| }% CONCATENATE THE DESIRED LIGATURES WITH || "OR"
\let\svsection\section
\renewcommand\section{\@ifstar{\starsection}{\nostarsection}}
\newcommand\starsection[1]{%
  \tmptitle{#1}%
  \svsection*{\tmp}%
}
\newcommand\nostarsection[2][\relax]{%
  \tmptitle{#2}%
  \if\relax#1\relax\svsection[#2]{\tmp}\else%
    \svsection[#1]{\tmp}%
  \fi%
}
\newcommand\tmptitle[1]{%
  \readlist\myligs{#1}%
  \def\tmp{}%
    \foreachitem\x\in\myligs{%
      \expandafter\g@addto@macro\expandafter\tmp\expandafter{\x}%
      \ifnum\xcnt<\listlen\myligs[]\relax
        \expandafter\expandafter\expandafter\g@addto@macro
        \expandafter\expandafter\expandafter\tmp
        \expandafter\expandafter\expandafter{%
        \csname{\myligssep[\xcnt]}lig\endcsname}%
      \fi
    }%
}
\makeatother
\begin{document}
\tableofcontents

\hrulefill
\section[blah Berufliche]{Berufliche Praxis}

\section{Hoffähige Praxis}

\subsection{Berufliche Praxis}
\end{document}

enter image description here

Of course, I shouldn't mention the crazy stuff you can do with this approach. But I will. Adding these lines (and the xcolor package):

\expandafter\def\csname{e}lig\endcsname{\kern3pt\textcolor{red}{e}\kern1pt}
\setsepchar{fl||ff|| ||e}% CONCATENATE THE DESIRED LIGATURES WITH || "OR"

produces this result:

enter image description here

  • 1
    @Mico Thanks. Done. Plus support for increased space kerns. – Steven B. Segletes Apr 3 at 13:29
  • 2
    This looks like a really sophisticated hack. Thank you very much for your effort. – schmattes Apr 3 at 13:50
8

With a current luaotfload (version 2.96) you can disable the ligatures in the SmallCapsFeatures:

\documentclass[%
    a4paper,
    DIV=9,
    fontsize=14pt,
    parskip=half-
]{scrartcl}

\usepackage[ngerman]{babel}

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}[%
    Ligatures=Common,
    SmallCapsFeatures=
      {Letters=UppercaseSmallCaps,
       Ligatures=CommonOff}, %disable ligatures
]

\setkomafont{disposition}{\rmfamily}

\usepackage[tracking=true]{microtype}
\SetTracking{encoding=*,shape=sc}{160}

\RedeclareSectionCommand[%
    font={\scshape\mdseries\Large}
]{section}

\RedeclareSectionCommand[%
    font={\mdseries\Large}
]{subsection}

\begin{document}

\section{Berufliche Praxis}
Berufliche Praxis\par
ff fl fi

\end{document}

enter image description here

  • 1
    I still get the FL ligature though when I load selnolig. As in the OP selnolig has to be turned off explicitly to get rid of the ligature. – moewe Apr 3 at 11:23
  • @moewe Ah yes, selnolig interferes. – Ulrike Fischer Apr 3 at 11:27
  • 3
    @moewe and \selnoligoff works by paragraph and doesn't respect tex grouping, so you can add it simply to the font commands ;-(. – Ulrike Fischer Apr 3 at 11:37
  • I guess you meant “so you can't add…”? So selnolig is the one to “blame”? Maybe tex.stackexchange.com/users/5001/mico could comment on that? – schmattes Apr 3 at 11:53
  • 4
    Yes I meant "can't", and selnolig is not really to blame, but you need a more complicated setup to reset the setting after the section. – Ulrike Fischer Apr 3 at 11:59

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.