我正在使用classicthesis
模板。
我正在尝试输入大写希腊字母 Psi Ψ。但是,它编译为符号 ̄ 。当我禁用 时,这种情况会停止breqn
。这发生在常规方程模式下,只需
\[\Psi\]
dmath
但我也遇到过这种情况equation
。
答案1
breqn 文档提到了这个问题:
通常您在之前加载数学字体breqn
:
不幸的是,fourier
这不是受支持的数学字体之一,您需要弄清楚发生了什么,然后创建自己的支持文件。
类似问题:fourier - breqn 在 TL 2016 中破坏了 fouriernc - TeX - LaTeX Stack Exchange
以下可能是正确的方法:
\documentclass{article}
\usepackage{amsmath}
\usepackage{fourier}
%\usepackage[fourier]{flexisym} % it would suffice to do this if there were a `fourier.sym` support file
\usepackage{breqn}
\ExplSyntaxOn
\makeatletter
\cs_gset:cpx {mg@Greek} {\hexnumber@\symotherletters}
\makeatother
\ExplSyntaxOff
\begin{document}
\[
\Psi
\]
\end{document}
基本上你可以
- 阅读现有的支持文件(例如
mathpazo.sym
)以查看breqn
/flexisym
与其他数学软件包的作用, - 阅读包的源代码
fourier
以找出 ⟨sym-font⟩ 名称(otherletters
), - 阅读各种源代码来找出其中的小技巧
- LaTeX
mathgroup
就是 TeX 的fam
, \mg@⟨flexisym internal symbol font name⟩
存储\mathgroup
该符号字体名称的编号,\sym⟨sym-font⟩
存储该符号字体的数学组,其中⟨sym-font⟩
为fntguide
。
- LaTeX
如果您breqn
提前加载会怎么样fourier
?
您会收到一些关于“命令已定义”的错误消息。
在内部,正在发生的事情是fourier
运行\DeclareMathSymbol
重新定义\Psi
和许多其他命令,但问题是
\DeclareMathSymbol
仅当含义包含字符串时才允许安全地重新定义控制序列mathchar
,breqn
的定义\Psi
没有它,- 从而
\DeclareMathSymbol
引发错误并且不会重新定义控制序列。
这是 LaTeX 的错还是 breqn 的错?我不确定,我只能通过 GitHub 日志将 LaTeX 代码追溯到 2008 年 (https://github.com/latex3/latex2e/blob/develop/base/ltfssdcl.dtx#L1591),但 breqn 包比它更老。(无论如何,TeX 缺少检查某个东西是否是数学字符的接口,这迫使 LaTeX 使用字符串含义测试,而这种测试很脆弱,正如您所见)
无论如何,一种方法是修补\DeclareMathSymbol
:(您还需要进行类似的修补\DeclareMathDelimiter
以避免出现这里未完成的其他错误消息):
\makeatletter
\def\originalDeclareMathSymbol#1#2#3#4{%
\expandafter\in@\csname sym#3\expandafter\endcsname
\expandafter{\group@list}%
\ifin@
\begingroup
\count\z@=#4\relax
\count\tw@\count\z@
\divide\count\z@\sixt@@n
\count@\count\z@
\multiply\count@\sixt@@n
\advance\count\tw@-\count@
\if\relax\noexpand#1% is command?
% \end{macrocode}
% Store the command name with a space attached inside
% \cs{reserved@@b} in case we look at a robust definition.
% \begin{macrocode}
\edef\reserved@b{\expandafter\noexpand
\csname\expandafter\@gobble\string#1\space\endcsname}%
% \end{macrocode}
% Test both \verb=#1= and \verb*=#1 = for containing \texttt{mathchar}.
% \begin{macrocode}
\edef\reserved@a
{\noexpand\in@{\expandafter\@gobble\string\mathchar}%
{\meaning#1\expandafter\meaning\reserved@b}}%
\reserved@a
% \end{macrocode}
% Drop \verb*=#1 = in case it was defined before.
% \begin{macrocode}
\global\expandafter\let\reserved@b\@undefined
\ifin@
\expandafter\set@mathsymbol
\csname sym#3\endcsname#1#2%
{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
\@font@info{Redeclaring math symbol \string#1}%
\else
\expandafter\ifx
\csname\expandafter\@gobble\string#1\endcsname
\relax
\expandafter\set@mathsymbol
\csname sym#3\endcsname#1#2%
{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
\else
\@latex@error{Command `\string#1' already defined}\@eha
\fi
\fi
\else
\expandafter\set@mathchar
\csname sym#3\endcsname#1#2
{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
\fi
\endgroup
\else
\@latex@error{Symbol font `#3' is not defined}\@eha
\fi
}
\ifx\originalDeclareMathSymbol\DeclareMathSymbol \else \errmessage{Unexpected definition of DeclareMathSymbol!!}\fi
\def\DeclareMathSymbol#1#2#3#4{%
\expandafter\in@\csname sym#3\expandafter\endcsname
\expandafter{\group@list}%
\ifin@
\begingroup
\count\z@=#4\relax
\count\tw@\count\z@
\divide\count\z@\sixt@@n
\count@\count\z@
\multiply\count@\sixt@@n
\advance\count\tw@-\count@
\if\relax\noexpand#1% is command?
% \end{macrocode}
% Store the command name with a space attached inside
% \cs{reserved@@b} in case we look at a robust definition.
% \begin{macrocode}
\edef\reserved@b{\expandafter\noexpand
\csname\expandafter\@gobble\string#1\space\endcsname}%
% \end{macrocode}
% Drop \verb*=#1 = in case it was defined before.
% \begin{macrocode}
\global\expandafter\let\reserved@b\@undefined
\expandafter\set@mathsymbol
\csname sym#3\endcsname#1#2%
{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
\@font@info{Redeclaring math symbol \string#1}%
\else
\expandafter\set@mathchar
\csname sym#3\endcsname#1#2
{\hexnumber@{\count\z@}\hexnumber@{\count\tw@}}%
\fi
\endgroup
\else
\@latex@error{Symbol font `#3' is not defined}\@eha
\fi
}
\makeatother
\documentclass{article}
%\usepackage[paperheight=5cm, paperwidth=5cm]{geometry}
%\errorcontextlines=10
\usepackage{amsmath}
\usepackage{breqn}
\usepackage{fourier}
\begin{document}
\[
\Psi
\]
\end{document}