我正在尝试编写自己的包,但无法包含esint
它而不会出错。这是我的包的 MWE:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{zyy}[2021/08/14 Yiyu's preamble for article]
\RequirePackage[e]{esvect} %% stylish vector symbols
\RequirePackage{esint} %% various integral symbols
\RequirePackage{tensor} %% manage order of tensor indices
\RequirePackage{slashed} %% Feynman slash notation
\RequirePackage{simpler-wick} %% Wick contraction
\RequirePackage{physics}
\RequirePackage{amssymb} %% this package loads package 'amsfonts' internally
\numberwithin{equation}{section} %% number equations by section and subsection numbers
\RequirePackage{mathtools} %% a more powerful version of package 'amsmath'
除非我注释掉physics
、\numberwith
和mathtools
,否则包含esint
会在排版时引起冲突:
! LaTeX Error: Command \iint already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
但我已经检查过了,既没有physics
也没有mathtools
定义\iint
。
\RequirePackage{esint}
为了让事情变得更加神秘,如果我在文件中注释掉它.sty
,并将其从文档中包含进去,那么一切都会好起来:
\documentclass{article}
\usepackage{zyy}
\usepackage{esint}
\begin{document}
$\oint$
\end{document}
答案1
您想更改加载顺序:esint
必须在amsmath
(由 加载mathtools
)之后进行。 的文档esint
仍然提到amslatex
,但应将其解释为amsmath
。
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{zyy}[2021/08/14 Yiyu's preamble for article]
\RequirePackage{mathtools} %% a more powerful version of package 'amsmath'
\RequirePackage{amssymb} %% this package loads package 'amsfonts' internally
\RequirePackage[e]{esvect} %% stylish vector symbols
\RequirePackage{esint} %% various integral symbols
\RequirePackage{tensor} %% manage order of tensor indices
\RequirePackage{slashed} %% Feynman slash notation
\RequirePackage{simpler-wick} %% Wick contraction
\RequirePackage{physics}
\counterwithin{equation}{section} %% number equations by section and subsection numbers
我改成\numberwithin
了\counterwithin
那个内核版本。
附注:您确定要加载吗physics
?我不会。它似乎提供了花哨的功能,但却以笨拙的语法和有争议的输出为代价。