
我需要用 Helvetica 字體寫一個文檔,發現無數學字體成為數學方面的良好匹配對象,但我願意接受其他建議。
現在我真的很難得到無襯線直體希臘語數學模式下的字母。有什麼辦法可以實現這一點嗎?
對於襯線字體我以前使用過 上希臘文或這個很好的答案。兩者都不適用於 helvet+sansmathfonts。
\documentclass{article}
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{sansmathfonts}
\usepackage[scaled=0.95]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{upgreek}
\begin{document}
Upright greek in math mode:
$\mathrm{\mu\alpha\beta\gamma}$, $\upmu\upalpha\upbeta\upgamma$,
\end{document}
MWE 關於 Steven B. Segletes 的評論:
\documentclass{article}
\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{sansmathfonts}
\usepackage[scaled=0.95]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{tikz}
\usepackage{scalerel}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][0]{\mbox{%
\sbox{\foobox}{#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\newcommand\unslant[2][-.2]{%
\mkern1mu%
\ThisStyle{\slantbox[#1]{$\SavedStyle#2$}}%
\mkern-1mu%
}
\newcommand\upmu{\unslant\mu}
\begin{document}
Upright greek in math mode: $\mathrm{\mu}$, $\upmu$,
\begin{tikzpicture}
\node[color=red,] {$\upmu$$\mu$};
\end{tikzpicture}
\end{document}
答案1
這個答案是在對該問題的評論中進行討論後得出的,我建議讀者參考。我指出我的解決方案適合電腦現代的直立希臘字體直接用於取消字體傾斜(它基於布魯諾的回答剪切變換“盒子”)。我在那裡展示瞭如何將其應用於希臘字母形式,但指出它僅適用於 pdflates,而 OP 在序言中調用了 lualatex。
然後OP告訴我該\unslant
方法也適用於lua(halle-lua-jah),但底層在\slantbox
接受節點顏色方面有問題tikz
。這對我來說是新聞,因為\slantbox
接受顏色作為\textcolor
論證的一部分或\color
聲明之後就可以了。
然後我發現了一份 pgf 錯誤報告,https://sourceforge.net/p/pgf/bugs/362/,這似乎與問題有關。由於我自己無法解決該問題,因此我尋找解決方法。
Heiko 的回答為如何儲存目前顏色展示了一種保存當前顏色的很酷的技術\colorlet{slantcolor}{.}
(在進入 之前\mbox
,然後我只是\color{slantcolor}
在 內部重新發出了一個\foobox
。這似乎解決了問題。
回顧一下,該\unslant
方法允許現有的斜體字母以相同的字體設計直立,並且該修復允許該解決方案與彩色節點\colorlet
一起使用。tikz
整體方法適用於 pdflatex 和 lualatex。
\documentclass{article}
%\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{sansmathfonts}
\usepackage[scaled=0.95]{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{tikz}
\usepackage{scalerel}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][0]{\colorlet{slantcolor}{.}\mbox{%
\sbox{\foobox}{\color{slantcolor}#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\newcommand\unslant[2][-.2]{%
\mkern1mu%
\ThisStyle{\slantbox[#1]{$\SavedStyle#2$}}%
\mkern-1mu%
}
\newcommand\upmu{\unslant\mu}
\begin{document}
Upright greek in math mode: $\mathrm{\mu}$, $\upmu$,
\begin{tikzpicture}
\node[color=red,] {$\upmu$$\mu$};
\end{tikzpicture}
\end{document}
答案2
可以使用CB字體
\documentclass{article}
\usepackage[scaled=0.95]{helvet}
\usepackage{sansmathfonts}
\renewcommand{\familydefault}{\sfdefault}
\DeclareFontEncoding{LGR}{}{}
\DeclareSymbolFont{sfgreek}{LGR}{cmss}{m}{n}
\SetSymbolFont{sfgreek}{bold}{LGR}{cmss}{bx}{n}
\DeclareMathSymbol{\alpha}{\mathord}{sfgreek}{`a}
\DeclareMathSymbol{\beta}{\mathord}{sfgreek}{`b}
\DeclareMathSymbol{\gamma}{\mathord}{sfgreek}{`g}
\DeclareMathSymbol{\delta}{\mathord}{sfgreek}{`d}
\DeclareMathSymbol{\epsilon}{\mathord}{sfgreek}{`e}
\DeclareMathSymbol{\zeta}{\mathord}{sfgreek}{`z}
\DeclareMathSymbol{\eta}{\mathord}{sfgreek}{`h}
\DeclareMathSymbol{\theta}{\mathord}{sfgreek}{`j}
\DeclareMathSymbol{\iota}{\mathord}{sfgreek}{`i}
\DeclareMathSymbol{\kappa}{\mathord}{sfgreek}{`k}
\DeclareMathSymbol{\lambda}{\mathord}{sfgreek}{`l}
\DeclareMathSymbol{\mu}{\mathord}{sfgreek}{`m}
\DeclareMathSymbol{\nu}{\mathord}{sfgreek}{`n}
\DeclareMathSymbol{\xi}{\mathord}{sfgreek}{`x}
\DeclareMathSymbol{\omicron}{\mathord}{sfgreek}{`o}
\DeclareMathSymbol{\pi}{\mathord}{sfgreek}{`p}
\DeclareMathSymbol{\rho}{\mathord}{sfgreek}{`r}
\DeclareMathSymbol{\sigma}{\mathord}{sfgreek}{`s}
\DeclareMathSymbol{\tau}{\mathord}{sfgreek}{`t}
\DeclareMathSymbol{\upsilon}{\mathord}{sfgreek}{`u}
\DeclareMathSymbol{\phi}{\mathord}{sfgreek}{`f}
\DeclareMathSymbol{\chi}{\mathord}{sfgreek}{`q}
\DeclareMathSymbol{\psi}{\mathord}{sfgreek}{`y}
\DeclareMathSymbol{\omega}{\mathord}{sfgreek}{`w}
\let\varepsilon\epsilon
\let\vartheta\theta
\let\varpi\pi
\let\varrho\rho
\DeclareMathSymbol{\varsigma}{\mathord}{sfgreek}{`c}
\let\varphi\phi
\DeclareMathSymbol{\Gamma}{\mathalpha}{sfgreek}{`G}
\DeclareMathSymbol{\Delta}{\mathalpha}{sfgreek}{`D}
\DeclareMathSymbol{\Theta}{\mathalpha}{sfgreek}{`J}
\DeclareMathSymbol{\Lambda}{\mathalpha}{sfgreek}{`L}
\DeclareMathSymbol{\Xi}{\mathalpha}{sfgreek}{`X}
\DeclareMathSymbol{\Pi}{\mathalpha}{sfgreek}{`P}
\DeclareMathSymbol{\Sigma}{\mathalpha}{sfgreek}{`S}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{sfgreek}{`U}
\DeclareMathSymbol{\Phi}{\mathalpha}{sfgreek}{`F}
\DeclareMathSymbol{\Psi}{\mathalpha}{sfgreek}{`Y}
\DeclareMathSymbol{\Omega}{\mathalpha}{sfgreek}{`W}
\begin{document}
Upright greek in math mode:
$\mu\alpha\beta\gamma$
$\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda\mu$
$\nu\xi\omicron\pi\rho\sigma\varsigma\tau\upsilon\phi\chi\psi\omega$
$\mathrm{A}\mathrm{B}\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$
\end{document}