1

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

\usepackage{amsmath, amsfonts, dsfont}
\usepackage{blindtext}
\usepackage{xcolor}

\usepackage{mathtools} \usepackage{comment} \usepackage{amsthm} \usepackage{algorithm, algpseudocode} \usepackage{caption, subcaption} \usepackage[export]{adjustbox} \usepackage{multirow} \usepackage{graphicx} \graphicspath{{images/}} \usepackage{xr} \usepackage{subfiles}

\newcommand{\E}{\mathbb{E}} \newcommand{\p}{\mathbb{P}} \newcommand{\Reals}{\mathbb{R}}

Unfortunately, I am getting the the error message ./sn-article.tex:75: LaTeX Error: Command \p already defined. Or name \end... illegal, see p.192 of the manual.

However, if I call $\p$ or \p, I get ./sn-article.tex:193: Missing $ inserted. <inserted text> .

Thanks!

Mico
  • 506,678
Anonny
  • 123

1 Answers1

1

A macro -- or, at least, a macro that's defined via \def, \newcommand, or friends -- can't be simultaneously defined and undefined.

If I make your code snippet minimally compilable by prefixing it with \documentclass[default]{sn-jnl} and affixing \begin{document} \show\p \end{document} to it, I get the following output (written to the screen and log file, but not to the pdf file):

> \p=macro:
#1->\mathrel {\ooalign {\hfil $\mapstochar \mkern 5mu$\hfil \cr $#1$}}.
l.23 \show\p

This macro takes one argument and should be used in math mode since its "outermost" constituent directive is \mathrel.

Aside: \p is not defined in the LaTeX kernel or in one of the standard LaTeX document classes (article, report, and book). Instead, \p is defined as part of the sn-jnl document class.

If you don't care about this macro and don't mind clobbering it -- warning: proceed at your own risk! -- you could simply replace

\newcommand{\p}{\mathbb{P}}

with

\renewcommand{\p}{\mathbb{P}}

However, clobbering existing macros is generally ill-advised. Do consider coming up with a name other than \p for the macro you intend to use in the body of your document.

Mico
  • 506,678