An image forming apparatus, which is capable of correctly and accurately
detecting a sheet leading edge position and carrying out image formation
in appropriate image write timing, includes a detection device disposed
at a reference position upstream from the transfer position and detects
the recording medium being conveyed. A determining device determines
image write timing for forming the electrostatic latent image on the
photosensitive drum based on a difference in position between a leading
edge position of the recording medium detected by said detection device
and the reference position. The detection device respectively include a
plurality of light detecting pixels disposed in a recording medium
conveying direction, and the leading edge position of the recording
medium detected by the respective light detecting pixels.