factored out LaTeX backend