Magnetoelastic effects in orthorhombic and tetragonal rare-earth crystals