I know a lot of people are still using $ and $$ to open and close math code but the proper way is to use \( and \[ to open while \) and \] to close.
The square brackets are the same as $$ and the round brackets are $. But $ and $$ are deprecated while \( and \[ are proper. Can you make them work?
Also, when things are centered using [math]! you should set \displaystyle like LaTeX does automatically when you do $$ or \[.