Conditional Content

In some cases you may want to create content that only displays for a given output format (or only displays when not rendering to a format). You can accomplish this by creating divs with the .content-visible and .content-hidden classes.

.content-visible

To make content visible only for a given format, create a div (:::) with the .content-visible class. For example, here we mark content as only visible in HTML:

::: {.content-visible when-format="html"}

Will only appear in HTML.

:::

You can also mark content as visible for all formats except a specified format. For example:

::: {.content-visible unless-format="pdf"}

Will not appear in PDF.

:::

Then when-format and unless-format attributes match the current Pandoc output format with some additional intelligence to alias related formats (e.g. html, html4, and html5). Details are provided below in Format Matching

.content-hidden

To prevent content from being displayed when rendering to a given format, create a div (:::) with the .content-hidden class. For example, here we mark content as hidden in HTML:

::: {.content-hidden when-format="html"}

Will not appear in HTML.

:::

You can also mark content as hidden for all formats except a specified format. For example:

::: {.content-visible unless-format="pdf"}

Will only appear in PDF.

:::

Format Matching

Then when-format and unless-format clauses do some aliasing of related formats to make it more straightforward to target content. The following aliases are implemented:

Alias Formats
latex latex, pdf
pdf latex, pdf
epub epub*
html html*, epub*, revealjs
markdown markdown*, commonmark*, gfm, markua