我想把公式编号连带编号两边的括号 的字体 都设置为Times New Roman,但 左边那个括号的字体就是改不了
检查清单
- [X] 我已在 issues 中进行搜索(包括已关闭的问题)
操作系统
win11
TeX 发行版
TexLive2024 CTeX3.0.215.2
描述问题
我想把公式右边编号和编号两边的括号的字体都设置为 新罗马。
我通过 \theequation 修改了参数,但最后只实现了编号和编号右边的括号的字体改成了新罗马字体,编号左边的括号的字体没变,如下图所示
修改 \theequation 参数的代码如下:
\newfontfamily\EngTwo{Times New Roman}
\renewcommand{\theequation}{\EngTwo{\arabic{equation}}}
谢谢帮助!
最小工作示例(MWE)
\documentclass[a4paper]{ctexart}
\usepackage{amsmath}
\newfontfamily\EngTwo{Times New Roman}
\renewcommand{\theequation}{\EngTwo{\arabic{equation}}}
\begin{document}
\begin{equation}
E = mc^2 \label{a}
\end{equation}
\end{document}
链接
- TeX.SX:
- GitHub:
其他信息
No response
附件
No response
\documentclass[a4paper]{ctexart}
\usepackage{mathtools}
\newfontfamily\EngTwo{Times New Roman}
\renewtagform{default}[\EngTwo]{\EngTwo(}{\EngTwo)}
\usetagform{default}
\begin{document}
\begin{equation}
E = mc^2 \label{a}
\end{equation}
\end{document}
我想把公式右边编号和编号两边的括号的字体都设置为 新罗马。 我通过
\theequation修改了参数,但最后只实现了编号和编号右边的括号的字体改成了新罗马字体,编号左边的括号的字体没变,如下图所示 [图片] 修改\theequation参数的代码如下:\newfontfamily\EngTwo{Times New Roman} \renewcommand{\theequation}{\EngTwo{\arabic{equation}}}
公式编号的排版相当于用了 (\theequation),左侧括号出现在 \theequation 之前,所以在 \theequation 里影响不到左侧括号的字体。具体是由 amsmath 里的 \tagform@ 控制的
% amsmath.sty v2.17q (2024/05/23), line 1218:
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
@SwitWu 的回答使用 mathtools 提供的修改 tag form 的用户接口,避免了直接修改 amsmath 内部宏。mathtools v1.30 (2024/03/11) 的实现,相当于
\hbox{\m@th\normalfont
<left paren>\ignorespaces{<tag format>{\theequation}}\unskip\@@italiccorr <right paren>}
所以只把切换字族的命令应用在 <left paren> 之前,也能整体修改 (\theequation) 的字体(也许不够稳妥),见 https://github.com/latex3/mathtools/issues/54 。
\newfontfamily\EngTwo{Times New Roman}
\renewtagform{default}{\EngTwo(}{)}
注意,这样定义的 \EngTwo 的语法和 \rmfamily 类似,都不接受参数,所以 \EngTwo{text} 和 \EngTwo text 的效果相同,不推荐第一种用法。
See also: https://github.com/tuna/thuthesis/blob/60661f7d140c192418cc9151b54a6c59a99fae23/thuthesis.dtx#L3529-L3563
我想把公式右边编号和编号两边的括号的字体都设置为 新罗马。 我通过
\theequation修改了参数,但最后只实现了编号和编号右边的括号的字体改成了新罗马字体,编号左边的括号的字体没变,如下图所示 [图片] 修改\theequation参数的代码如下:\newfontfamily\EngTwo{Times New Roman} \renewcommand{\theequation}{\EngTwo{\arabic{equation}}}公式编号的排版相当于用了
(\theequation),左侧括号出现在\theequation之前,所以在\theequation里影响不到左侧括号的字体。具体是由amsmath里的\tagform@控制的% amsmath.sty v2.17q (2024/05/23), line 1218: \def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}@SwitWu 的回答使用
mathtools提供的修改 tag form 的用户接口,避免了直接修改amsmath内部宏。mathtoolsv1.30 (2024/03/11) 的实现,相当于\hbox{\m@th\normalfont <left paren>\ignorespaces{<tag format>{\theequation}}\unskip\@@italiccorr <right paren>}所以只把切换字族的命令应用在
<left paren>之前,也能整体修改(\theequation)的字体(也许不够稳妥),见 latex3/mathtools#54 。\newfontfamily\EngTwo{Times New Roman} \renewtagform{default}{\EngTwo(}{)}注意,这样定义的
\EngTwo的语法和\rmfamily类似,都不接受参数,所以\EngTwo{text}和\EngTwo text的效果相同,不推荐第一种用法。
非常感谢!
\documentclass[a4paper]{ctexart} \usepackage{mathtools} \newfontfamily\EngTwo{Times New Roman} \renewtagform{default}[\EngTwo]{\EngTwo(}{\EngTwo)} \usetagform{default} \begin{document} \begin{equation} E = mc^2 \label{a} \end{equation} \end{document}
非常感谢
See also: https://github.com/tuna/thuthesis/blob/60661f7d140c192418cc9151b54a6c59a99fae23/thuthesis.dtx#L3529-L3563
非常感谢