ndarrayをLaTexの行列文に自動変換するプログラムを作ったので、貼っておきます。
A = np.array([[1,2,3,1,0],[2,4,6,3,1],[3,4,1,1,-2],[4,6,4,-1,-5]])
def tex_mat(mat:np.ndarray) -> str:
tex = r"$\begin {pmatrix}"
for i in mat:
row_i = ""
for j in i:
row_i += str(j) + "&"
tex += row_i[:-1] + r"\\"
return tex[:-2] + r"\end{pmatrix}$"
tex_mat(A)
>>>
$\begin {pmatrix}1&2&3&1&0\\2&4&6&3&1\\3&4&1&1&-2\\4&6&4&-1&-5\end{pmatrix}$pythonではバックスラッシュがエスケープシーケンスとして認識されるため、raw stringを使用しています。

