fix latex loops for contracts