Skip to main content
We no longer support Internet Explorer. Please upgrade your browser to improve your experience. Find out more.

Create and export variations of a document with ease using Affinity’s layer states

Layer states allow you to instantly set the visibility of multiple layers in a document, either to a previously captured state or by specifying criteria that layers must match to be affected.

The latter type of layer state is called a query. Queries can identify layers that match any combination of layer tag, type, name and lock status.

You could use a query to instantly hide all layers tagged red to ensure they’re excluded from output. Or, you might use a query to toggle the visibility of all adjustments and live filters for an instant before-and-after comparison.

Queries can select objects too. If you create document templates, you might use a query to select all image layers you’ve tagged grey to indicate they should be removed before distribution, for example, and then delete them all with a key press.

These are just a few example applications. There are other ways you can use queries to improve your workflow.

Here, we’ll explore how you can use them to build and output multiple deliverables from a single Affinity document, helping to smooth the process of working through clients’ revisions.

Creating queries

Queries are created and managed on the States Panel, which is available via the Window menu.

This query uses a regular expression to find layers that end with a specific word.

At any time, you can show, hide or select all layers that match a query’s criteria with a single click.

The States panel is also where you manage captured states. A captured state affects only layers that existed when it was created. A query affects all layers, including those added after the query was created.

Our example document

We’ll demonstrate queries using this 23-page golf course brochure in Affinity Publisher, but note that the feature is available in Affinity Designer and Affinity Photo too.

All the pages of our brochure's initial design.

Our client has approved the design and commissioned the following deliverables:

  • English versions for each of its three golf courses, with some text and images being course-specific.
  • Translations in French, German, Spanish and Japanese.

Ordinarily, you might create a separate Affinity document for each deliverable. However, even if good practice is followed—using Affinity features such as text styles and global colours—certain types of change would have to be repeated in all the documents.

Our brochure's cover, exported for multiple golf courses and languages.

Alternatively, we can create all brochure variations in one Affinity document, follow a consistent layer naming convention, and use queries to quickly switch to any variation of the document. Revisions to common design elements then only have to be performed once.

Here’s the layer stack for the first pair of facing pages in our initial document.

Pages 2 and 3 of our brochure, and their layer stack when the brochure is for a single golf course.

On this spread, the layers that will differ between deliverables are:

  • The course description
  • The largest photo
  • The driving range and restaurant photos at the lower right.

Everything else on the spread is the same for all deliverables.

The spread's reorganised layer stack after adding image and text layers for multiple golf courses.

Here’s how the layer stack looks after adding content for all three courses. For each course-specific design element, we have:

  • Duplicated its layer, so there’s a copy for each golf course.
  • Replaced each new layer’s content with course-specific text or imagery.
  • Named each of these layers after its related course.
  • Grouped layers by design element so the document is easy to navigate.

Switching between variations

Next, we’ve created one query for each golf course. As long as Scope at the bottom of the States Panel is set appropriately, we can switch between course variations of the document in just three clicks!

Each of the three queries we've created matches layers solely by layer name.

The queries are almost identical. They all ignore layer tags, types and lock status. For our purpose, we only need to inspect layer names, so each query’s layer name criterion contains a different course name.

Regular expressions

You may be wondering why we’ve typed additional characters–(?i)—in front of the course names in the queries.

They relate to the Regular expressions setting, which we’ve enabled. When the setting is disabled, Affinity considers a layer’s name to be a match if it is literally what you’ve typed in the box.

Regular expressions allow Affinity to match layer names to a pattern, i.e. a specification.

The additional characters we’ve included tell Affinity to ignore the case of letters. So, it won’t matter if we’ve mistyped a layer name all in lower case—for example, description shetland—or starting with two upper-case letters—MAplewood), say.

Care is still needed to avoid outright misspellings, though.

Trying it out

Having set up all three queries, we can click Hide—the struckthrough eye—on two of them and Show—the open eye—on the other to view a different course’s layers.

Each query has Hide and Show buttons, as highlighted here, that set the visibility of matching layers.

With the groundwork laid, the earlier work of adding and organising layers for each golf course needs to be repeated for the document’s other pages.

While doing so, we ran into a problem on the brochure’s back page. It contains a location line with all three golf course names, which has been automatically named using the start of the text.

The selected layer would be unintentionally affected by our queries.

Currently, our queries can cause this layer to be unintentionally hidden.

One way to deal with this is to manually name the problematic layer, e.g. Location Line. That would work but isn’t a scalable solution for documents that contain many auto-named text layers. It’s better to make a small change to the naming of layers we want to affect.

So, course names are now preceded by a hyphen, and we’ve updated our queries accordingly. This character sequence is unlikely to occur in auto-generated layer names.

Consider possibilities like this when devising your own naming convention.

We've revised layer names and updated our queries to be more precise, excluding unintentional matches.

Let’s go multilingual

We can continue with this approach to handle the client’s request for brochures in additional languages.

Much like we did for each golf course, we’ve created duplicates of this spread’s text and image layers.

Where your design allows for it, grouping layers can reduce the number of layers that need to be named to work with queries.

For each language, we’ve appended a hyphen and a short country code to each layer group’s name, e.g. -FR for French layers and -JA for Japanese.

Here’s the query we’ve created to toggle French text layers.

Each of our language-related queries is very similar to the one shown above.

The dollar sign at the end of our regular expression tells Affinity to match layer names that end with the specified pattern. Layer names that coincidentally contain the same characters—in an earlier hyphenated word, for example—will be ignored.

We’ve repeated this for all pages and created a query for each language. Toggling between document variations requires a few more clicks than before in order to show content for only one golf course and one language.

Even so, the organisational work we’ve done will make revision rounds from the client easier to handle.


Learn more about layer states

Bear in mind that we’ve shown just one scenario for using layer states. The feature can help out in many other ways. These tutorials cover some further use cases in Affinity Publisher, Photo and Designer.

Discover how to capture layer visibility states and select, hide and show layers based on criteria such as layer name, colour tag and layer type in Affinity Publisher.
Learn how to toggle layer visibility using manually created layer states and queries, which allow you to filter layers by colour tag, type, name and more in Affinity Photo.
Discover how you can use layer states to select, show and hide layers based on criteria such as layer type and name, including the use of Regular Expressions for more advanced filtering in Affinity Designer.

It’s also worth noting that we’re working on further improvements to layer states to make the feature even better.


Technical author

Alan is part of our technical authoring team and joined us from the world of magazines (MacUser), where he wrote up software techniques and worked on pioneering interactive digital editions. When he’s not neck-deep in page layouts, layer masks and adjustment layers, you’ll often find him digging through second-hand records for interesting sleeve artwork or gazing in wonderment at the graphical variety of Japanese video games.