Electronic structure of MX2-type layered compounds