Conventionally, a printer acting as an image forming apparatus detects a position at which an image is formed in such a manner that a sensor for position detection reads a pattern for position detection formed on a medium. However, an error occurring in formation of the image by the printer also occurs in a case in which the pattern for position detection is formed with high resolution. Thus, the conventional printer has a problem that it is difficult to detect the position with high precision in a position detection with the high resolution.