Using inversion in the following sentence: I only realized what

Using inversion in the following sentence: I only realized what trouble he was in when I heard his voice trembling.
【正确答案】:Only when I heard his voice trembling did I realize what trouble he was in.
【题目解析】:参考教材P340