Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown reader: use title of implicit figure as short caption. #8617

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Feb 13, 2023

The title of an implicit figure, if set, is used as the short caption of
a figure. The short caption of a figure replaces the full caption in the
list of figures.

Closes: #7915

The title of an implicit figure, if set, is used as the short caption of
a figure. The short caption of a figure replaces the full caption in the
list of figures.

Closes: jgm#7915
@jgm
Copy link
Owner

jgm commented Feb 13, 2023

I think my main question is still the one raised in #7915 -- what if formatting or math is needed in the short caption?

One approach to this would be to parse the title as markdown.

@tarleb
Copy link
Collaborator Author

tarleb commented Feb 13, 2023

Another thought: The title could also be used as the image's alt text. This would be more consistent with the fact that titles cannot contain markup. I'd give accessibility higher priority than convenience for short captions, and this could be a good way to specify a description that differs from the figure caption. OTOH, it might be confusing to have implicit figures and normal images behave so differently.

@jgm
Copy link
Owner

jgm commented Feb 13, 2023

Yes, I agree both that this makes sense and that it's probably too confusing to have implicit figures and normal images behave differently.

We can still specify alt text using an attribute, no?

![the caption](file.jpg){alt="My alt text"}

@jgm
Copy link
Owner

jgm commented Feb 13, 2023

I suppose one alternative to overloading the title would be to allow a short caption to be specified via an attribute:

![the caption](file.jpg){shortcaption="My short caption"}

Drawback: English keyword. Drawback: no formatting.

@tarleb
Copy link
Collaborator Author

tarleb commented Feb 13, 2023

Am I right in thinking that pandoc currently only has special treatment for English keywords in the writers, but not the Markdown reader? It might be a dangerous precedent.

Would it make sense to support the table caption syntax on images?

![Close-up shot of the colorful face of a male mandrill.](mandrill.jpg)

: A male mandrill

Then the problem would become the more general issue of how to add short captions with that syntax. I guess the downside is that this is ambiguous syntax that could also be intended to mark a description list with an image term?

@jgm
Copy link
Owner

jgm commented Feb 13, 2023

Hm, that does make a lot of sense. I agree that it's ambiguous, and that's a strike against it, but it is still tempting, and how common is it to use a definition list with an image term?

I would suggest that if we did this, then when this explicit caption is present, the image description should be the short caption, and the thing after : should be the long caption (since here we can include block-level content).

@tarleb
Copy link
Collaborator Author

tarleb commented Feb 13, 2023

If we could find a way to specify the short caption by extending the long caption syntax, then we could use that with tables as well. E.g., something like

![alt](a.png)

:short caption:
    long caption.

or, inspired by org-mode description lists,

![alt](a.png)

: short caption :: long caption.

Fuller example:

![The colorful face of a male mandrill.](mandrill.jpg)

: "Mandrill" test image :: The "Mandrill" standard test image, sometimes
  erroneously called "Baboon", is a popular sample photo used in image
  processing research.

Maybe this could also open a path towards more general, multi-image figures, but I don't know yet how that might look like.

@jgm
Copy link
Owner

jgm commented Feb 14, 2023

: "Mandrill" test image :: The "Mandrill" standard test image, sometimes
  erroneously called "Baboon", is a popular sample photo used in image
  processing research.

That's not bad, actually!

@acxz
Copy link
Contributor

acxz commented Nov 23, 2024

Hello, I've taken an interest in the short/long caption issue. (Although I might not be able to devote time in solving it...)

: "Mandrill" test image :: The "Mandrill" standard test image, sometimes
  erroneously called "Baboon", is a popular sample photo used in image
  processing research.

Would this solve the problem of having specific formatting in the short caption?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use markdown image title text when generating list of figures
3 participants