I can add a dynamic page number reference to a particular bookmark by doing the following:
Insert → Cross-Reference
- Type → Bookmarks
- Insert Reference To → Page
My question is: How do I have the page number to have leading zeros, if necessary?
Eg.
1 → 001
10 → 010
999 → 999
Normally, I would right-click on the number, select "Numbers" then change the format, but it does not appear for cross-references.
答案1
As explained here, the only way is to add zeroes before the field. The following is a complex but automatic solution to do this.
As an example, enter "Bookmarked text" on page 15 of a document. On the same line, insert a page number field by going to Insert -> Page Number
.
Before the page number, we need to insert two fields, one for each of the possible zeroes. To do this, go to Insert -> Fields -> More Fields
or press Ctrl+F2. Under the Functions tab, with Type Conditional text
, enter the "Condition" as Page < 100
. Enter 0 for "Then" and leave "Else" empty. Now press Insert.
Now modify the condition to Page < 10
and press Insert again, to create the other possible zero. Then press Close.
Next, select the page number and the leading zeros fields. Go to Insert -> Bookmark
and give it a name. Also, go to Format -> Character
and under Font Effects, change the font color to white so that it doesn't show up when printed. (Changing the text to hidden will cause the page number not to be updated, so don't do that).
Finally, go to a different page and do Insert -> Cross-reference
to the bookmark we just created. The Type is Bookmarks
and Insert reference to Reference
.
For other bookmarks, the three fields (page number plus two conditional zeroes) can be copied and pasted.
Conditional text is explained here.