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 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, the method comprising the steps of: determining, for a plurality of focusing-means settings and aligning-means settings, a respective position of the outgoing electron beam, relative a sensor area, by deflecting the outgoing electron beam into and/or out of the sensor area; determining, based on the plurality of positions thus determined, an adequate aligning-means setting for which the 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; 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. 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, the method comprising the steps of: determining, for a plurality of focusing-means settings and aligning-means settings, a respective position of the outgoing electron beam, relative a sensor area, by deflecting the outgoing electron beam into and/or out of the sensor area; determining, based on the plurality of positions thus determined, an adequate aligning-means setting for which the 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; 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. determining, for a plurality of focusing-means settings and aligning-means settings, a respective position of the outgoing electron beam, relative a sensor area, by deflecting the outgoing electron beam into and/or out of the sensor area; determining, based on the plurality of positions thus determined, an adequate aligning-means setting for which the 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; 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.