I'm trying to find a sensor that is similar to the ones used in floppy drives to determine the track 0.
It's an optical sensor with about 3-4mm of space between the emitter and the receiver so that it can detect if the beam is interrupted.
All parts I can find are pretty large elements but I am looking for something small and I don't know what name they may have
An example of such sensor is on the photo here, the black part:
Additional question: I have a box moving on rails and it has 5 positions; the range is about 1m, precision about 0.5cm. Are these sensors the best way to go?