Structural transitions in layer crystals under hydrostatic compression