Caption of image

This could be accomplished with some creative use of Scrivener’s placeholder and replacement system. Images can be referred to with placeholders, such as in the following example, where the image is named “Libraries of the World” in the Binder:

<$img:Libraries of the World>

We can make things easier for ourselves with Compile Replacements. These are basically just search and replace directives that run during compile, without altering the original text. One thing they can do is “capture” variable text and then use that text in the replacement value. Here is an example that would ease typing in the above:

Replace: <$@>
With: <$img:$@>

The $@ is special, it means Scrivener should just start storing text as it scans to the right, until it finds the character following—in this case, >. We can then use that same token to print whatever was stored in the replacement. <Salt Mines> becomes <$img:Salt Mines> when you compile, which in turn triggers Scrivener to look for a picture named “Salt Mines” in the Binder and insert the first one it finds by that name into the text.

Now all you have to do is extend that principle further to also print a caption. Using the above Replace string, we can alter the With string to:

<$img:$@>
Fig. <$n:figure>. $@

When compiled, this will result in:


Fig. 2. Salt Mines

If you don’t want them numbered, you can just put “$@” on the second line by itself (hint, you can just copy and paste into the With field, but if you want to type it in, hold down the Option key when pressing Return to insert a carriage return).

Some things of note:

  • Images and their captions will take on whatever formatting you use on the placeholder in the editor. So if you want italicised captions, make sure to italicise (and probably centre-align) the placeholder.
  • The numbering token as I provided it will count figure numbering separately from anything else. So if you are using the ‘n’ counter for chapter numbers or something, it will not conflict.
  • For your custom replacement code, make sure to use something that will not otherwise be used in an image name, for the terminator after the $@ code. For example if you for whatever reason use “>” in an image caption then you should choose something else to enclose the image name—or of course if this pattern is used elsewhere in your writing.

Image source Wikipedia. en.wikipedia.org/wiki/File:Slanic_Salt_Mine.jpg