Write formula and a derived formula to TeX file