A method in an electron-optical system adapted to supply an outgoing electron beam (I 2) in an electron-impact X-ray source operable to produce an electron target to be irradiated by the outgoing electron beam in an interaction region, the system comprising: aligning means for adjusting a direction of an incoming electron beam (I 1); a deflector operable to deflect the outgoing electron beam (I 2); and focusing means for focusing the outgoing electron beam in the interaction region, wherein the deflector and focusing means define an optical axis of the electron-optical system, the method comprising the steps of: determining, for a plurality of focusing-means settings and aligning-means settings, a relative position of the outgoing electron beam by deflecting the outgoing electron beam into and/or out of a sensor area, which is arranged a distance downstream of the interaction region and has a known position with respect to the optical axis of the system; determining, based on the plurality of relative positions thus determined, an adequate aligning-means setting for which the relative position has minimal sensitivity with respect to a change in focusing-means setting; applying an aligning-means setting based on said adequate aligning-means setting; determining an orientation of the outgoing electron beam by ensuring that the electron target partially obscures the sensor area from a deflection range of the electron beam, and further by deflecting the electron beam between the electron target and an unobscured portion of the sensor area; and determining, for at least one focusing-means setting, a width of the outgoing electron beam in the interaction region by ensuring that the electron target partially obscures the sensor area from the electron beam, and further by deflecting the electron beam between the electron target and an unobscured portion of the sensor area in a normal direction of the electron target. aligning means for adjusting a direction of an incoming electron beam (I 1); a deflector operable to deflect the outgoing electron beam (I 2); and focusing means for focusing the outgoing electron beam in the interaction region, wherein the deflector and focusing means define an optical axis of the electron-optical system, the method comprising the steps of: determining, for a plurality of focusing-means settings and aligning-means settings, a relative position of the outgoing electron beam by deflecting the outgoing electron beam into and/or out of a sensor area, which is arranged a distance downstream of the interaction region and has a known position with respect to the optical axis of the system; determining, based on the plurality of relative positions thus determined, an adequate aligning-means setting for which the relative position has minimal sensitivity with respect to a change in focusing-means setting; applying an aligning-means setting based on said adequate aligning-means setting; determining an orientation of the outgoing electron beam by ensuring that the electron target partially obscures the sensor area from a deflection range of the electron beam, and further by deflecting the electron beam between the electron target and an unobscured portion of the sensor area; and determining, for at least one focusing-means setting, a width of the outgoing electron beam in the interaction region by ensuring that the electron target partially obscures the sensor area from the electron beam, and further by deflecting the electron beam between the electron target and an unobscured portion of the sensor area in a normal direction of the electron target. determining, for a plurality of focusing-means settings and aligning-means settings, a relative position of the outgoing electron beam by deflecting the outgoing electron beam into and/or out of a sensor area, which is arranged a distance downstream of the interaction region and has a known position with respect to the optical axis of the system; determining, based on the plurality of relative positions thus determined, an adequate aligning-means setting for which the relative position has minimal sensitivity with respect to a change in focusing-means setting; applying an aligning-means setting based on said adequate aligning-means setting; determining an orientation of the outgoing electron beam by ensuring that the electron target partially obscures the sensor area from a deflection range of the electron beam, and further by deflecting the electron beam between the electron target and an unobscured portion of the sensor area; and determining, for at least one focusing-means setting, a width of the outgoing electron beam in the interaction region by ensuring that the electron target partially obscures the sensor area from the electron beam, and further by deflecting the electron beam between the electron target and an unobscured portion of the sensor area in a normal direction of the electron target.