-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Explicit Figure element in Block #3177
Comments
Another advantage is that attributes could be added explicitly to the Div.
See #3094. |
Seconded, I just spent an hour figuring out why multiple images in a paragraph don't create a figure. Is there any way to create a figure with multiple images right now? (I guess creating Rawblocks will work?) Relevant code is here? https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/HTML.hs#L450 Why is the match only for one image and not multiple ones in the first place? |
If multiple images were allowed, which one would form the figure's caption? (There is only one caption.) What would determine how the images are arrayed in the figure? In retrospect, some kind of more explicit syntax for figures would have been desirable, and maybe that's the direction we should move in. |
Layout: Hm, I only use html and latex backends, but both of those handle multiple images in a figure in a reasonable way without extra specification. However, in latex IIRC it makes a difference if there is a SoftBreak between images (break vs. no break). IMHO it would be up to the writer/backend to break up figures if multiple images are not supported. Caption: None unless explicitely stated? That's legal in both html and latex iirc. However I believe Paras do not support extra data like attrs, so that a div or figure node would be easier. |
+++ Hauke Rehfeld [Oct 24 16 16:42 ]:
You can paste the images together into one image, I suppose,
Good question. I suppose that since I'm in a field where But how would it work to allow a paragraph with multiple Really we need a more explicit syntax for figures if this |
I think we need an explicit Block element for Figure. |
The question is whether this figure element should only contain images, or if it should be a general floating-container more analogous to the LaTeX
If so, the figure element should contains a caption (multiple paragraphs allowed) and arbitrary block content:
|
+++ Mauro Bieg [Feb 26 17 05:07 ]:
If so, the figure element should contains a caption (multiple
paragraphs allowed) and arbitrary block content:
Figure Attr [Block] [Block]
That's what I was thinking.
|
Development on |
Thinking about about explicit Markdown syntaxes for figures. If we had a native syntax for divs, we could treat any div with a following caption as a figure:
Another possibility would be to have a special kind of marking for figures, like:
I'm trying to avoid syntaxes that require you to use the word I like the |
TODO on
|
Having second thoughts about the type now. I suspect that allowing ANY kind of block content inside a figure is not going to work well in many output formats. E.g. in docbook, only certain elements are allowed inside a figure element. http://tdg.docbook.org/tdg/4.5/figure.html Perhaps instead the contents should be limited to a list of images (or perhaps a list of lists of images, so they can be organized on lines? -- though it may be better to let the layout happen automatically, given width information). Perhaps listings could go in figures as well? |
I think I'm going to remove this from the 2.0 milestone as it still needs more thought. |
I still think taking the most general approach in the AST makes sense. There are always going to be some formats that don't support certain things, but that should be handled by the respective writers and the AST design shouldn't be held up by those. It would be great to have a general block figure element to output to HTML/ePUB/LaTeX... |
Concerning the caption syntax, I kind of prefer the second one, since it is clearly placed inside the figure/div element. A third variant:
|
What kinds of things do people really put in figures, besides images? |
Maybe the element I have in mind is more of a Again the MDN extract posted above:
And from Wikibooks LaTeX/Floats:
Usually it's tables and images that are floated, but it could also be source code, a poem, some sort of aside box etc. Even Docbook has a sidebar element. Maybe the table AST element shouldn't have a caption, only the Summarizing, a
I think it would be great to have the figure type in the AST for pandoc 2.0. Writing the code for the writers and reference generators etc. can be done later. |
Yes, this is the big conceptual issue to decide. Whether to
have separate elements for (possibly floating) figures,
tables, and listings with captions, or to make all of
these non-floating and non-captioned, but add a container
element that makes them floating and adds a caption.
|
I'm leaning currently towards the second option (general float/caption container). Use cases include floating more than just images (e.g. float two tables that share a caption), or having one figure with a caption, that contains subfigures (or images) with each having a caption, e.g: It's probably true that it gets a bit trickier to consider all cases in all writers, but it is a more flexible option. |
The HTML writer currently has to deal with the fact that HTML headings only go up to So, eventually, the writers that have depth-limited figures and tables could keep track of the current figure depth. If they encounter too-deep nesting, they could convert the Initially, of course, every writer would need to fallback in this way, except for figures with |
See #6782 for important info on accessibility. |
Noting that #5994 depends on this. |
This was done in pandoc 3. |
Currently we represent figures in the AST using this hack: a figure is an
Image
whose title attribute starts withfig:
and which is by itself in aPara
.Short of a full-featured figure environment in the AST, it would make sense to move to a less hacky representation: a
Div
with classfigure
containing the image (which need not have a title starting withfig:
). This would involve changes to readers and writers.Indeed, if we did this, we could support figures containing multiple images, via explicit Divs.
The text was updated successfully, but these errors were encountered: