move caption setting AtBeginDocument