# Error compiling equation

My document (subfile in documentclass book) compiles perfectly, untill I add the following equation:

$$\label{beliefupdate} \begin{split} b_{t+1}(s') & = \Pr(s'|o',a,b) \\ & = \frac{\Pr(o'|s',a,b)\Pr(s'|a,b)}{\Pr(o'|a,b} \\ & = \frac{\Pr(o'|s',a) \sum_{s\in\S}\Pr(s'|a,b,s)\Pr(s|a,b)}{\Pr(o'|a,b)} \\ & = \frac{O(o',a,s') \sum_{s\in\S}T(s,a,s')b_t(s)}{\Pr(o'|a,b)} \end{split}$$


\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{physics}

\renewcommand{\S}{\mathcal{S}}

\usepackage{graphicx}
\usepackage{wrapfig}


Now, Latex starts giving me warnings in two locations of the document. The first few are in this piece of code, way before the location where I enter the equation

\begin{wrapfigure}{r}
\centering
\includegraphics[scale = 0.25]{images/MDP.jpg}
\end{wrapfigure}


I get the error: 'missing number, treated as zero' and also 'Illegal unit of measure (pt inserted)' both about the line \centering

The second batch of errors is about the line \end{split} in the equation.

errors:

FIRST ERROR:

Argument of \opbraces has an extra }.

\par l.151 \end{split}

SECOND ERROR:

Runaway argument?

(o'|a,b ! Paragraph ended before \opbraces was complete. \par l.151 \end{split}

THIRD ERROR: Missing \$ inserted.

I honestly don't see where I go wrong

• Don't use physics. Aug 24, 2020 at 7:49
• Well, that seemed to work. Thanks haha! Any explanation why, because I would never have figured this out myself
– Rens
Aug 24, 2020 at 7:51
• Off-topic: You may want to replace the "conditioning" uses of | with \mid.
– Mico
Aug 24, 2020 at 9:08

Well, you're missing ) at the end of the second line in split:

        & = \frac{\Pr(o'|s',a,b)\Pr(s'|a,b)}{\Pr(o'|a,b} \\


should be

        & = \frac{\Pr(o'|s',a,b)\Pr(s'|a,b)}{\Pr(o'|a,b)} \\


The missing parenthesis goes unnoticed when physics is not loaded, but it becomes essential when it is, because the package (re)defines \Pr to look for an argument enclosed in (...) (which is a bad thing to do, in my opinion).

Check your input more closely. And don't do \renewcommand\S{\mathcal{S}}.

Personal opinion. I cannot recommend using the physics package, because it has a very convoluted syntax and makes disputable typesetting decisions.

• Thanks for the extensive answer. It is sloppy that i overlooked the parenthesis. Any comment on why not to renewcommand? because it is error prone? By the way, I would upvote your post, but apparently I can't because I lack the reputation
– Rens
Aug 24, 2020 at 8:26
• @Rens it is better to never redefine internal commands, and it's better to not use one-letter commands, they are used internally often, and changing them can have very strange effects. For example \S is normally defined (barring the protect) as: \S : \long macro:->\ifmmode \mathsection \else \textsection \fi --- you never know where it can bite you Aug 24, 2020 at 8:36
• @Rens I can confirm what Rmano says; use \cS or whatever, but don't redefine commands you don't know about. A colleague of mine had all sorts of mysterious error messages because he had redefined \c. Aug 24, 2020 at 8:39
• Clear! Thanks again for the answers
– Rens
Aug 24, 2020 at 8:51