![如何将 MathJax Optentype 字体与 XeLaTeX 一起使用?](https://linux22.com/image/393888/%E5%A6%82%E4%BD%95%E5%B0%86%20MathJax%20Optentype%20%E5%AD%97%E4%BD%93%E4%B8%8E%20XeLaTeX%20%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8%EF%BC%9F.png)
我想MathJax
在文档中使用 opentype 文本和数学字体。以下所有字体都可以从以下网址下载MathJax GitHub 页面。
MathJax_AMS-Regular.otf MathJax_SansSerif-Bold.otf
MathJax_Caligraphic-Bold.otf MathJax_SansSerif-Italic.otf
MathJax_Caligraphic-Regular.otf MathJax_SansSerif-Regular.otf
MathJax_Fraktur-Bold.otf MathJax_Script-Regular.otf
MathJax_Fraktur-Regular.otf MathJax_Size1-Regular.otf
MathJax_Main-Bold.otf MathJax_Size2-Regular.otf
MathJax_Main-Italic.otf MathJax_Size3-Regular.otf
MathJax_Main-Regular.otf MathJax_Size4-Regular.otf
MathJax_Math-BoldItalic.otf MathJax_Typewriter-Regular.otf
MathJax_Math-Italic.otf MathJax_WinChrome-Regular.otf
MathJax_Math-Regular.otf MathJax_WinIE6-Regular.otf
对于文本,我能够让事情正常运作,但对于数学来说,这太棘手了。我试过了,mathspec
但unicode-math
没有成功。我以前成功地将 XeLaTeX 与其他数学字体一起使用,但它无法与此字体正常工作。有些人走得更远,成功地使用 pdfLaTeX 编译 MathJax 字体并获得了很棒的结果。我只需使用 XeLaTeX 就可以了。
这是我的尝试,但输出不令人满意:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{mathspec}
\setmainfont{MathJax_Main-Regular.otf}[
UprightFont = MathJax_Main-Regular,
ItalicFont = MathJax_Main-Italic,
BoldFont = MathJax_Main-Bold
]
\setmathrm{MathJax_Main-Regular.otf} % for sin cos ln max ..
\setmathsfont(Digits){MathJax_Main-Regular.otf}
\setmathsfont(Latin,Greek){MathJax_Math-Italic.otf}
\setboldmathrm{MathJax_Math-BoldItalic.otf}
\usepackage{bm}
\begin{document}
\section{Mathjax fonts}
\subsection{Main fonts}
Roman: `The quick brown fox jumps over the lazy dog.' 0123456789\\
Italic: \textit{`The quick brown fox jumps over the lazy dog.' 0123456789}\\
Bold: \textbf{`The quick brown fox jumps over the lazy dog.' 0123456789}
\subsection{Math}
Numbers: $123,456.7890$\\
Alphabet: $abcdefghijklmnopqrstuvwxyz$ $ABCDEFGHIJKLMNOPQRSTUVWXYZ$\\
Calligraphic: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
Accents: $\hat f \vec f \ddot f \dot f \bar f\check f \tilde f \acute f \grave f \breve f$\\
Greek: $\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \iota \kappa \lambda \mu \nu \xi \pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega$
$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$\\
Operators: $\cos\theta$, $\ln x$, $a \bmod n$, etc.\\
Big operators:
\[ f(x) = \sum_{n = -\infty}^\infty c_{n}e^{jnx} \]
\[ c_{n} = \frac{1}{2}\int_{-\pi}^{\pi}f(x)e^{-jnx}\,\mathrm dx \]
%
Bold italic: $\bm{abcdefghijklmnopqrstuvwxyz}$\\
Bold rm: $\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
Bold italic: $\bm{\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \iota \kappa \lambda \mu \nu \xi \pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega}$
\end{document}
答案1
字体缺少数学表和数学脚本。
您可以使用字母,但不能使用符号和重音符号,
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{MathJax_Main}[
Extension=.otf,
Path=./MathJax-otf/,
UprightFont=*-Regular,
ItalicFont=*-Italic,
BoldFont=*-Bold,
]
\setmathfont{Latin Modern Math} % base
\setmathfont{MathJax_Math-Regular}[
Extension=.otf,
Path=./MathJax-otf/,
range={
up,it,bb,bbit,scr,cal,bfcal,frak,tt,sfup,sfit,bfup,bfit,bfscr,bffrak,bfsfup,bfsfit,
},
]
\setmathfont{MathJax_Main-Regular}[
Extension=.otf,
Path=./MathJax-otf/,
range=up/num,
]
\begin{document}
Numbers: $123,456.7890$\\
Alphabet: $abcdefghijklmnopqrstuvwxyz$ $ABCDEFGHIJKLMNOPQRSTUVWXYZ$\\
Calligraphic: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
Accents: $\hat{a} \vec{a} \ddot{a} \dot{a} \bar{a}\check{a} \tilde{a} \acute{a} \grave{a} \breve{a}$\\
Greek: $\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \iota \kappa \lambda \mu \nu \xi \pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega$
$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$\\
Operators: $\cos\theta$, $\ln x$, $a \bmod n$, etc.\\
Big operators:
\[ f(x) = \sum_{n = -\infty}^\infty c_{n}e^{jnx} \]
\[ c_{n} = \frac{1}{2}\int_{-\pi}^{\pi}f(x)e^{-jnx}\,\mathrm dx \]
%
Bold italic: $\symbfit{abcdefghijklmnopqrstuvwxyz}$\\
Bold rm: $\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
Bold italic: $\symbfit{\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \iota \kappa \lambda \mu \nu \xi \pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega}$
\showoutput
\end{document}
如果您检查日志文件,您会发现符号和重音来自拉丁现代数学,但所有字母都来自 MathJax_Math-Regular。