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.

4
  • 2
    Package inputenc is only needed for pdflatex if you use an old encoding, like latin1. `utf8' is the default.
    – user187802
    Commented Sep 26, 2022 at 19:59
  • @Teepeemm Some of it is useful to me but I still would like to know exactly how my setup for packages and fonts should be. Commented Sep 26, 2022 at 19:59
  • 1
    This asks different questions to the marked duplicate. Commented Nov 17, 2022 at 8:43
  • @AndrewSwann Thank you, Andrew! I thought so too. Commented Nov 17, 2022 at 8:54

2 Answers 2

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

13
  • How do I remove all ligatures? Is what I've added at the bottom of the question correct? Commented Sep 26, 2022 at 20:38
  • 1
    Is there a reason why you used RawFeature instead of `FakeBold=2? Commented Sep 26, 2022 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
    Commented Sep 26, 2022 at 21:11
  • 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
    Commented Sep 27, 2022 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
    Commented Sep 27, 2022 at 16:53
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .