You can automatically generate a directory by referencing it and then selecting Auto Directory.
Step 1: Select the title content, click the Start menu and set the format of the title content, such as title 1.
Step 2: Click Reference-Directory, and then select Auto Directory 1 or Auto Directory 2.
Step 3: The generation is successful.