我正在嘗試編寫以下內容$T_E$
,但它以斜體顯示。我也嘗試過,$\text{T_E}$
但是 LaTeX 給了我錯誤。
答案1
答案2
以下範例說明了幾種可能的解決方案。
\documentclass{scrartcl}
\usepackage{amsmath}
\newcommand{\testline}{Text $\mathrm{T}_\mathrm{E}$ or $\text{T}_\text{E}$ or $\textup{T}_\textup{E}$ or T\textsubscript E}
\begin{document}
\testline
\itshape\testline
\sffamily\upshape\testline
\itshape\testline
\rmfamily\upshape\bfseries%as before but bold
\testline
\itshape\testline
\sffamily\upshape\testline
\itshape\testline
\end{document}
觀察其中一些採用文字的樣式和字體。
答案3
借助現代工具鏈
隨著unicode-math
包(我個人推薦,雖然不是每個人都同意),\mathrm
仍然支持向後相容性,但同義詞\mathup
和密切相關的\symup
.
如果使用,則可以指定與常規文字字體以及運算符名稱(如、和\symup
)不同的直立字體。我的首選範例是以 ISO 風格設定歐拉恆等式,即以直立字體設定符號常數,其中常數 e、π 和 i 在 Euler 中,其他所有內容在 Palatino 中。這是一個很好的例子,說明了為什麼您可能需要使用不同的直立字體來表示數學變數。log
sin
lim
\documentclass[varwidth, preview]{standalone}
\usepackage{mathtools}
\usepackage[math-style=ISO]{unicode-math}
\setmainfont{TeX Gyre Pagella}
\defaultfontfeatures{Scale=MatchLowercase}
\setmathfont{Asana Math}
\setmathfont[range={up/{Latin,latin,Greek,greek},
bfup/{Latin,latin,Greek,greek}},
script-features={}, sscript-features={}
]{Neo Euler}
\newcommand\upe{\symup{e}}
\newcommand\upi{\symup{i}}
\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}
(如果您想使用預設字體執行類似的操作,您可以嘗試 Latin Modern Roman Unslanted 或 CMU Serif Upright Italic。這是後者的範例:
\documentclass[varwidth, preview]{standalone}
\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range=up/{Latin,latin,Greek,greek}]{CMU Serif Upright Italic}
\begin{document}
\begin{align*}
\symup{e}^{\symup{i} x} &= \cos{x} + \symup{i} \sin{x} \\
\symup{e}^{\symup{i \pi}} + 1 &= 0
\end{align*}
\end{document}
該\symup
命令旨在以這種方式使用。和\mathrm
命令\mathup
更多用於方程中的單字,例如命名變數 TIME 和 ENERGY。整個單字的另一個不錯的替代方法是使用\operatorname
from amsmath
。這會將文字格式化為\log
or \sin
,即插入 2 log 之類的間距X而不是 2logx。
等寬字母和無襯線字母也有類似的\mathtt
和。\mathsfup
例如,您也可以使用\newcommand\TIME{\mathop{\mbox{\scshape time}}}
小寫字母來取得 TIME,並使用運算符的間距。
您可以透過載入帶有\usepackage[math-style=upright]{unicode-math}
.
使用舊版工具鏈
該eulerpx
包實現了歐拉數學變量和 Palatino 文本的流行組合,以及來自newpxmath
.如果您想要 PDFLaTeX 中的直立字母,我認為這對他們來說是最有吸引力的軟體包。
該cfr-lm
軟體包使直斜體變得容易使用;有了這個包,你可以寫出\DeclareRobusTCommand\mathui[1]{\mbox{\uishape #1}}
直斜體。我之前給的\scshape
小型股範例也適用。
若要將變數名稱格式化為預設字體,\operatorname
fromamsmath
是不錯的選擇。
對於更複雜的用例,有\DeclareMathAlphabet
和\DeclareMathSymbol
。