cleaned up latex template handling
more meat on the bones