Add and remove math mode keywords in toggle function