If you compare a standard lens to a macro lens of the same focal length, you will notice that the barrel of the macro lens is usually considerably longer. For example, the Zeiss Planar ZF 50 mm f/1.4 measures 45 mm, while the Zeiss ZF Makro Planar 50 mm f/2 is already 75 mm long and further extends about 30 mm for maximum magnification. Why do macro lenses have to be so long?
Focus distance and image distance
The answer can be derived from equation (F8), which describes the image distance h (between sensor and lens) as a function of the selected focus distance d (between sensor and object) and the focal length f. The diagram shown below illustrates this function for two lenses with focal lengths of 50 mm (blue) and 100 mm (red), respectively.
In contrast to what one might intuitively expect, as the focus distance d is decreased to get closer to your object, the image distance h is actually getting longer. In other words, the lens is moving away from the sensor. Also interesting to note, h is always in the range between 2 f (for 1:1 macro photography) and f (at infinity).
The image distance of the Zeiss macro lens mentioned above is about 75 mm at its maximum magnification ratio of 1:2, so its length is about what we would expect (give a little for the lens construction). If you want a flat pancake lens, cut some of the macro capabilities.
Extending the image distance
To give a standard lens some macro capabilities, a lens extension tube or a bellows can be used. An extension tube is basically an empty metal ring which is attached between lens and camera body, thus extending the image distance h. Extension tubes are available from some of the original lens manufacturers, such as Canon, Fujifilm, Hasselblad, Leica and Nikon, or third parties such as Kenko. In contrast to a close-up filter (i.e. a lens which decreases the focal length), an extension tube does not contain any optical elements and thus does not degrade the sharpness of the lens. Since the lens usually cannot be fully retracted any more with a lens extension tube in place, it is no longer possible to focus at infinity.
Effective focus distance
To see the effective minimum and maximum focus distances of your lens with an extension tube, use the extension tube calculator and enter the minimum focus distance (MFD) of the lens and a fairly large focus distance such as 1000 m, respectively.
For example, a 50 mm lens with a minimum focus distance of 0.3 m offers a magnification of 0.27. With a moderate extension tube of 12 mm, the effective minimum focus distance falls to about 0.22 m and the magnification almost doubles to 0.51. The effective maximum focus distance is at 0.32 m, with a magnification of 0.24. In other words, you can only focus on objects which are between 0.22 m and 0.32 m away from your sensor.
Note that the length of the extension tube that can be used in practice is limited as the effective focus distance may become shorter than the working distance of the lens.