The present invention provides a method for aligning a compacting plunger (18) of an agricultural square baler (10) with respect to a gearbox (21) for driving the compacting plunger (18). The method comprises controlling a position of plunger rails (41) on and against which the compacting plunger (18) will move when the agricultural square baler (10) is in operation, with respect to a position of a carrying beam (30) adapted for carrying the gearbox (21). Controlling the position of the plunger rails (41) with respect to the carrying beam (30) adapted for carrying the gearbox (21) rather than with respect to the side walls of the baler (10) provides the advantage of reduced wearing and/or fractures of parts of the baler (10).