Anchoring transitions and periodic deformations in nematic slabs