+1
When would you say:

1. He is in the library.

2. He is at the library.
Comments  
1. He is in the library. Used when you want to mean that he's really inside the library, say that he's sitting and reading there.

2. He is at the library. He is in or just outside the library. You're using this when you want to position the person within the city, the area, looking at it generally from some distance.
If I know that the person is currently inside the library but I am far away from the library (let's say a few miles away), should I use 'in' or 'at'?

I'll prefer to use 'in' just to be precise. Is this a good choice?
Teachers: We supply a list of EFL job vacancies
As long as the person is inside the library, then 'in' will always be ok, where you are is irrelevant.
Very well Marius and Nona!! Thanks for your clarity!

How about this analysis...see if it makes sense please:

If the library is a separate building, we can use AT or IN as Nona and Marius explained depending on our purpose - general location or exact location being inside, for example, not outside.

However, if the library is inside a high school, or an institute, we always use "in". We use "in" because it is like saying:

- She is in class (a room inside this building). = She is in the library (the library is inside the school itself). The library here is similar to a room inside a building even if it's very big.

What do you think of my additional analysis of "in" and "at" the library?
Another question:

in prison vs. at prison ?

in the hospital vs. at the hospital ?

Does "in" here mean a prisoner and a patient respectively whereas "at" a visitor of a prison and a visitor of a hospital respectively?
Students: We have free audio pronunciation exercises.
in hospital means a patient , not in the hopital.
Teacher S.

he is in the library