Factorization in a torus and Riemann–Hilbert problems