Gravitational instability is a key process that may lead to fragmentation of gaseous structures (sheets, filaments, haloes) in astrophysics and cosmology. We introduce here a method to derive analytic expressions for the growth rate of gravitational instability in a plane stratified medium. First, the main strength of our approach is to reduce this intrinsically fourth-order eigenvalue problem to a sequence of second-order problems. Second, an interesting by-product is that the unstable part of the spectrum is computed by making use of its stable part. Third, as an example, we consider a pressure-confined, static, self-gravitating slab of a fluid with an arbitrary polytropic exponent, with either free or rigid boundary conditions. The method can naturally be generalised to analyse the stability of richer, more complex systems. Finally, our analytical results are in excellent agreement with numerical solutions. Their second-order expansions provide a valuable insight into how the rate and wavenumber of maximal instability behave as functions of the polytropic exponent and the external pressure (or, equivalently, the column density of the slab).