2

I am using this template: https://www.overleaf.com/latex/templates/springer-nature-latex-template/gsvvftmrppwq

my equation is:

\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}

The same problem with:

\begin{equation}
dh_{i}=\left|h_{t l}-h_{i}\right|
\end{equation}

it gives an error and doesn't show | in the equation.

6
  • Please try to post a complete example; with article your equations works ok. Are you sure you did not load some package that changes the meaning of |? Some verbatim-like packages do that, I think. This is the reason why an MWE is so important in LaTeX... tex.meta.stackexchange.com/questions/6255/…
    – Rmano
    Feb 16, 2022 at 11:54
  • Something is strange, I used it after your comment without any addition or change. The same issue.
    – Redhwan
    Feb 16, 2022 at 12:00
  • 2
    Unrelated: remember that generally |... | is not the proper symbol pair to use (try |-1|, the minus spacing is wrong). Use amssymb and \lvert... \rvert instead
    – daleif
    Feb 16, 2022 at 12:04
  • @daleif, Thank you so much. It is working fine now.
    – Redhwan
    Feb 16, 2022 at 12:08
  • You should still provide a full minimal example such that your question is usable for others in the future. So far we have no idea what you're doing that might cause | to behave differently
    – daleif
    Feb 16, 2022 at 12:10

2 Answers 2

5

For very mysterious reasons, the class loads program.sty, an obscure package that does several mysterious things and has essentially no documentation: one page with no examples; it tells to look into program-demo.tex, which is pretty uninformative as well.

On the other hand, the scanty documentation for the package tells users to use origbar instead of |.

You should complain with the editors and the maintainers of the class, because forcing users to deal with this package is really awful of them. By the way, the class also loads algpseudocode, which is much better than program. What I find most irritating is that the package redefines \( and \).

Anyway, you can solve your problem by using \lvert and \rvert which are actually better than the unadorned | to denote absolute value or cardinality. LaTeX also provides \vert as an alias.

\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}

enter image description here

A more drastic step would be to undo the (wrong) settings made by 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}
4

The sn-jnl class load the package program causing the problem. Commenting out or removing the line #311 (\usepackage{program}%) of sn-jnl.sty gives the correct result.

a

% !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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .