This article is from the Star Trek Tech FAQ, by Joshua Bell inexorabletash@hotmail.com with numerous contributions by others.
The simplest answer is that the Holodeck "compartmentalizes", in
effect becoming a separate Holodeck for each person within it. In
reality, the two people would probably be only a few meters apart, but
would be separated by a Holodeck-projected "wall". If they turned to
look at each other, they would see an image of the other projected on
that wall.
Benjamin Chee points out that Star Trek: Generations strongly supports
this notion; whilst on the simulation of the seagoing Enterprise,
Picard calls for the Holodeck arch and it appears on the ship's deck.
But earlier, Worf and Crusher were sent overboard, below the level of
the ship's deck and therefore below the floor of the Holodeck, unless
the holodeck does compartmentalize to some degree.
 
Continue to: