English is a flexible and subtle language, which is why it can be so exasperating for non-native speakers.
Both your examples are fine - in the context in which they are used. They are acceptable and comprehensible. We would understand that the person is both
at and
within the library.