  The analysis and interpretation of the H2 line emission from planetary
nebulae have been done in the literature assuming that the molecule survives
only in regions where the hydrogen is neutral, as in photodissociation, neutral
clumps or shocked regions. However, there is strong observational and
theoretical evidence that at least part of the H2 emission is produced inside
the ionized region of such objects. The aim of the present work is to calculate
and analyze the infrared line emission of H2 produced inside the ionized region
of planetary nebulae using a one-dimensional photoionization code. The
photoionization code Aangaba was improved in order to calculate the statistical
population of the H2 energy levels and the intensity of the H2 infrared
emission lines in physical conditions typical of planetary nebulae. A grid of
models was obtained and the results are analyzed and compared with the
observational data. We show that the contribution of the ionized region to the
H2 line emission can be important, particularly in the case of nebulae with
high temperature central stars. This result explains why H2 emission is more
frequently observed in bipolar planetary nebulae (Gatley's rule), since this
kind of object typically has hotter stars. Collisional excitation plays an
important role on the population of the rovibrational levels of the electronic
ground state of H2. Radiative mechanisms are also important, particularly for
the upper vibrational levels. Formation pumping can have minor effects on the
line intensities produced by de-excitation from very high rotational levels,
especially in dense and dusty environments. We included the effect of the H2 on
the thermal equilibrium of the gas, concluding that H2 only contributes to the
thermal equilibrium in the case of a very high temperature of the central star
or a high dust-to-gas ratio, mainly through collisional de-excitation.
