latex function is ok, not very well