Skip to content

Enabling the caption for a block with no title

Dan Allen edited this page May 24, 2013 · 1 revision

AsciiDoc (and the DocBook toolchain) only adds a caption (e.g., Example 1) to a block when the block has a title.

There are a few approaches to getting the caption without a title.

Approach #1: Use a blank title

You can trick AsciiDoc/DocBook into thinking the block has a title using the zero-width space character (which is aliased to the zwsp attribute).

.{zwsp}
====
example block content
====

This should appear as:

Example 1.
example block content

Approach #2: Use the title to output the caption

.{example-caption} {counter:example-number}.
====
example block content
====

This should also appear as:

Example 1.
example block content

Approach #3: Customize the backend template

The final option is to customize the template in the backend so that it always uses the caption even in the absence of a title.

These workarounds are necessary because you are working around the convention that a caption (e.g., Example 1) should only be used in the case when the block has a title.