Skip to content

Instantly share code, notes, and snippets.

@graphomania
Created March 30, 2021 07:23
Show Gist options
  • Save graphomania/8665fc2b3a6c4c7eef19e8ffd1bf5929 to your computer and use it in GitHub Desktop.
Save graphomania/8665fc2b3a6c4c7eef19e8ffd1bf5929 to your computer and use it in GitHub Desktop.
Python Matrix to Tex String
def matrix_to_tex(matrix) -> str:
tex_str = '\\begin{matrix}\n'
lines_strs = list()
for line in matrix:
lines_strs.append(' & '.join([str(el) for el in line]))
tex_str += '\\\\\n'.join(lines_strs) + '\n\\end{matrix}'
return tex_str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment