Referencing another page number

How do I associate the <$p> placeholder with a linked document? According to the information in the Scrivener Placeholders summary, with <$p> (page number) “when used in the main text and it has an internal document link associated with it, the <$p> placeholder will be replaced with the page number on which the linked document appears if possible”. I have guessed at formats that could make such an association but none of them work. These are a few examples of my failed attemps:
Try 1 - Page <$p><$n:figure:ChPedigreeEarliest>
Try 2 - Page <$p<$n:figure:ChPedigreeEarliest>>
Try 3 - Page <$p:<$n:figure:ChPedigreeEarliest>>
Try 4 - Page <$n:figure:ChPedigreeEarliest><$p>
Try 5 - Page <$p>figure:ChPedigreeEarliest
Try 6 - Page <$p:figure:ChPedigreeEarliest>
Try 7 - Page <$p:$n:figure:ChPedigreeEarliest>
Try 8 - Page <$p#figure:ChPedigreeEarliest>
Try 9 - Page <$p:$n#figure:ChPedigreeEarliest>
Can someone please suggest what format I should be using to achieve this association.

I think you can reference figures but not page numbers.

These replacements occur when Compiling to an output document. Have you been doing that in your tries? Until compiling, Scrivener knows pages nor pagenumbers…
Also check the Scrivener Manual from the Help menu: 10.1.4 Compiling Document Links

Yes, I have done the compile, but the results are meaningless. Here are some typical results from a test run. The output should read “Page 18”
Try 1 - Page XXX 1
Try 1 - Page <$p1>
Try 1 - Page <$p:1>
Try 2 - Page XXX $n:figure:ChPedigreeEarliest>
Try 3 - Page XXX 1
Try 4 - Page 1 XXX
Try 5 - Page XXX figure:ChPedigreeEarliest
Try 6 - Page <$p:figure:ChPedigreeEarliest>Try 6 - Page <$p:$n:figure:ChPedigreeEarliest>

That is not what the Scrivener Placeholders summary, says - see the words that I have quoted.

You don’t use a specific placeholder format or suffix or anything like that to accomplish the linking.

Rather, according to the manual, you enter the placeholder in your document, then highlight it and turn it into a document link, pointing it to the appropriate target document.

From 10.1.14:

Combining Links with Placeholders

An interesting capability you have at your disposal is combining these placeholders
with document links. When selecting a placeholder in its entirety and
linking to another document with it, the metadata will be extracted from the link
target rather than the item you typed the placeholder into. From our previous
example, if you select the <$modifiedDate> placeholder and link it to another
document, the modification date for the target will print in this section.

So try this: enter the <$p> page number placeholder into your source document, highlight and right-click it, select Link to Document and browse to your target document. Then cross your fingers and click Compile. :firecracker:

I’ve never done this, so no idea whether it works. I found it by searching the manual for “placeholder”. It’d be a pretty slick trick though if it does work. :nerd_face:


I’d have to try it and see, but $modifiedDate is a document property, and <$p> Is not.

Scratch that. There’s no way to try it, for the same reason.

Thanks JimRac and drmajorbob. I did try it without success. I think JimRac’s suggestion would only work if compiled output is to MultiMarkdown but I am outputting to docx (Word). Having tried it every which way, I have now officially given up. (I can still cross reference to an Illustration number, but would have also liked to also include the page number). But I think the Scrivener Placeholders instructions for <$p> should be amended to either delete the (false?) claim of functionality; or explain how to do it with an example.

I doubt that for the same reason as before. I see no reason a document link could convey something that isn’t a document property.

By the way, there is no difference between making these linked placeholders yourself, and the result you get from the Edit ▸ Copy Special ▸ Copy Documents as ToC. If that works, similar placeholders distributed wherever else in the text should also work. So that’s your working example if you want it.

There are some cases where it may not work as you would expect:

  • The format doesn’t support pagination as a file type. So no TXT, HTML, ePub or Markdown-based stuff (the latter may direct itself to a format that does pagination, like ODT, but Scrivener isn’t going to be aware of that, and there would be zero reason to use Scrivener’s approach to cross-referencing anyway, since MMD and Pandoc fully support cross-referencing to a detail greater than what Scrivener can do, and with better results in general).
  • The format supports it, but page references are a kind of cross-reference, formatted to display the page number alone. Just like in any system you’ve got to have something to point to if you’re going to reference it. This ordinarily won’t be an issue since the default built-in Formats all include these necessary anchors, but customised settings may not. To double-check for those that aren’t working:
    1. Click on the hyperlinked placeholder to navigate to the target and check its Section Type in the inspector.
    2. Open up the compiler and locate the Layout being used for that type of item in the preview column. Double-click to edit it.
    3. In Section Layouts, under the Settings pane, ensure Include in RTF Bookmarks is ticked.
  • For the same reason, if the section itself that you’re linking to is omitted from the compile group for any reason, it won’t work—but that’s to be expected.

Having tried it every which way, I have now officially given up. (I can still cross reference to an Illustration number, but would have also liked to also include the page number).

Given that Scrivener itself can only insert bookmarks at the top edge of the section, this would require a point of clarification: is your illustration somewhere in the middle of a long section of text, or is it in its own binder section? If it’s the latter, definitely check to make sure it is inserting a bookmark, because I can’t think why that wouldn’t work.

It would also help to know what “not working” means, specifically.

Huh. That blows my theory out of the water, since those page numbers work and aren’t document properties. Or are they, being the first page in the document?

Extracting document properties remotely does represent the majority of the functionality, but in addition to page numbers there are a few other placeholders that work with links, such as <$include>, <$linkID> and some auto-numbering placeholders. I suppose in a very vague way we could consider those to be properties.