The mdbook-figure preprocessor
This preprocessor allows you to define figures with a label, an optional type, a description, and contents.
Quick Start
To get started, install the preprocessor:
cargo install mdbook-figure
and add it to your book.toml:
[book]
[preprocessor.figure]
# If you're also using `mdbook-xref`, you must use the correct ordering:
before = [ "xref" ]
Defining figures
Defining figures is done as follows:
```figure a-label Optional Type
The first line is the description of the figure
<center>
The rest describes its contents, which are rendered as
**markdown** _in_ `the` final document.
</center>
```
which renders as
markdown in the final document.
The figures are numbered by type and order in the book.
These figures can be referred to by their label using the mdbook-xref preprocessor. In this case, we can refer to ref:a-label, or Table 1.
Autodetection
If the type of the figure is not specified, it defaults to “Figure”. However, the type is automatically inferred for some content, so long as that content immediately follows the description.
Currently, only “Table” is supported:
```figure a-table
a very fancy table
| Column 1 | Column 2 |
| :------- | :------- |
| Value1 | Value2 |
```
which renders as
| Column 1 | Column 2 |
|---|---|
| Value1 | Value2 |
and is referred to as Table 1