Tips and Tricks
Tips and Tricks #
Modify Spacing between Boxes #
Unfortunately for technical reasons, setting the spacing between boxes generated by peace-of-posters
has to be done manually with 3 distinct methods.
Suppose, we want to set the new spacing to 0.5em
from the default value of 1.2em
.
So let’s capture this in a variable.
#let box-spacing = 0.5em
First, we need to specify the spacing between blocks.
#set block(spacing: box-spacing)
Next, we also want to change the spacing between columns.
Thus we modify the gutter
argument of the columns
function.
#set columns(gutter: box-spacing)
Last but not least, we need to tell peace-of-posters
to use the new value when calculating how large boxes need to be in order to stretch them to the nearest endpoint.
#update-layout(
spacing: box-spacing,
)
Variable width of columns #
To create a document with different widths of columns, we can use two instances of a wrapper
box
.
View the output of this code here.
#grid(
gutter: pop.layout-a4.spacing,
columns: (2fr, 3fr),
box(width: 100%)[
#pop.column-box(heading: "Left Column")[This is a box on the left]
],
box(width: 100%)[
#pop.column-box(heading: "Right Column")[This is a bit bigger on the right]
],
box(width: 100%)[
#pop.column-box(heading: "Stretch it", stretch-to-next: true)[
This stretches all the way to the bottom of the page
]
],
)
#pop.bottom-box()[At the bottom]
Deeply modify Heading and Body Boxes #
In order to deeply modify heading and body boxes, we are able to change the function itself which draws the box. By default, these boxes are simply rectangles which are drawn with the specified options. We define a new function that takes the heading as a mandatory argument (or the body when changing the body funtion) and a range of arguments not more closely specified.
#let my-custom-heading(heading, ..args) = {
...
}
This function will now obtain all information that the default rect
function would be given as well.
We can choose to ignore the optional ..args
or reuse them if desired.
Let’s begin by simply making a smaller centered box.
#let my-custom-heading(heading, ..args) = {
align(center, rect(heading, ..args, width: 100% - 2em))
}
Afterwards, we need to supply the new behaviour to peace-of-posters
by setting the corresponding option in the layout.
#update-layout(
heading-box-function: my-custom-heading,
)