improved LaTEX parser