Separated inline and displayed math logic