我正在使用这个模板: https://www.overleaf.com/latex/templates/springer-nature-latex-template/gsvvftmrppwq
我的等式是:
\documentclass[pdflatex,sn-mathphys]{sn-jnl}% Math and Physical Sciences Reference Style
\jyear{2021}%
\theoremstyle{thmstyleone}%
\newtheorem{theorem}{Theorem}% meant for continuous numbers
\newtheorem{proposition}[theorem]{Proposition}%
\theoremstyle{thmstyletwo}%
\newtheorem{example}{Example}%
\newtheorem{remark}{Remark}%
\theoremstyle{thmstylethree}%
\newtheorem{definition}{Definition}%
\raggedbottom
\begin{document}
\begin{equation}
J(A, B)=\frac{|A \cap B|}{|A \cup B|}
\end{equation}
\bibliography{sn-bibliography}% common bib file
\end{document}
同样的问题:
\begin{equation}
dh_{i}=\left|h_{t l}-h_{i}\right|
\end{equation}
它会产生错误并且不会|
在等式中显示。
答案1
由于非常神秘的原因,该类加载了program.sty
一个不起眼的包,它会做一些神秘的事情,并且基本上没有任何文档:一页没有任何示例;它告诉人们去查看program-demo.tex
,这也是没有什么信息的。
另一方面,该软件包的稀少文档告诉用户使用origbar
而不是|
。
您应该向该类的编辑和维护者投诉,因为强迫用户处理这个包确实很糟糕。顺便说一句,该类还会加载algpseudocode
,这是很多比 更好program
。我发现最令人恼火的是该包重新定义了\(
和\)
。
\lvert
无论如何,您可以使用和来解决问题,\rvert
它们实际上比未修饰的|
表示绝对值或基数更好。LaTeX 还提供了\vert
别名。
\documentclass[pdflatex,sn-mathphys]{sn-jnl}% Math and Physical Sciences Reference Style
\jyear{2021}
\theoremstyle{thmstyleone}
\newtheorem{theorem}{Theorem}% meant for continuous numbers
\newtheorem{proposition}[theorem]{Proposition}
\theoremstyle{thmstyletwo}
\newtheorem{example}{Example}
\newtheorem{remark}{Remark}
\theoremstyle{thmstylethree}
\newtheorem{definition}{Definition}
\raggedbottom
\begin{document}
\begin{equation}
J(A, B)=\frac{\lvert A \cap B\rvert}{\lvert A \cup B\rvert}
\end{equation}
\bibliography{sn-bibliography}% common bib file
\end{document}
更激烈的措施是撤消所做的(错误)设置program.sty
。
\documentclass[pdflatex,sn-mathphys]{sn-jnl}% Math and Physical Sciences Reference Style
\jyear{2021}%
\theoremstyle{thmstyleone}%
\newtheorem{theorem}{Theorem}% meant for continuous numbers
\newtheorem{proposition}[theorem]{Proposition}%
\theoremstyle{thmstyletwo}%
\newtheorem{example}{Example}%
\newtheorem{remark}{Remark}%
\theoremstyle{thmstylethree}%
\newtheorem{definition}{Definition}%
\raggedbottom
%%% Undo the settings made by program.sty
\catcode`_=8 % _ is subscript
\catcode`|=12 % | is a normal character
\mathcode`;=\semicolon
\mathcode``=``
\makeatletter
\DeclareRobustCommand\({\relax\ifmmode\@badmath\else$\fi}
\DeclareRobustCommand\){\relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}
\makeatother
%%%
\begin{document}
\begin{equation}
J(A, B)=\frac{|A \cap B|}{|A \cup B|}
\end{equation}
\bibliography{sn-bibliography}% common bib file
\end{document}
答案2
类sn-jnl
加载导致问题的包program
。注释掉或删除行 #311( \usepackage{program}%
)sn-jnl.sty
可得到正确结果。
% !TeX TS-program = pdflatex
\documentclass[pdflatex,sn-mathphys]{sn-jnl}% Math and Physical Sciences Reference Style
\jyear{2021}%
\theoremstyle{thmstyleone}%
\newtheorem{theorem}{Theorem}% meant for continuous numbers
\newtheorem{proposition}[theorem]{Proposition}%
\theoremstyle{thmstyletwo}%
\newtheorem{example}{Example}%
\newtheorem{remark}{Remark}%
\theoremstyle{thmstylethree}%
\newtheorem{definition}{Definition}%
\raggedbottom
\begin{document}
\begin{equation}
J(A, B)=\frac{|A \cap B|}{|A \cup B|}
\end{equation}
\begin{equation}
dh_{i}=\left\|h_{t l}-h_{i}\right\| % changed <<<<<<<<<<
\end{equation}
% \bibliography{sn-bibliography}% common bib file
\end{document}