From 069d3a3cf431353a7ff605f1783a1f10e7aaebf4 Mon Sep 17 00:00:00 2001 From: Alexara Wu Date: Thu, 2 Jan 2025 22:01:04 +0800 Subject: [PATCH] chore: disable loading of conflicting packages --- sjtutex/source/sjtutex.dtx | 54 ++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/sjtutex/source/sjtutex.dtx b/sjtutex/source/sjtutex.dtx index 8900b21d..018f0484 100644 --- a/sjtutex/source/sjtutex.dtx +++ b/sjtutex/source/sjtutex.dtx @@ -2128,6 +2128,18 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\@@_disable_package_load:n} +% \begin{macrocode} +\msg_new:nnn { sjtutex } { package-disabled } + { The~loading~of~package~'#1'~is~disabled. } +\cs_new_protected:Npn \@@_disable_package_load:n #1 + { + \disable@package@load {#1} + { \msg_warning:nnn { sjtutex } { package-disabled } {#1} } + } +% \end{macrocode} +% \end{macro} +% % \changes{v2.0.2}{2023/03/31}{区分 \texttt{dim} 与 \texttt{skip} 类型变量。} % \begin{macro}[int]{\@@_dim_set_to_wd:Nn,\@@_skip_add_to_wd:Nn} % 操作长度变量的辅助函数。 @@ -2857,6 +2869,9 @@ \scpolint\npolint\pointint\sqint\intlarhk\intx \intcap\intcup\upint\lowint } + \clist_map_inline:nn + { amsfonts, amssymb, bm, upgreek } + { \@@_disable_package_load:n {#1} } } % \end{macrocode} % @@ -5493,34 +5508,33 @@ \newtheoremstyle { sjtu } { } { } { \SJTU@style@thm@body@font } { } { \SJTU@style@thm@header@font } { } { \ccwd } { } + \@@_disable_package_load:n { ntheorem } + \AddToHook { begindocument / before } + { + \theoremstyle { sjtu } + \@@_new_theorems: + } } % \end{macrocode} % -% 如果用户加载了 \pkg{amsthm} 或 \pkg{ntheorem} 宏包, -% 则在导言区末尾应用预设的样式定义定理环境。 +% \pkg{ntheorem} 宏包。 % \begin{macrocode} -\AddToHook { begindocument / before } +\AddToHook { package / ntheorem / after } { - \IfPackageLoadedTF { amsthm } + \@@_disable_package_load:n { amsthm } + \AddToHook { begindocument / before } { - \theoremstyle { sjtu } + \@@_cs_provide_eq:NN \QED \c_empty_tl + \theoremheaderfont { \SJTU@style@thm@header@font } + \theorembodyfont { \SJTU@style@thm@body@font } + \theoremseparator { \enskip } + \theoremsymbol { \ensuremath { \QED } } + \qedsymbol { \ensuremath { \QED } } + \cs_if_exist:NF \proof + { \newtheorem* { proof } { \proofname } } + \theoremsymbol { } \@@_new_theorems: } - { - \IfPackageLoadedT { ntheorem } - { - \@@_cs_provide_eq:NN \QED \c_empty_tl - \theoremheaderfont { \SJTU@style@thm@header@font } - \theorembodyfont { \SJTU@style@thm@body@font } - \theoremseparator { \enskip } - \theoremsymbol { \ensuremath { \QED } } - \qedsymbol { \ensuremath { \QED } } - \cs_if_exist:NF \proof - { \newtheorem* { proof } { \proofname } } - \theoremsymbol { } - \@@_new_theorems: - } - } } % \end{macrocode} %