You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在LaTeX数学模式内使用\MTVersion或类似命令切换字体?

问题解决:mathastext局部切换数学字体的正确方法

\MTVersion命令不能在数学模式内部直接使用,它是全局切换mathastext字体版本的命令,必须在数学模式外调用。要实现公式局部切换草书字体,不需要拆分公式,有两种更简洁的方案:

方案1:利用\mathversion局部切换

mathastext会适配LaTeX原生的\mathversion命令,结合分组可以精准限定字体切换范围:

\documentclass{article}

\usepackage[default]{frcursive}
\usepackage[subdued, eulergreek, defaultmathsizes, noplusnominus, noequal, nohbar, nolessnomore, noasterisk]{mathastext}
\MTDeclareVersion{frcursive}{T1}{frc}{m}{n}

% 封装成便捷命令,方便重复使用
\newcommand{\cursivmath}[1]{{\mathversion{frcursive}#1}}

\begin{document}

{原拆分公式写法:$f(x)=3x+$ \MTVersion{frcursive}$2y$}

{局部切换的正确写法:$f(x)=3x+\cursivmath{2y}$}

\end{document}

方案2:直接调用字体族跳过版本声明

如果只是局部应用草书字体,也可以直接在数学模式内调用字体族,无需通过mathastext的版本声明:

\documentclass{article}

\usepackage[default]{frcursive}
\usepackage[subdued, eulergreek, defaultmathsizes, noplusnominus, noequal, nohbar, nolessnomore, noasterisk]{mathastext}

\newcommand{\cursivmath}[1]{{\fontfamily{frc}\selectfont$#1$}}

\begin{document}

{直接字体调用写法:$f(x)=3x+\cursivmath{2y}$}

\end{document}

关键说明

  • \MTVersion是全局生效命令,使用后会改变后续所有数学模式的字体,必须在数学模式外调用,若要恢复原字体还需执行\MTVersion{normal}。
  • 上述两种方案通过分组{}限定字体切换范围,确保仅影响公式的指定部分,不需要拆分公式。

内容的提问来源于stack exchange,提问作者AO3 user without CSS knowledge

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 13:33:13