Automating pairwise distance to LaTeX.