Skip to content

Instantly share code, notes, and snippets.

@Tabea-K
Created August 27, 2015 04:24
Show Gist options
  • Save Tabea-K/cfe179ea2c09e41fef8d to your computer and use it in GitHub Desktop.
Save Tabea-K/cfe179ea2c09e41fef8d to your computer and use it in GitHub Desktop.
Uses TeX to create a pdf file with the visualization of an alignment.
#!/usr/bin/env python
"""
Creates a pdf alignment
"""
import sys
import os
import tempfile
input_filename = sys.argv[1]
tex_document = r"""\documentclass[12pt]{amsart}
\usepackage{geometry}
\geometry{a4paper}
\usepackage{texshade}
\begin{document}
\section*{%s}
\begin{texshade}{%s}
\end{texshade}
\end{document}
""" % (input_filename, input_filename)
temp_tex_file = tempfile.NamedTemporaryFile(delete=False)
temp_tex_filename = temp_tex_file.name
with open(temp_tex_filename, 'w') as fh:
fh.write(tex_document)
print('pdflatex %s' % temp_tex_filename)
os.system('pdflatex %s' % temp_tex_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment