Function to reduce a matrix in row echelon form and write steps to LaTeX