Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a follow-up question to Currency symbol: French franc.

Consider the following code:

\documentclass{article}
\usepackage{fontspec}
\usepackage{siunitx}

\DeclareRobustCommand*{\myfranc}{%
  \begingroup
    \fontspec{FreeSerif.otf}%
    ^^^^20a3%
  \endgroup
}
\DeclareSIUnit{\franc}{\myfranc}

\begin{document}
Horse fififif \SI{123.45}{\franc}.
\end{document}

How do I remove the fi ligature to get a seperate f and i instead?

Update

A setup that works for me is the following:

\documentclass{article}

\usepackage{siunitx}
\DeclareRobustCommand*{\myfranc}{%
  \begingroup
    \fontspec{FreeSerif.otf}%
    ^^^^20a3%
  \endgroup
}
\DeclareSIUnit{\franc}{\myfranc}

\usepackage{fontspec}
\defaultfontfeatures{
  Ligatures={
    NoCommon,
    NoRequired,
    NoContextual,
    NoHistoric,
    NoDiscretionary,
    TeX
  }
}
\setmainfont[
  BoldFont=lmroman10-bold.otf,
  ItalicFont=lmroman10-italic.otf,
  BoldItalicFont=lmroman10-bolditalic.otf,
  SlantedFont=lmromanslant10-regular.otf,
  BoldSlantedFont=lmromanslant10-bold.otf,
  SmallCapsFont=lmromancaps10-regular.otf
]{lmroman10-regular.otf}

\begin{document}
\section{Horse}
off fit fly office baffle -- \SI{123.456}{\franc}
\end{document}
share|improve this question
4  
Do you want to suppress (i) just the fi ligature, (ii) all f-ligatures, or (iii) all typographic ligatures entirely? To suppress all so-called "Common" ligatures (generally f-ligatures), you could issue the command \defaultfontfeatures{Ligatures=NoCommon} after loading fontspec. –  Mico Mar 19 '13 at 12:54
    
For one off, the TeX book way would be f\/i. –  Andrew Swann Mar 19 '13 at 12:56
    
@Mico: All typographic ligatures entirely. –  Svend Tveskæg Mar 19 '13 at 12:56
    
Just saw your edit: Are you sure you want to enable Discretionary ligatures? For Latin Modern fonts, it of course doesn't matter since this font family provides only Common ligatures... –  Mico Mar 19 '13 at 14:28
    
That was just to get the -- ligature (so I didn't want all ligatures removed, anyway). What is the way to get the -- and --- ligatures and no one else? –  Svend Tveskæg Mar 19 '13 at 14:35
show 2 more comments

2 Answers

up vote 5 down vote accepted

To suppress all typographic ligatures, you could issue the command

\defaultfontfeatures{Ligatures={NoCommon, NoDiscretionary, NoHistoric, NoRequired, NoContextual}}

after loading the fontspec package. This directive will apply to all fonts selected subsequently in your document.

Comments:

  • By far the most important option in the directive above is NoCommon. The so-called f-ligatures (ff, fi, fl, ffi, ffl, and possibly other f-ligatures as well) are generally assigned to the "Common" group.
  • "Required" and "Contextual" are the defaults. However, virtually all OpenType fonts I'm familiar with do not feature any "Required" or "Contextual" ligatures. Thus, it's probably not necessary to specify "NoRequired" and "NoContextual", unless you use some kind of special font.
  • "NoHistoric" and "NoDiscretionary" are the fontspec defaults. However, it doesn't hurt to specify these options explicitly to make your intentions clear, right? :-)

Addendum: Here's an MWE that illustrates the use of the \defaultfontfeatures command when used with XeLaTeX:

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures={NoCommon, NoRequired, NoContextual, NoHistoric, NoDiscretionary}}
\setmainfont{Latin Modern Roman}
  % If your TeX distribution/Operating System doesn't recognize "logical" font names
  % such as "Latin Modern Roman", try using the name of the file that contains the 
  % font you're trying to load. In this case, try "\setmainfont{lmroman10-regular.otf}".

\begin{document}
off fit fly office baffle 
\end{document}

enter image description here

share|improve this answer
    
This still results in ligatures for me. Could you post a MEW, please? (P.S. I use xelatex.) –  Svend Tveskæg Mar 19 '13 at 13:11
1  
@SvendMortensen If you don't specify a font with \setmainfont the default (with ligatures enabled) will be used. As Mico says, the \defaultfontfeatures declarations are applied to subsequently loaded fonts. –  egreg Mar 19 '13 at 13:19
    
@SvendMortensen - Please see the MWE I've added per your request. –  Mico Mar 19 '13 at 13:21
    
@Mico I don't really understand this. When I compile, I get the folllowing error: Invalid fontname 'Latin Modern Roman', contains ' ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! fontspec error: "font-not-found" ! ! The font "Latin Modern Roman" cannot be found. ! ! See the fontspec documentation for further information. ! ! For immediate help type H <return>. !............................................... l.4 \setmainfont{Latin Modern Roman} % "Latin Modern" only features "Common"... –  Svend Tveskæg Mar 19 '13 at 13:27
1  
@SvendMortensen -- Which TeX distribution and which operating system do you use? (I happen to use MacTeX2012 running under MacOSX 10.7.5., and my XeTeX version is labeled 3.1415926-2.4-0.9998, dated 2013.02.28.) Could you check if the MWE works on your system if you replace \setmainfont{Latin Modern Roman} with \setmainfont{lmroman10-regular.otf}, i.e., if you replace the font's logical name with the name of the file that contains the font? –  Mico Mar 19 '13 at 13:31
show 2 more comments
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=NoCommon]{lmroman10-regular.otf}
\newfontface\Franc{FreeSerif.otf}
\usepackage{siunitx}

\DeclareSIUnit{\kroner}{kr.}
\DeclareRobustCommand*{\myfranc}{{\Franc^^^^20a3}}
\DeclareSIUnit{\franc}{\myfranc}

\begin{document}
Horse fififif \SI{123.45}{\franc}.
\end{document}

btw: define a font face instead of running \fontspec

share|improve this answer
    
What do you mean by "running \fontspec"? –  Svend Tveskæg Mar 19 '13 at 13:10
    
sorry, I meant using \fontspec –  Herbert Mar 19 '13 at 14:17
    
I see. :) Thank you. –  Svend Tveskæg Mar 19 '13 at 14:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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