Do people usually prefer to live close to their jobs? What if you put a garage nearby, will they live in the city if I build housing there?
For example, farmers, they are always building shacks. If I put a garage close to a farm will they live in the city?
People take into account the housing quality and the distance from their jobs. They may end up moving to a fancy mansion that's a little further away from their job if they can afford it, but if the only housing at all is on the other side of the island then they will prefer to build shacks near their job. You will need housing that's at least a little in the area of their job, but not necessarily right next to it. I don't think they take the presence of garages into account when calculating the distance, but don't quote me on that one.
Keep in mind that Tropicans don't really like moving. If they live in an apartment, and you build an apartment of equal quality that's closer to their job, they're probably not going to move. But an immigrant who gets the same job and needs a place to live will prefer the closer apartment. It's wise to kick everyone out of their homes once in a while to make them all look for a new one; this will make them re-consider their choice, so they might pick a more convenient place to live. An easy way of doing this is to set the rent in all your apartments to 50, wait until everyone is kicked out at once upon being unable to pay it, and then set it back to its normal level. If there is little time in between them being kicked out and the rent being lowered, they won't build any shacks in the process.