Internal method to tokenize latex

def _tokenize_latex(self, exp):
        """
        Internal method to tokenize latex
        """
        tokens = []
        prevexp = ""
        while exp:
            t, exp = self._get_next_token(exp)
            if t.strip() != "":
                tokens.append(t)
            if prevexp == exp:
                break
            prevexp = exp
        return tokens