在 pdflatex 中使用 XCharter 匹配文本和数学希腊字体

在 pdflatex 中使用 XCharter 匹配文本和数学希腊字体

我想将 XCharter 字体与 pdflatex 结合使用,并使文本中的希腊字体与数学中的希腊字体相匹配。我发现,但找不到合适的字体。也许还有其他方法。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{XCharter}
\usepackage[charter,scaled=1.07]{newtxmath}
\usepackage[T1]{fontenc}
\usepackage[greek, english]{babel}

% From: https://tex.stackexchange.com/questions/106790/
\usepackage{xpatch}
\xpatchcmd{\greektext}
  {\selectfont}
  {\fontfamily{artemisia}\selectfont}% Maybe change this?
  {}{}

\begin{document}
Make this \textit{\textgreek{αβγδ}} the same font
as this $\alpha\beta\gamma\delta$.
\end{document}

答案1

您可以重新定义希腊字母与字体的关联。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[greek, english]{babel}

% fix a bad bug in XCharter
\let\LGRtextnu\textnu
\usepackage{XCharter}
% fix a bad bug in XCharter
\let\textnu\LGRtextnu
\usepackage[charter,scaled=1.07]{newtxmath}
\usepackage{substitutefont}
\substitutefont{LGR}{\rmdefault}{artemisia}

\DeclareSymbolFont{greekletters}{LGR}{artemisia}{m}{it}
\SetSymbolFont{greekletters}{bold}{LGR}{artemisia}{b}{it}
\DeclareSymbolFont{ucgreekletters}{LGR}{artemisia}{m}{n}
\SetSymbolFont{ucgreekletters}{bold}{LGR}{artemisia}{b}{n}
\DeclareMathSymbol{\alpha}{\mathord}{greekletters}{`a}
\DeclareMathSymbol{\beta}{\mathord}{greekletters}{`b}
\DeclareMathSymbol{\gamma}{\mathord}{greekletters}{`g}
\DeclareMathSymbol{\delta}{\mathord}{greekletters}{`d}
\DeclareMathSymbol{\epsilon}{\mathord}{greekletters}{`e}
\DeclareMathSymbol{\zeta}{\mathord}{greekletters}{`z}
\DeclareMathSymbol{\eta}{\mathord}{greekletters}{`h}
\DeclareMathSymbol{\theta}{\mathord}{greekletters}{`j}
\DeclareMathSymbol{\iota}{\mathord}{greekletters}{`i}
\DeclareMathSymbol{\kappa}{\mathord}{greekletters}{`k}
\DeclareMathSymbol{\lambda}{\mathord}{greekletters}{`l}
\DeclareMathSymbol{\mu}{\mathord}{greekletters}{`m}
\DeclareMathSymbol{\nu}{\mathord}{greekletters}{`n}
\DeclareMathSymbol{\omicron}{\mathord}{greekletters}{`o}
\DeclareMathSymbol{\xi}{\mathord}{greekletters}{`x}
\DeclareMathSymbol{\pi}{\mathord}{greekletters}{`p}
\DeclareMathSymbol{\rho}{\mathord}{greekletters}{`r}
\DeclareMathSymbol{\sigma}{\mathord}{greekletters}{`s}
\DeclareMathSymbol{\tau}{\mathord}{greekletters}{`t}
\DeclareMathSymbol{\upsilon}{\mathord}{greekletters}{`u}
\DeclareMathSymbol{\phi}{\mathord}{greekletters}{`f}
\DeclareMathSymbol{\chi}{\mathord}{greekletters}{`q}
\DeclareMathSymbol{\psi}{\mathord}{greekletters}{`y}
\DeclareMathSymbol{\omega}{\mathord}{greekletters}{`w}
\DeclareMathSymbol{\varepsilon}{\mathord}{greekletters}{`e}
\DeclareMathSymbol{\vartheta}{\mathord}{greekletters}{`j}
\DeclareMathSymbol{\varpi}{\mathord}{greekletters}{`p}
\DeclareMathSymbol{\varrho}{\mathord}{greekletters}{`r}
\DeclareMathSymbol{\varsigma}{\mathord}{greekletters}{`v}
\DeclareMathSymbol{\varphi}{\mathord}{greekletters}{`f}
\DeclareMathSymbol{\Alpha}{\mathord}{ucgreekletters}{`A}
\DeclareMathSymbol{\Beta}{\mathord}{ucgreekletters}{`B}
\DeclareMathSymbol{\Gamma}{\mathord}{ucgreekletters}{`G}
\DeclareMathSymbol{\Delta}{\mathord}{ucgreekletters}{`D}
\DeclareMathSymbol{\Epsilon}{\mathord}{ucgreekletters}{`E}
\DeclareMathSymbol{\Zeta}{\mathord}{ucgreekletters}{`Z}
\DeclareMathSymbol{\Eta}{\mathord}{ucgreekletters}{`H}
\DeclareMathSymbol{\Theta}{\mathord}{ucgreekletters}{`J}
\DeclareMathSymbol{\Iota}{\mathord}{ucgreekletters}{`I}
\DeclareMathSymbol{\Kappa}{\mathord}{ucgreekletters}{`K}
\DeclareMathSymbol{\Lambda}{\mathord}{ucgreekletters}{`L}
\DeclareMathSymbol{\Mu}{\mathord}{ucgreekletters}{`M}
\DeclareMathSymbol{\Nu}{\mathord}{ucgreekletters}{`N}
\DeclareMathSymbol{\Xi}{\mathord}{ucgreekletters}{`X}
\DeclareMathSymbol{\Omicron}{\mathord}{ucgreekletters}{`O}
\DeclareMathSymbol{\Pi}{\mathord}{ucgreekletters}{`P}
\DeclareMathSymbol{\Rho}{\mathord}{ucgreekletters}{`R}
\DeclareMathSymbol{\Sigma}{\mathord}{ucgreekletters}{`S}
\DeclareMathSymbol{\Tau}{\mathord}{ucgreekletters}{`T}
\DeclareMathSymbol{\Upsilon}{\mathord}{ucgreekletters}{`U}
\DeclareMathSymbol{\Phi}{\mathord}{ucgreekletters}{`F}
\DeclareMathSymbol{\Chi}{\mathord}{ucgreekletters}{`Q}
\DeclareMathSymbol{\Psi}{\mathord}{ucgreekletters}{`Y}
\DeclareMathSymbol{\Omega}{\mathord}{ucgreekletters}{`W}


\begin{document}

Make this \textit{\textgreek{αβγδ}} the same font
as this $\alpha\beta\gamma\delta$.

\textit{\textgreek{αβγδεζηθικλμνξοπρστυφχψω}}

$\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda
\mu\nu\xi\omicron\pi\rho\sigma\tau\upsilon\phi\chi\psi\omega$

\textgreek{ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ}

$\Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta\Iota\Kappa\Lambda
\Mu\Nu\Xi\Omicron\Pi\Rho\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega$

\end{document}

“修复 中的严重错误XCharter”是必要的,因为该包重新定义了\textnu,从而破坏了对希腊语的支持。

在此处输入图片描述

相关内容