私が図書館に着いたとき彼女は5時間も勉強していた、を英訳すると「私が着いたとき」=過去、「彼女が5時間勉強していた」=大過去。さらに「勉強していた」は過去進行形と考えて、
She had been studying for 5 hours when I had arrived in library.
間違っているのでしょうか?
She had been studying for 5 hours when I had arrived in library.
She had been studying for 5 hours by the time I arrived at the library.
私が図書館に着いたとき彼女は5時間も勉強していた
She had been studying for 5 hours when I had arrived in library.
She had been studying for 5 hours when I had arrived は大丈夫です。
in library -> at the library か I arrived at the library
I had arrived at the library or I arrived at the library
arrived at the library のほうが natural だと思います。
She had been studying for 5 hours when I arrived at the library.
さらに when -> by the time
She had been studying for 5 hours by the time I arrived at the library.
By the time I arrived at the library, she had been studying for 5 hours.