Transforming figure & caption output on compile

The filter option in compiling is going to work for some of what I want to do in preparing a text for a publisher, but can I couple it with a replacement and add it to an external file for each instance? An explanation of what I’m trying to do could help.
I’m working on a book with multiple chapters and figures. When I write in Scrivener, I add a link to a figure and write its caption, using the Caption style… For compiling for the publisher, I need to remove the figures and captions and put them in separate files. The figures are pretty easy, but how could I do that with the captions? And how could I compile so that a text is put in the place of the figure and caption that states something like “Insert Ch1-Fig1 about here”?
I am trying to keep this simple and straightforward, but let me know if I got too complex or I am missing the obvious.

Thanks in advance,

One step you could take along the path you have chosen would be to specify in your Compile format that things that have the Caption style should disappear. See: [edit compile format] > Styles > select the ‘Caption’ style > enable Delete Text of This Style option. Onviously this only accomplishes part of what you need.


P.S. I’m not sure what the absolutely most efficient way to do the whole business would be but, I suppose “formatting” captions and figures into your book though the publisher does not want this (but wants something elses in its place) must certainly be complicating your mission. I assume you are going to this extra trouble because you want your project to have the included figures and captions for personal reasons (so you could compile your own feature-complete copy or something).

Writing to Specifications

Yeah, there might be something to be said for not using Scrivener like a word processor here, and instead writing the material the way the publisher has requested.

What you can do to make things easier on yourself is store each figure item in a folder outside of the Draft, and then create a hyperlink from the “Insert Ch1-Fig1 about here” text in the editor to that file. Since the file won’t be compiled, Scrivener will ignore the hyperlink even if you use them otherwise for cross-referencing. The hyperlink is purely for your convenience: click on it to view the image in the other editor split. Meanwhile with a folder of figures all ready to go, you can bulk select the contents and use File/Export/Files... to get them out in a format the publisher requires, one file per figure.

Building a Flexible Workflow

If you really want proofing copies that have the figures inline with their captions, there are other approaches you could take that would involve a little more preparation. For example you could use the <$include:Ch1-Fig1> placeholder to inject the figure and its caption into the main document during compile. This would be placed within an inline annotation, so that you can switch annotations off in the compiler, stripping the placeholder (and thus the injected content) from production output.

I’ve attached a simple example of what I’m getting at here:

  • In the “Image Test” document we have two separate insertions.
  • I’ve created a style called “Publisher Instructions”, and that is drawing the blue highlight you see around the placement hints in the editor.
  • After that is an inline annotation (set to black so the caption doesn’t end up red or whatever) containing a placeholder that will insert the figure document into the text at this location. We use a hyperlink on the placeholder to link it to the figure item we want to insert from the binder. This keeps your text agile—if you need to rename a figure you need only do so from the title of the item itself in the binder.
  • Along that vein, a method I would recommend is demonstrated in the second example: I use a hyperlinked <$title> token, which is pulling the text it prints here from the binder title of the linked item (Ch1-Fig2).
  • In the compiler there are two Formats set up. The main thing they do is set inline annotations to print inline instead of in the margins of a word processor, and to not print any “[ … ]” apparatus around them.

To test this project:

  1. Open File/Compile..., and first just run a test compile using the settings I’ve provided. This will be the copy your publisher sees. I made the “Publisher Instructions” style colour the text blue, for clarity. You can customise that in the “Production Output” compile format’s Styles pane.
  2. To switch to a proofing workflow:
    1. Open File/Compile....
    2. Switch the active Format to “Proofing Output” in the left column. This will delete the Publisher Instructions text from the output (that is the only difference between these two simple examples).
    3. In the General Options tab on the right hand side, disable the Remove annotations setting.
    4. Compile.

As with the first suggestion, you would also export the folder of figure items for the publisher along with compiling with the production output settings and inline annotations stripped.

Why are we using inline annotations instead of Replacements to delete the <$include> placeholder? Those run too early in the compile process for Replacements to ever see them. They thus cannot be removed or modified by the compiler. Annotations are a useful way to include “meta document” information inline with the text. You could maybe even simplify this workflow by doing away with the include placeholder and putting the figure and caption in the inline annotation—but then you’d run into the difficulty of having to work backwards from that point and somehow export each figure+caption into a separate file. So I think ultimately for what you are doing, the include method will work best. (138 KB)