5

Code

Consider the following MWE:

\documentclass{article}

\usepackage{inputenc} \usepackage[T1]{fontenc} \usepackage{babel} \usepackage[sc]{mathpazo} \usepackage{microtype} \DisableLigatures[f]{encoding = T1} \usepackage{hyperref} % Used in alot of my documents.

\begin{document} Test. \end{document}

Assume I compile using pdflatex (with an up-to-date TeX Live distribution), I then use the setup above.

Questions

I have a few questions:

  1. Is \usepackage{inputenc} needed at all when compiling using pdflatex?
  2. When kind of packages should I load and how do I setup the font properly if I want to compile using lualatex?

Is the following correct and if not, how do I do it in a correct way?

\documentclass{article}

\usepackage{polyglossia} \setdefaultlanguage{danish} \usepackage{fontspec} \defaultfontfeatures{Ligatures = TeX} \usepackage{mathpazo} \setmainfont[ BoldFont = texgyrepagella-bold.otf, ItalicFont = texgyrepagella-italic.otf, BoldItalicFont = texgyrepagella-bolditalic.otf ]{texgyrepagella-regular.otf} \usepackage{hyperref} % Used in alot of my documents.

\begin{document} Test. \end{document}

Also, is the loading-order of the packages of any importance? (I know that hyperref should almost always be loaded as the last package but apart from that?)

Update

In case I want to remove all ligatures, is the following then the correct way to do it?

\addfontfeature{
  Ligatures = {
    RequiredOff,
    CommonOff,
    ContextualOff,
    RareOff,
    HistoricOff,
    TeXOff
  }
}

instead of

\defaultfontfeatures{Ligatures = TeX}

I found it in Table 11 at the bottom of page 42 of the fontspec manual.

2 Answers2

5

Use the OpenType math font and not package mathpazo:

\documentclass{standalone}

\usepackage{polyglossia} \setdefaultlanguage{danish} \usepackage[math-style=TeX]{unicode-math} \setmainfont[ Extension = .otf, UprightFont = -regular, BoldFont = -bold, ItalicFont = -italic, BoldItalicFont = -bolditalic, Ligatures = {CommonOff,TeXOff}% no ligatures ]{texgyrepagella}

\setmathfont{texgyrepagella-math.otf} \setmathfont{texgyrepagella-math.otf}[version=bold,RawFeature={embolden=2}]

\usepackage{hyperref} % Used in alot of my documents.

\begin{document} Test. -- --- ff fl fi $y=f(x)$ \boldmath $y=\int_1^2f(x)\symup{d}x$ \end{document}

enter image description here

user187802
  • 16,850
  • How do I remove all ligatures? Is what I've added at the bottom of the question correct? – Svend Tveskæg Sep 26 '22 at 20:38
  • 1
    Is there a reason why you used RawFeature instead of `FakeBold=2? – Marcel Krüger Sep 26 '22 at 20:41
  • 2
    @SvendTveskæg - \defaultfontfeatures{Ligatures = TeX,NoCommon}. All other ligature features are not enabled by default. The "TeX" ligatures (e.g., en-dashes and em-dashes) would not be considered to be real ligatures by most folk outside the TeX world. But if you don't want to enable the creation of en- and em-dashes by typing -- and ---, respectively, then by all means run \defaultfontfeatures{Ligatures = NoTeX,NoCommon}. – Mico Sep 26 '22 at 21:11
  • @Mico Thank you very much, but unfortunately NoCommon isn't valid; ! LaTeX Error: The key 'fontspec-opentype/NoCommon' is unknown and is being ignored.. Should it be \addfontfeature{Ligatures = TeX, NoCommon}, i.e. \addfontfeature instead of \defaultfontfeatures? – Svend Tveskæg Sep 26 '22 at 22:20
  • @MarcelKrüger: No, there was no reason ... – user187802 Sep 27 '22 at 06:26
  • @SvendTveskæg: See edited answer for no ligatures – user187802 Sep 27 '22 at 06:37
  • @SvendTveskæg - My bad. I omitted a pair of curly braces. \defaultfontfeatures{Ligatures = {TeX,NoCommon}} works as expected. – Mico Sep 27 '22 at 06:43
  • @Mico When I use your suggestion on one of my 'real' documents, I get the warning Package fontspec Warning: OpenType feature 'Ligatures=TeX,CommonOff' (liga) not available for font 'texgyrepagella-math' with script 'Math' and language 'Default'.. However, if I use \addfontfeature{Ligatures = {TeX, CommonOff}} I get no warnings. – Svend Tveskæg Sep 27 '22 at 15:41
  • @SvendTveskæg: a math font has no special ligatures. – user187802 Sep 27 '22 at 15:47
  • @user187802 I see! Is it then correct to add Ligatures = {TeX,CommonOff} as an option to \setmainfont (almost what you already did)? – Svend Tveskæg Sep 27 '22 at 15:49
  • 1
    @SvendTveskæg: Don't use the Ligature option for math! With my code you do not get a warning. And yes you can add it to \setmainfont – user187802 Sep 27 '22 at 15:53
  • 1
    @SvendTveskæg - For the record: Earlier today, I recommended writing Ligatures = {TeX,NoCommon}, not Ligatures=TeX,CommonOff. If nothing else, you would appear to be missing a pair of curly braces. – Mico Sep 27 '22 at 16:53
  • @Mico Thanks for the reminder regarding the barces. I used CommonOff because that's given in the manual. :-) – Svend Tveskæg Sep 27 '22 at 18:36
4

I would suggest the following changes: use fontspec with suitable OpenType font (TeXGyre Pagella mimics Palatino fairly well), and use unicode-math with suitable math font (again, TeXGyre Pagella Math works fine, IMO it looks better than mathpazo, which borrows some glyphs from Computer Modern, and they look different from Palatino). You don't have to drop babel, it works fine. Also, LuaLaTeX have a very nice font search engine, so in most cases it's sufficient to use the human readable font family name in order to find it.

Also, when using one font will become boring, you could find many unicode-math compatible math fonts in this nice question: Which OpenType Math fonts are available?

An example:

\documentclass{article}

\usepackage{babel} \usepackage{microtype} \usepackage{fontspec} \defaultfontfeatures{Ligatures={TeX,NoCommon}} \setmainfont{TeXGyre Pagella} \usepackage{unicode-math} \setmathfont{TeXGyre Pagella Math}

\usepackage{hyperref} % Used in alot of my documents.

\begin{document} Test. Difficult \emph{test}. Some math --- [ \int_{-\infty}^\infty e^{-x^2}dx = \sqrt{\pi}. ] \end{document}

The result:

enter image description here