
我希望能夠使用自訂 TTF(News Gothic)作為整個文件中出現文字的主要字體,並使用 CMU Bright 來表示數學。但\text
裡面的數學模式應該要用New Gothic。然而,嘗試使用 News Gothic 作為主要字體會取消 CMU 作為數學字體的設置,您可以在下圖中看到 sin
它 - 用 News Gothic 編寫,就像Computer Modern 中的ABC
、x
和e^{-x}
are 而不是 CMU Bright 一樣。
這是一個範例文件。它是用 xelatex 編譯的,儘管僅使用 luatex 的解決方案也可以;我不認為 pdflatex 可以處理這樣的字體,但我希望是錯的。任何有效的解決方案都是可以接受的。
\documentclass{article}
\usepackage{mathtools}
\usepackage{fontspec,unicode-math}
\usepackage{cmbright}
\usepackage[T1]{fontenc}
\setmainfont[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
BoldFont = News Gothic MT Bold,
ItalicFont = News Gothic MT Italic,
BoldItalicFont = News Gothic MT Bold Italic
]
{News Gothic MT}
\setsansfont[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
BoldFont = News Gothic MT Bold,
ItalicFont = News Gothic MT Italic,
BoldItalicFont = News Gothic MT Bold Italic
]
{News Gothic MT}
\begin{document}
\begin{center}
This is math:
\begin{align*}
\int_{-\infty}^\infty \frac{\sin(x)e^{-x}}{x}\quad\textbf{\textit{ABC}}
\end{align*}
\end{center}
\end{document}
結果:
如果我刪除\setmainfont
,那麼sin
也會變成電腦現代。如果我刪除\setsansfont
,則正文字體 和ABC
都變為 CMU Bright (但sin
仍保留 News Gothic)。但我無法弄清楚將導致的組合:
- 正文字體 = News Gothic
sin
= News Gothic(這是可選的;CMU Bright 也可以)\text
數學模式=新聞哥德式- 數學模式下的數字、變數等 = CMU Bright
答案1
您想使用舊版數學字體,因此不要載入unicode-math
.當然,不要fontenc
使用 T1 編碼載入。
\documentclass{article}
\usepackage{mathtools}
\usepackage{fontspec}
\usepackage{cmbright}
%\usepackage[T1]{fontenc}% <--- don't
\setmainfont{News Gothic MT}[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
ItalicFont = * Italic,
BoldFont = * Bold,
BoldItalicFont = * Bold Italic,
]
\setsansfont{News Gothic MT}[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
ItalicFont = * Italic,
BoldFont = * Bold,
BoldItalicFont = * Bold Italic,
]
\begin{document}
This is math:
\begin{equation*}
\int_{-\infty}^\infty \frac{\sin(x)e^{-x}}{x}\quad\textbf{\textit{ABC}}+123
\end{equation*}
\end{document}
人們可以在 News Gothic 中得到操作員的名字,但序言略有不同:
\documentclass{article}
\usepackage{mathtools}
\usepackage{fontspec}
\usepackage{cmbright}
\setmainfont{News Gothic MT}[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
ItalicFont = * Italic,
BoldFont = * Bold,
BoldItalicFont = * Bold Italic,
NFSSFamily = ngmt,
]
\setsansfont{News Gothic MT}[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
ItalicFont = * Italic,
BoldFont = * Bold,
BoldItalicFont = * Bold Italic,
]
\DeclareSymbolFont{operators}{TU}{ngmt}{m}{n}
\SetSymbolFont{operators}{bold}{TU}{ngmt}{b}{n}
\DeclareSymbolFont{cmbroperators}{OT1}{cmbr}{m}{n}
\makeatletter
\AtBeginDocument{\DeclareMathSymbol{\std@equal}{\mathrel}{cmbroperators}{`=}}
\makeatother
\begin{document}
\show\Relbar
This is math:
\begin{equation*}
\int_{-\infty}^\infty \frac{\sin(x)e^{-x}}{x}\quad\textbf{\textit{ABC}}+123
\end{equation*}
$\Longrightarrow\longrightarrow$
\end{document}