Skip to main content
Version: 0.5.x

Cover Function

As you already know, both uncover and #pause use the cover function to conceal content that is not visible. So, what exactly is the cover function here?

Default Cover Function: hide

The cover function is a method stored in s.methods.cover, which is later used by uncover and #pause.

The default cover function is the hide function. This function makes the internal content invisible without affecting the layout.

Updating the Cover Function

In some cases, you might want to use your own cover function. In that case, you can set your own cover function using:

config-methods(cover: (self: none, body) => hide(body))

hack: handle enum and list

You will find that the existing cover function cannot hide the mark of enum and list, refer to here, so you can hack:

config-methods(cover: (self: none, body) => box(scale(x: 0%, body)))

Semi-Transparent Cover Function

Touying supports a semi-transparent cover function, which can be enabled by adding:

config-methods(cover: utils.semi-transparent-cover.with(alpha: 85%))

You can adjust the transparency through the alpha: .. parameter.

Warning

Note that the transparent-cover here does not preserve text layout like hide does because it adds an extra layer of box, which may disrupt the original structure of the page.

Internals

The utils.semi-transparent-cover method is defined as:

#let semi-transparent-cover(self: none, constructor: rgb, alpha: 85%, body) = {
cover-with-rect(
fill: update-alpha(
constructor: constructor,
self.page.fill,
alpha,
),
body,
)
}

It creates a semi-transparent rectangular mask with the same color as the background to simulate the effect of transparent content. Here, constructor: rgb and alpha: 85% indicate the background color's construction function and transparency level, respectively.