The in-plane orientation of a nematic liquid-crystal sample, confined by two periodic microtextured substrates, is theoretically analyzed by means of the Frank-Oseen continuum elastic theory and a suitable surface term. In addition, an easy optical method to produce such textures using photopolymeric films is presented. It is shown that, in the limit of large pattern period, the orientation depends only on the ratio of the splay and bend elastic constants K1/K3 and on the easy axis direction of the individual stripes. In the particular case for which K1 = K3, the stability depends only on the easy axis direction for a general pattern period.