Customizing Figure Caption

classic Classic list List threaded Threaded
4 messages Options
ped
Reply | Threaded
Open this post in threaded view
|

Customizing Figure Caption

ped
This post was updated on .
Hello together

I have been using Asciidoctor for almost 1 week now and am totally thrilled. A great tool!!! I'm using the newest version 2.0.8 on Ruby 2.5.3

Despite intensive search in the web I have some questions to the following minimal example:

= Minimal Working Example
:doc-part: A
:figure-caption: Figure {doc-part}-
:xrefstyle: short

[#fig:{doc-part}:001]
[.center.text-center]
[title="This is the caption of the figure"]
image::https://avatars0.githubusercontent.com/u/1817009?s=400&v=4[float="center", align="center"]

Please see <<fig:{doc-part}:001>>

The result is:



1. How is it possible to remove the space between the A and the number? Should be: "Figure A-1".
2. How is it possible to change the period after the number to a colon? Should be: "Figure A-1: This is the caption of the figure".
3. The caption is not centered. Has anyone an idea why not?

I would be very happy if someone could answer any of the items.

ped

ped
Reply | Threaded
Open this post in threaded view
|

Re: Customizing Figure Caption

ped
This post was updated on .
After a week more experience with Asciidocotor, I came a little closer to solving my problem for question  1 and 2:

= Minimal Working Example
:xrefstyle: short

[#fig:001]
image::https://avatars0.githubusercontent.com/u/1817009?s=400&v=4[caption="Figure A-{counter:figure}", title=": This is the caption of the figure", align="center"]

Please see <<fig:001>>

It would be more customizable if there would be something like:

= Minimal Working Example
:figure-caption: Figure A-
:figure-separator: :
:xrefstyle: short

[#fig:001]
image::https://avatars0.githubusercontent.com/u/1817009?s=400&v=4[title="This is the caption of the figure", align="center"]

I also think that the terminology is somewhat unfavorable. Analogous to latex, I think the following name definition of the attributes would be better:

:figure-label: Figure    // Currently is :figure-caption:
:figure-separator: :     // Not existing yet

Caption is what is currently named under "title".



Reply | Threaded
Open this post in threaded view
|

Re: Customizing Figure Caption

stallio
This is a good workaround.

I've been using a similar workaround because I also need to include the chapter number/letter (A) in my figure numbers (A-1) but hadn't seen a way to get rid of that pesky space in the middle.

One tweak I would recommend is using the :doc-part: attribute from your first post instead of writing "A" directly into the caption. This way you can copy and paste the same caption in every chapter.

[caption="Figure {doc-part}-{counter:figure}", title=": This is the caption of the figure"]

I don't like the way that this inserts a colon at the beginning of the figure title, and was about to recommend moving the colon into the caption instead... when I realized that would mess up the cross references. There is a workaround for that too, if you really want:

[caption="Figure {doc-part}-{counter:figure}: ", reftext="Figure {doc-part}-{figure}", title="This is my caption"]


But now we're getting out of hand. What we really need are more options to configure the numbering itself, rather than manipulating the caption and label to fake it.

1. An option to include the chapter number/letter inside the figure number (see issues #702, 979).
2. Options for two separators: one inside the number (figure A-1 vs A.1), and one in between the number and the title (#1994).
ped
Reply | Threaded
Open this post in threaded view
|

Re: Customizing Figure Caption

ped
HI stellio

thank you very much for your answer. Your proposal

[caption="Figure {doc-part}-{counter:figure}: ", reftext="Figure {doc-part}-{figure}", title="This is my caption"]

is much better than my fake workaround.