refactor latex render, matrix and vector randomization, fix transposed matrix bug