Melt an Ocaml library and preprocessor to generate Latex documents. It saved me countless hours and immense frustration. It is still a little too much tailored to the needs of the few contributors, and development is going slowly. But you may still consider using it.