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. |
CaptionsMarkdown and HTML (and MediaWiki etc.) support six heading levels, plain Latex supports up to seven named levels ( My point is, captions could use the lowest heading level already available ###### Caption
 or another level could be introduced for them, systematically: ####### Caption
 ContentsIn modern forum, blog and chat software and social websites, plain links are often automatically converted to informative “cards” by fetching metadata like title, author and cover image. Links to media files, audio and video recordings in particular, are also displayed with embedded playback controls. These can hardly be distinguished, conceptually, from traditional (floating) figures. I therefore suggest that implicit figures shall support any number and combination of links ( A single, complex figure:


Another single, complex figure:

Two simple figures:

 |
@Crissov Pandoc Markdown does not have a limit on header level. Additionally, many other formats don't either, and we want Pandoc Markdown to be (at least somewhat) interoperable with those. So that's a hard blocker to your proposal. |
It would be great to see support for figures as essentially wrappers that associate a caption with some content. Both HTML and JATS XML allow a fairly wide range of content inside their |
Just to collect some thoughts from reading the thread above and looking through some of the supported formats: There are two sorts of figures. One type is a floating captioned container, which would most easily have this type in Pandoc: -- Caption from Table could be removed.
data Block
= ...
| Figure Attr Caption CaptionPos FigureWidth [Block]
...
-- A Figure with [Table...] or [CodeBlock...] content could be a
-- captioned table or listing (for numbering or in output, if there
-- are separate captions for those elements).
-- Not sure how the Figure and Table Attrs would be handed in
-- HTML output in that case. Just use the Figure's? Or merge.
-- A Figure with [Plain [Image...]] content (or a Figure with
-- a sequence of those figures as content) could be a
-- gallery-type figure (the second kind).
-- Caption position is frequently customizable
data CaptionPos = CaptionBelow | CaptionAbove
-- The figure width is necessary for subfigures in many formats.
-- Handling it like Table columns (fractions of the enclosing
-- container width) should work.
data FigureWidth = FigureWidth Double | FigureWidthDefault Some support for this type of figure, that I know of:
The other type of figure is like an image gallery: either a single captioned image, or a sequence of captioned images that can be collectively captioned. (There are also grid versions, but the sequence version seems more popular). This has the type: -- Not sure if FigureWidth is desirable for Figure itself
-- in this version (Table doesn't have it).
data Block
= ...
| Figure Attr Caption CaptionPos FigureWidth Figures
...
-- The [Inline] is for alt text like Image has, but this could be Text
-- instead, since the caption can be put into Caption.
data Figures
= OneFigure Attr [Inline] Target
| Gallery [Subfigure]
-- Same remarks on [Inline] vs Text for the alt text apply here
data Subfigure = Subfigure Attr Caption CaptionPos FigureWidth [Inline] Target Some support for this type of figure:
The first (container) type has the advantage of expressiveness, but most writers that support figures would need to decide how to deal with unsupported The second (gallery) type has the advantage of not requiring the writers to come up with fallback strategies, certainly not as often. It's also a bit easier to deal with it (no detecting if a |
The second (gallery) version could be a grid, but I don't know how well that's supported in the outputs. Possibly support could be added with whatever native tables the output supported, if there wasn't native support for the grid version. |
To be precise/nitpicking, my understanding is that in html5 the figure/caption element is just a semantically tagged container (a block element), without any special formatting.
I think one confusion that we frequently deal with when converting between formats is when to focus on retaining semantics versus retaining presentation. I would almost always argue that semantics need to be preserved and visuals need to be adapted, but not familiar with too many formats.
So for me a figure is "a block element with an optional caption, possibly containing a series of these". It's hard to define without recursion.
However, in latex you frequently do not use subfigure (each block has it's own caption), but just lay out the sub-blocks and put the captions in a list textually, e.g. "(left) first image caption. (right) second image caption."
6 Sep 2020 00:27:03 Christian Despres <notifications@github.com>:
… The second (gallery) version could be a grid, but I don't know how well that's supported in the outputs. Possibly support could be added with whatever native tables the output supported, if there wasn't native support for the grid version.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub[#3177 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AAATX5Z25IZ6UGUTNGQ6FQ3SEK3KXANCNFSM4CTY6SUA]. [https://github.com/notifications/beacon/AAATX54TC7Y52U4AXFODOILSEK3KXA5CNFSM4CTY6SUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFD6QMNQ.gif]
|
That is my understanding of HTML5 figures as well.
From the spec. Both it and MDN mention that it can be (or usually is) used for content that can be moved elsewhere without affecting the main flow of a document, and is best referenced in the text with a label like "Figure 7" so it can be moved. That's how floats are used in LaTeX, though LaTeX is much happier to move floats around by default than web browsers are figures, and will automatically put "Table 3" or "Figure 2" in the caption for you. I also prefer the semantically cleaner container version of figures. Their recursive structure does mean that figures inside Pandoc may be nested more deeply than figures are allowed in the output, so it's important to know what extensions (LaTeX packages and the like) can be used in the outputs to deal with nested figures. |
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. |
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: