如何在 XeLaTeX 中使用旧式数字

如何在 XeLaTeX 中使用旧式数字

我希望使用旧式数字,并且我可以使用以下代码通过 PDFLaTeX 轻松实现此目的:

\documentclass[a4paper,10pt]{article}
\usepackage[osf]{mathpazo}
\begin{document}
1234567890
\end{document}

输出:

pdflatex test.tex 
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/mathpazo.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./test.aux) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pplj.fd)
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux) ){/usr/shar
e/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc}</usr/share/texlive/texmf-dist
/fonts/type1/public/fpl/fplrc8a.pfb>
Output written on test.pdf (1 page, 13241 bytes).
Transcript written on test.log.

但是,如果我使用 XeLaTeX 进行编译,虽然编译成功,但会给出警告,并且不会生成我想要的旧式图形。这是我从 XeLaTeX 获得的输出:

xelatex test.tex 
This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/mathpazo.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def)
(./test.aux) (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)

LaTeX Font Warning: Font shape `TU/pplj/m/n' undefined
(Font)              using `TU/lmr/m/n' instead on input line 4.

[1] (./test.aux)

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

 )
Output written on test.pdf (1 page).
Transcript written on test.log.

答案1

\documentclass[a4paper,10pt]{article}
\usepackage{unicode-math}
\setmainfont[Numbers=OldStyle]{TeXGyre Pagella}
\setmathfont{texgyrepagella-math}[AutoFakeBold]
\begin{document}
    1234567890
\end{document}

答案2

这个mathpazo软件包相当老旧了。它已经好几年没有更新了,因此它在 XeLaTeX 或 LuaLaTeX 下都不太好用也就不足为奇了。

幸运的是,更新、维护得更好的newpxtext 和 newpxmath字体包提供了 Palatino 克隆文本和数学字体,它们可以在 pdfLaTeX、XeLaTeX 和 LuaLaTeX 下同样使用。也就是说,以下代码在这三个引擎下产生完全相同的输出。

在此处输入图片描述

\documentclass{article} % or some other suitable document class
\usepackage{iftex}      % test which TeX engine is in use
\iftutex % 'true' if either XeTeX or LuaTeX is in use
  \usepackage[no-math]{fontspec}
\fi
\usepackage[osf]{newpxtext} % oldstyle numerals as default in text mode
\usepackage{newpxmath}

\begin{document}
Hello 123 \liningnums{123} $123 \sum\int\prod \displaystyle \sum\int\prod$ 
\end{document}

相关内容