3.2 Labels and captions

To set labels and captions, wrap your object in Options:

function options_example()
    df = DataFrame(A=[1], B=[2], C=[3])
    caption = "My DataFrame."
    label = "foo"
    return Options(df; caption, label)
end
BooksDocs.options_example()
Table 5: My DataFrame.
A B C
1 2 3

which can be referred to with

@tbl:foo

Table 5

It is also possible to pass only a caption or a label. This package will attempt to infer missing information from the path, caption or label when possible:

julia> Books.caption_label("foo_bar()", missing, missing)
(caption = "Foo bar.", label = "foo_bar")

julia> Books.caption_label("foo_bar()", "My caption.", missing)
(caption = "My caption.", label = "foo_bar")

julia> Books.caption_label("foo_bar()", "My caption.", nothing)
(caption = "My caption.", label = nothing)

julia> Books.caption_label(missing, "My caption.", missing)
(caption = "My caption.", label = nothing)

julia> Books.caption_label(missing, missing, "my_label")
(caption = "My label.", label = "my_label")

julia> Books.caption_label(missing, missing, missing)
(caption = nothing, label = nothing)


CC BY-NC-SA 4.0 Rik Huijzer, and contributors