Stellar structure of magnetars