In this article, you’ll learn how to use constraints by creating flexible versions of two common design elements: captioned pictures and pull-quotes that integrate decorative objects.
Let’s start with captioned pictures. A publication might have a rule of thumb about how they are presented—not just a caption’s text formatting but its typical position and size relative to its picture frame, too. Constraints enable you to codify these rules to ensure consistency.
To begin, download and extract the practice files.
A problem of proportion
From the practice files, open Example 1.afpub. On its first page is a group that contains a picture frame and a text frame, which span four column guides.
- Duplicate the group in the same position on the second page.
- With the new group selected, resize it—maintaining its proportions—to span all nine column guides.
Compare the two groups side by side. The width and height of everything in the second group has resized proportionally. As the group gets larger, an undesirable amount of space is introduced above and below the framed text.
At this size, any caption will likely fit on a single line. So, it would be better if the text frame didn’t grow taller.
Undo the size transformation, and keep this document open.
A problem of position
Open Example 2.afpub. It contains a similar layer structure to the first document, but the caption is presented differently.
Like before, make a duplicate of the group at the same position on the second page, and then size the new group—maintaining its proportions—to span all nine column guides.
The problem with this design is a little subtler. Notice that the caption’s distance from the picture frame’s left and bottom edges increases in proportion to the group’s dimensions. The effect is more pronounced—and more clearly ‘wrong’—if you change the group’s aspect ratio.
Again, undo the size transformation.
The problems you’ve seen can be fixed with constraints, so let’s take a look at the Constraints Panel.
Understanding the Constraints Panel
Select View > Studio > Constraints to show the Constraints Panel.
Switch back to Example 1.afpub, and then select the text frame on the second page. The Constraints Panel displays this read-out:
The inner square represents the selected object, and the outer square represents the group that contains the selected object.
The lines within the inner square determine how the selected object’s width and height change in proportion to the respective dimension of the containing group (the default), or if the object’s width/height is fixed.
The lines between the two squares determine whether the object maintains a proportional distance from the respective edge of its containing group as the group’s dimensions change (the default behaviour), or if the distance from each edge is fixed.
Subtly different read-outs, same effect
Note that if you set an object’s width, say, to be fixed and then anchor it to its containing group’s left and right edges, the anchor constraints take precedence. The line for the object’s width remains dashed but becomes white.
Clearing either of the anchor constraints will set the object’s width back to your previous, explicitly chosen behaviour.
Let’s fix the problems
The problem in Example 2.afpub is simpler to fix, so let’s start there.
We want the text frame to remain the same distance from the group’s left and bottom edges regardless of the group’s dimensions.
- Select the text frame on the second page.
- On the Constraints Panel, click the left and bottom anchor lines so they become solid and white.
- Select the group on the right page, hold Shift to resize proportionally, and use the group’s handles to resize it to span all nine column guides.
Notice that at all times during resizing, the text frame remains a fixed distance from the left and bottom of the group.
A more challenging scenario
In Example 1.afpub, we want the text frame to have a fixed height.
- Select the text frame on the second page.
- On the Constraints Panel, set the vertical line in the inner square so it is dimmed and dashed.
- Select the group on the right page, hold Shift, and resize the group to span all nine column guides.
The text frame maintains its height but there’s a new problem: as the group grows larger, gaps appear above and below the text frame.
Some additional constraints are needed so the bottom edges of the text frame and group remain aligned.
- Undo the size change.
- Select the text frame.
- On the Constraints Panel, click the line below the inner square so it becomes solid and white.
- Resize the group proportionally to span all nine column guides.
The text frame’s position is correct. All the unwanted space is now above it, and we’ll fill that space by allowing the picture frame’s height to change.
- Undo the size change.
- Select the picture frame.
- On the Constraints Panel, click the top and bottom anchor lines so they become solid and white.
- Resize the group proportionally to span all nine column guides once more.
Now the bottom edge of the picture frame and the top edge of the text frame stay together.
Note that when the group is resized proportionally, the picture frame’s aspect ratio changes slightly. You have a choice of adjusting the group’s height to compensate, or simply adjusting the frame’s contents to hide any unwanted details that might have crept into view.
Let’s constrain a pull-quote
Pull-quotes are often presented simply as multi-line text at a large point size. Sometimes, though, they may include secondary objects as decoration and to introduce white space.
Open Example 3.afpub. The pull-quote on its first page is three ungrouped objects. Extending its text to five lines would require that you move the secondary objects manually afterwards.
- Select all three objects and group them.
- Increase the group’s height so it contains five lines of filler text.
The secondary objects become vertically stretched, and the distances between them and the text frame are increased.
- Undo the resize operation, and then select the upper secondary object.
- Anchor the object to the top of its group, and set its height to be fixed.
- Select the lower secondary object.
- Anchor the object to the bottom of its group, and set its height to be fixed.
- Increase the group’s height again.
You’ve fixed the size and position of the secondary objects, but the distance between them and the text frame still increases as the group is made taller. The problem lies with the text frame’s constraints.
- Undo the resize operation, and then select the text frame.
- Anchor the frame to the top and bottom edges of its group.
- One last time, increase the group’s height.
That’s it. Job done!
Think about other elements in your documents that would benefit from this kind of flexibility.
You’ve learned the fundamentals of constraints, though there is more to them. We’ve kept things simple by mostly scaling design elements proportionally or along one axis.
We haven’t discussed the icons near the bottom right of the outer square on the Constraints Panel. They determine how an object changes when the aspect ratio of its containing group is altered. Learn about them in Affinity Publisher’s Help system, in-app and online.