Getting a 42mm chainline is a surprisingly tricky task. The problem is that most cranksets are made for either two or three rings with an expected chainline of 43.5 (meaning the inside ring is at 41 and the outside ring is at 46) or 45 (the position of the middle ring). So you either have to accept an imperfect chainline (41mm really is close enough) or tinker -- or find a crankset that is made to have a 42mm chainline with a single ring (most common with track cranksets).
The math is really simple though. Start by finding out what bottom bracket the crankset manufacturer recommends (not always an easy task) and what chainline they expect that to give you. Then make adjustments (different spindle length or spacers somewhere).
The canonical reference:
All About Bicycle Chainline