
我需要更改文檔中的字體大小。問題是,無論我嘗試什麼方法,與文字模式相比,內聯數學中的字元都會被拉伸(變寬),這看起來很糟糕(並且浪費了頁面空間)。我怎樣才能解決這個問題?
這是一個 MWE:
\documentclass{scrbook}
\usepackage{unicode-math}
\begin{document}
Same character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 $\par
\KOMAoptions{fontsize=10}
% or other change in size like \footnotesize \LARGE etc
Different character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 $\par
\end{document}
答案1
您可以強制 unicode-math 使用普通的拉丁現代文字字體來表示數字:
\documentclass{scrbook}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range={"0030-"0039}]{Latin Modern Roman}
\setmathfont[range=\int]{Latin Modern Math} %last font should be a math font
\begin{document}
Same character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 $\par
\KOMAoptions{fontsize=10}
Different character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 x^3$\par
\end{document}
編輯
實際上 range 指令不是必需的。只需像egreg在他的答案中那樣設置數學字體就可以在現代tex系統中解決我的問題:
\documentclass{scrbook}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\begin{document}
Same character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 $\par
\KOMAoptions{fontsize=10}
Different character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 x^3$\par
\end{document}
編輯2
經過更仔細的觀察(並測試其他字體大小)後,我發現了問題的根源:unicode-math 正在使用不同的「數學樣式」來設定數學。較小的字體大小使用例如+ssty=0;
,這會導致更寬的數字(這是一個功能,而不是錯誤。更寬的字元在小尺寸下更容易閱讀)。
因此,如果更改整體字體大小,則必須再次設定數學字體:
\documentclass[fontsize=11pt]{scrbook}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\begin{document}
Same character width:\\
123456789012345678901234567890 abc\\
$ 123456789012345678901234567890 abc$
\KOMAoptions{fontsize=9}
\setmathfont{Latin Modern Math}
Different character width:\\
123456789012345678901234567890 abc\\
$ 123456789012345678901234567890 abc$
\end{document}
對於拉丁現代字體,文字字體具有光學尺寸,但仍存在差異。
答案2
您只需指定數學字體即可。為什麼會發生這種情況可能是個錯誤unicode-math
(或工作原理的結果fontsize=10
)。
\documentclass{scrbook}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\begin{document}
Same character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 $\par
\KOMAoptions{fontsize=10}
% or other change in size like \footnotesize \LARGE etc
Different character width:\\
123456789012345678901234567890\\
$ 123456789012345678901234567890 $\par
\end{document}
顯示中的微小變化是由於拉丁現代數學字體中的一個錯誤;如果我做
\sbox0{78}\showbox0
\sbox0{$78$}\showbox0
使用正常scrbook
設定(11pt),然後我得到
\hbox(7.40219+0.24089)x10.95
.\EU1/lmr/m/n/10.95 78
對於第一個盒子,當我得到
\hbox(7.40219+0.2409)x11.09236
.\mathon
.\EU1/LatinModernMath(0)/m/n/10.95 glyph#24
.\kern0.14235
.\EU1/LatinModernMath(0)/m/n/10.95 glyph#25
.\mathoff
大小差異為11.09236 - 10.95 = 0.14236
(由於二元算術差異為 1sp,不相關)。緊鄰添加到 7 到任何數字。數字之間沒有插入其他字距調整。