move caption setting to AtBeginDocument