1

Edit: Included different variants to show that everything seems to work fine.

I'd like to use selnolig with the default font used by lualatex. The reason is that I write a paper using the Simplified LNCS Template (which is based on Springer LNCS conference template). The template uses the default latex font. When the workshop organizers publish on CEUR-WS.org (as we do in the ZEUS workshop), we do not need to double-check with Springer.

Introduction into selnolig

selnolig works fine when using fontspec. Here an example with "TeX Gyre Termes: "workflow" has a ligature and "dwarflike" not.

\documentclass{article}
\usepackage[ngerman,english]{babel}
\usepackage{fontspec}
\usepackage[english]{selnolig}
% hint by http://tex.stackexchange.com/a/321066/9075 -> enable "= as dashes
\addto\extrasenglish{\languageshorthands{ngerman}\useshorthands{"}}
\setmainfont{TeX Gyre Termes}
\begin{document}
\noindent
workflow -- ligature is correct here\\
dwarflike -- no ligature (automatically)\\
dwarf{\breaklig}like -- no ligature (manually, using selnolig)\\
dwarf"|like -- no ligature (manually, using babel)
\end{document}

MWE1

MWE without fontspec

\documentclass{article}
\usepackage[ngerman,english]{babel}
\usepackage[english]{selnolig}
\addto\extrasenglish{\languageshorthands{ngerman}\useshorthands{"}}
\begin{document}
\noindent
workflow -- ligature is correct here\\
dwarflike -- no ligature (automatically)\\
dwarf{\breaklig}like -- no ligature (manually, using selnolig)\\
dwarf"|like -- no ligature (manually, using babel)
\end{document}

Result

! Package selnolig Error: ==========================================
(selnolig)                Error Alert Error Alert
(selnolig)                ------------------------------------------
(selnolig)                The selnolig package *requires* the
(selnolig)                'fontspec' package, but it hasn't been
(selnolig)                loaded. Exiting now.
(selnolig)                ===========================================.

MWE without setmainfont

\documentclass{article}
\usepackage[ngerman,english]{babel}
\usepackage{fontspec}
\usepackage[english]{selnolig}
\addto\extrasenglish{\languageshorthands{ngerman}\useshorthands{"}}
\begin{document}
\noindent
workflow -- ligature is correct here\\
dwarflike -- no ligature (automatically)\\
dwarf{\breaklig}like -- no ligature (manually, using selnolig)\\
dwarf"|like -- no ligature (manually, using babel)
\end{document}

Result

MWE2

MWE with fontspec and switching back to lmodern manually

From the documentation:

If the selnolig package is run under LuaLaTeX but the fontspec package isn’t loaded by the time the \begin{document} statement is encountered, selnolig will terminate with an error message.

So, I tried to set an arbitrary font and then switch back to the default font:

\documentclass{article}
\usepackage[ngerman,english]{babel}
\usepackage{fontspec}
\usepackage[english]{selnolig}
% hint by http://tex.stackexchange.com/a/321066/9075 -> enable "= as dashes
\addto\extrasenglish{\languageshorthands{ngerman}\useshorthands{"}}
% hint by https://tex.stackexchange.com/a/24998/9075 -> switch back to latin modern
\setmainfont{TeX Gyre Cursor}
\renewcommand\rmdefault{lmr}
\renewcommand\sfdefault{lmss}
\renewcommand\ttdefault{lmtt}
\begin{document}
\noindent
workflow -- ligature is correct here\\
dwarflike -- no ligature (automatically)\\
dwarf{\breaklig}like -- no ligature (manually, using selnolig)\\
dwarf"|like -- no ligature (manually, using babel)
\end{document}

The result is as follows.

MWE3

Question

Are there any issues in just loading fontspec and not to use setmainfont?

koppor
  • 3,252
  • 1
    your question isn't very clear, in the title you ask about latin modern (the default lualatex font) but in the body of the question you ask about computer modern, using a 7bit font with luatex is technically possible but seems a bit odd? (it certainly disables fontspec completely) – David Carlisle Mar 08 '18 at 23:32
  • @DavidCarlisle That was a typo. I changed the wording in the last paragraph to "latin modern" and added to pointer to cfr-lm. -- Maybe, it would be better to rephrase the question to "How to have selnolog work with the default font?" – koppor Mar 08 '18 at 23:40
  • If you want the default font remove all the settings to OT1 encoded cmr as the lualatex default is TU encoded lmr – David Carlisle Mar 08 '18 at 23:44
  • you changed the wording but the first code fragment is still selecting cmr rather than the default latin modern – David Carlisle Mar 08 '18 at 23:50
  • Is lmr the right rmdefault then? I updated the code: Same result. My guess is that selnolig fetches the font metrics from the font set by setmainfont and does not update its internal metrics when renewcommand on fonts is used. However, I wonder, why selnolig has to use font metrics at all. Maybe, it establishes a hook when the font is used. – koppor Mar 09 '18 at 00:03
  • 2
    as I tried to show in my answer below your code is not "switching back" it is switching to a completely different font technology, a classic tex 7bit tfm font rather than the default opentype latin modern – David Carlisle Mar 09 '18 at 00:04
  • 3
    Off-topic: As a general rule, selnolig should be loaded after babel. The load ordering doesn't affect the issue described here, but it can matter in other circumstances. – Mico Mar 09 '18 at 00:25
  • 1
    Are you sure that use of LuaTeX is permitted? – cfr Mar 09 '18 at 00:33
  • 1
    The issue of how much whitespace (if any) should be inserted in order to create a visible gap between "f" and f/i/l is strongly font-dependent. babel's "| method not only breaks up the ligature but also inserts 0.03em of whitespace. This setting seems to have been arrived at for the Computer/Latin Modern Roman font face and, in particular, the f-l ligature case. Inserting whitespace is actually not at all necessary for the f-f and f-i cases. With Times Roman, in contast, 0.03em is not sufficient for the f-l case. And, for EB Garamond, one would have to insert 0.11em to create a gap. Argh. – Mico Mar 09 '18 at 00:51
  • Echoing @cfr's comment: You better check back with the publisher to verify that it's OK to use LuaLaTeX to compile the document. If the publisher insists that it's got to be pdfLaTeX, don't waste your time on optimizing everything for LuaLaTeX. – Mico Mar 09 '18 at 00:53
  • In the concrete case, we are self-publishing. For the general case, I agree and I will add a hint at https://latextemplates.github.io/LNCS/ for using lualatex. – koppor Mar 09 '18 at 08:20
  • @Mico Oh, wow. Do I get it right that the package selnolig is the only one offering a proper "breaklig" and thus it works only at lualatex? I am thinking of adding demonstration texts in texts compiled using pdflatex. -- This also means, the tools rmligs, delig, and ligatex are all doing wrong (in the general case)? – koppor Mar 09 '18 at 08:33
  • 1
    @koppor - So far, I haven't found a clear, first-principles explanation for why babel inserts 0.03em whitespace when "| is encountered. (Note that rmlig, delig, etc) don't actually insert whitespace; instead, they insert "|. The tacit assumption is that babel will know what to do with "|.) 0.03em appears to be appropriate for breaking up f-l ligatures if the document uses the CM or LM Roman font face. But 0.03em is too much for f-f and f-i ligature boundaries if CM/LM Roman is in use, and it's not appropriate either if CM/LM italic or sans-serif font faces are used. – Mico Mar 09 '18 at 08:55
  • 1
    your edited question still describes your code as "switching back to the default font" but then switches to tfm fonts (so negating any settings of fontspec required by selnolig) also your "MWE without fontspec" is the same as the code in my answer and loads fontspec. – David Carlisle Mar 09 '18 at 09:02
  • @koppor - Consider Knuth's own example word, viz., shelfful. (Let's also agree that it's not correct to use an ff ligature and hence that the ligature should be suppressed.) If CM/LM Roman is used, in my opinion no extra whitespace is needed (in addition to breaking up the ligature). Hence, shelf"|ful is not as good as what selnolig does. Same for Wasserstoff"|ionen and auf"|isst. A separate problem arises if the document uses a font face with a "long-armed" f-glyph. In such cases, 0.03em is not enough to create a gap between f & l. Lots more to think about! – Mico Mar 09 '18 at 09:08
  • 1
    Regarding your most recent edit and, in particular, the final section, entitled "MWE with fontspec and switching back to lmodern manually": You mention "switch back to latin modern", but then you don't use \setmainfont{Latin Modern Roman}, \setsansfont{Latin Modern Sans}, and \setmonofont{Latin Modern Mono}. Instead, you deploy a triplet of \renewcommand directives. What are you trying to achieve by not using \set....font directives? – Mico Mar 09 '18 at 12:35
  • I just did not now the font names "Latin Modern Roman". It is so obvious, but I was trying everything else. Sometimes, the solution is so easy. Maybe, I was confused, because my on-MWE files had microtypecontext in them, which does not work at my side - see https://tex.stackexchange.com/questions/419288/microtypecontext-with-lualatex – koppor Mar 09 '18 at 12:48
  • 1
    I had completely forgotten but I just came across this answer of mine....https://tex.stackexchange.com/a/389337/1090 – David Carlisle Mar 09 '18 at 21:06

1 Answers1

3

The question is not very clear but I think you are looking for

enter image description here

\documentclass{article}
\usepackage{fontspec}
\usepackage[english]{selnolig}
\usepackage[ngerman,english]{babel}
\addto\extrasenglish{\languageshorthands{ngerman}\useshorthands{"}}
\begin{document}
workflow\\
dwarflike\\
dwarf"|like
\end{document}
David Carlisle
  • 757,742
  • Shoulcn't that give you bad boxes? – cfr Mar 09 '18 at 00:30
  • 1
    @cfr one bad box yes, I just edited and removed the spurious \\ sorry copied it from the OP's example:-) – David Carlisle Mar 09 '18 at 00:34
  • Note the different space after "darf" in the rendered output in the answer? - The space should be the same and not be different. I agree, both outputs of "dwarflike" do not have a ligature, but the spacing is still wrong. -- I restructured the question to first state how selnolig works in principle, then the issue (no fontspec) and then the MWE with fontspec but switching back to lmodern. – koppor Mar 09 '18 at 07:59
  • 1
    @koppor no your example in the question (even after several edits) is still breaking fontspec and selnolig (and most luatex features) by switching to classic tfm fonts rather than using opentype. – David Carlisle Mar 09 '18 at 08:54
  • 2
    @koppor as Mico explained the fact that there is extra space inserted by babel 's "| is expected, the code above is showing selnolig breaking ligatures with the default latin modern font which is what you asked in the question. – David Carlisle Mar 09 '18 at 09:04
  • So, it was just late yesterday evening and I had a strange system setup. In case I encounter issues again, I will raise another question. - Meanwhile, I updated the question to a) use breaklig of selnolig and b) use the T1 encoding in the "hack". Not sure, if this is the right way. – koppor Mar 09 '18 at 10:51
  • @DavidCarlisle Can I be sure that this font is as good as the cfr-lm font? (I am new to lualatex and google "cfr-lm lualatex" brought me to https://tex.stackexchange.com/q/247530/9075 - so maybe, I should pose a new question for the googlers? – koppor Mar 09 '18 at 11:17
  • 1
    @koppor with luatex you (almost) never want to use OT1 or T1 encoding, certainly you can never use those encodings with fonts loaded via fontspec, but I am repeating myself – David Carlisle Mar 09 '18 at 11:26