如何在 pdfLaTeX 上使用 Alegreya Sans 进行数学模式

如何在 pdfLaTeX 上使用 Alegreya Sans 进行数学模式

我尝试寻找一种方法来在 pdfLaTeX 中使用 Alegreya Sans 进行数学模式。我发现可以在 XeLaTeX 中使用mathspec,但是有没有办法在 pdfLaTeX 中做到这一点?

这是因为我使用 Alegreya 处理正文,我希望数学运算与文本“同步”。如果 pdfLaTeX 无法做到这一点,我就不得不改用 XeLaTeX。

谢谢你!

答案1

您可以使用newtxsf希腊字母和mathastext

\documentclass{scrartcl}
\usepackage{newtxsf}
\usepackage[sfdefault]{AlegreyaSans}
\usepackage[italic]{mathastext}

\begin{document}

This is in Alegreya Sans, with math
$E=mc^2$ and $\sin(\alpha+\beta)=\pi$
\[
\int_{-\infty}^{\infty}e^{-x^2}\,dx=\sqrt{\pi}
\]

\boldmath Also bold math
$E=mc^2$ and $\sin(\alpha+\beta)=\pi$
\[
\int_{-\infty}^{\infty}e^{-x^2}\,dx=\sqrt{\pi}
\]

\end{document}

在此处输入图片描述

对于衬线文本和无衬线数学(但为什么?),您可以使用手册中建议的技巧mathastext

\documentclass{scrartcl}
\usepackage{newtxsf}
\usepackage{Alegreya,AlegreyaSans}

\renewcommand\familydefault\sfdefault
\usepackage[italic]{mathastext}
\renewcommand\familydefault\rmdefault

\begin{document}

This is in Alegreya Sans, with math
$E=mc^2$ and $\sin(\alpha+\beta)=\pi$
\[
\int_{-\infty}^{\infty}e^{-x^2}\,dx=\sqrt{\pi}
\]

\boldmath Also bold math
$E=mc^2$ and $\sin(\alpha+\beta)=\pi$
\[
\int_{-\infty}^{\infty}e^{-x^2}\,dx=\sqrt{\pi}
\]

\end{document}

在此处输入图片描述

答案2

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{Alegreya,AlegreyaSans}
\DeclareMathAlphabet{\mathrm}  {T1}{AlegreyaSans-LF}{m}{n}
\SetMathAlphabet{\mathrm}{bold}{T1}{AlegreyaSans-LF}{b}{n}

\DeclareMathAlphabet{\mathit}  {T1}{AlegreyaSans-LF}{m}{it}
\SetMathAlphabet{\mathit}{bold}{T1}{AlegreyaSans-LF}{b}{it}

\DeclareMathAlphabet{\mathbf}  {T1}{AlegreyaSans-Bold-lf-t1}{b}{n}
\SetMathAlphabet{\mathbf}{bold}{T1}{AlegreyaSans-Bold-lf-t1}{b}{n}

\DeclareSymbolFont{operators}  {T1}{AlegreyaSans-LF}{m}{n}
\SetSymbolFont{operators}{bold}{T1}{AlegreyaSans-LF}{b}{n}
\DeclareSymbolFont{letters}    {T1}{AlegreyaSans-LF}{m}{it}
\DeclareSymbolFont{lettersA}   {OML}{zplm}{m}{it}%  for greek letters
\SetSymbolFont{letters}{normal}{T1}{AlegreyaSans-LF}{m}{it}
\SetSymbolFont{letters}{bold}  {T1}{AlegreyaSans-LF}{b}{it}

\DeclareMathSymbol{\alpha}{\mathalpha}{lettersA}{"0B}
\DeclareMathSymbol{\beta}{\mathalpha}{lettersA}{"0C}
\DeclareMathSymbol{\gamma}{\mathalpha}{lettersA}{"0D}
\DeclareMathSymbol{\delta}{\mathalpha}{lettersA}{"0E}
\DeclareMathSymbol{\epsilon}{\mathalpha}{lettersA}{"0F}
\DeclareMathSymbol{\zeta}{\mathalpha}{lettersA}{"10}
\DeclareMathSymbol{\eta}{\mathalpha}{lettersA}{"11}
\DeclareMathSymbol{\theta}{\mathalpha}{lettersA}{"12}
\DeclareMathSymbol{\iota}{\mathalpha}{lettersA}{"13}
\DeclareMathSymbol{\kappa}{\mathalpha}{lettersA}{"14}
\DeclareMathSymbol{\lambda}{\mathalpha}{lettersA}{"15}
\DeclareMathSymbol{\mu}{\mathalpha}{lettersA}{"16}
\DeclareMathSymbol{\nu}{\mathalpha}{lettersA}{"17}
\DeclareMathSymbol{\xi}{\mathalpha}{lettersA}{"18}
\DeclareMathSymbol{\pi}{\mathalpha}{lettersA}{"19}
\DeclareMathSymbol{\rho}{\mathalpha}{lettersA}{"1A}
\DeclareMathSymbol{\sigma}{\mathalpha}{lettersA}{"1B}
\DeclareMathSymbol{\tau}{\mathalpha}{lettersA}{"1C}
\DeclareMathSymbol{\upsilon}{\mathalpha}{lettersA}{"1D}
\DeclareMathSymbol{\phi}{\mathalpha}{lettersA}{"1E}
\DeclareMathSymbol{\chi}{\mathalpha}{lettersA}{"1F}
\DeclareMathSymbol{\psi}{\mathalpha}{lettersA}{"20}
\DeclareMathSymbol{\omega}{\mathalpha}{lettersA}{"21}
\DeclareMathSymbol{\varepsilon}{\mathalpha}{lettersA}{"22}
\DeclareMathSymbol{\vartheta}{\mathalpha}{lettersA}{"23}
\DeclareMathSymbol{\varpi}{\mathalpha}{lettersA}{"24}
\DeclareMathSymbol{\varrho}{\mathalpha}{lettersA}{"25}
\DeclareMathSymbol{\varsigma}{\mathalpha}{lettersA}{"26}
\DeclareMathSymbol{\varphi}{\mathalpha}{lettersA}{"27}
\DeclareMathSymbol{\ldotp}{\mathpunct}{lettersA}{"3A}

\begin{document}\sffamily
 sin(x) $E=mc^2$ $\mathit{E=mc^2}$ \itshape E=mc$^2 \sin(x) \alpha\beta$

\upshape\boldmath
 sin(x) $E=mc^2$ $\mathit{E=mc^2}$ \itshape\bfseries E=mc$^2 \sin(x) \alpha \beta$ 

\end{document}

在此处输入图片描述

相关内容