更改 Mathup 字体

更改 Mathup 字体

我只是一个可怜的 latex 用户,想要自定义字体样式。这是我的基本设置。

\documentclass[11pt]{article}
\usepackage{amsthm,amssymb,amsmath,amsbsy}
\usepackage[T1]{fontenc}
\usepackage[lf]{Baskervaldx} % lining figures
\usepackage[bigdelims]{newtxmath} % math italic letters from Nimbus Roman (vvarbb for mathbb font)
\usepackage[bb=px, cal=cm, scr=boondoxo]{mathalfa}

\DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n}

\begin{document}
$\mathup{Category}$ $\text{Category}$
\end{document}

在此处输入图片描述

我的问题是,当我在设置中使用 \mathup 时,它使用 Computer Modern 而不是我用作文本字体的 Baskervaldx。(显然使用 \text 是一个错误的决定,因为它不是数学模式……)有没有办法解决这个问题?unicode-math 包可以解决这个问题吗?(我试过了,但不知何故我的 overleaf 在加载这个包时出现了一些问题。可能与我的代码的其他部分冲突。)

答案1

这是一个解决方案,本质上它包括整合@egreg 的所有建议。

请注意,所有建议均已实施,\mathup与 大致相同\mathrm

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage{amsthm,amssymb,amsmath,amsbsy}

\usepackage[T1]{fontenc}
\usepackage{baskervillef} % text font (lining figures are the default)
\usepackage[bigdelims,baskerville]{newtxmath} % math font
\DeclareMathAlphabet{\mathup}{T1}{\familydefault}{m}{n}
%\usepackage[bb=px,cal=cm,scr=boondoxo]{mathalfa} % optional

\begin{document}
\obeylines
$\mathup{Category}$ $\text{Category}$
$\mathrm{abc ABC 0123568}$
$\mathup{abc ABC 0123568}$
$\text{abc ABC 0123568}$
abc ABC 0123568
\end{document}

答案2

事实上,我找到了一个简单的解决方案。除了使用 \mathup 或 \mathrm,还可以使用 \normalfont 来使用文本字体,并在任何环境下保持其直立。

\documentclass[11pt]{article}
\usepackage{amsthm,amssymb,amsmath,amsbsy}

\usepackage[T1]{fontenc}
\usepackage{baskervald}
\usepackage[bigdelims]{newtxmath} % math font
%\usepackage[bb=px,cal=cm,scr=boondoxo]{mathalfa} % optional
\newcommand{\textup}[1]{\normalfont{\text{#1}}}
\begin{document}
\obeylines
$\textup{Category}$ $\text{Category}$
\end{document}

这与在定理环境中直立的 \text 效果相同。

相关内容