Skip to content

Figure caption should always appear on the same page as the figure itself #2109

Closed

Description

@Andrew15-5

Description

I've added a figure about a 3rd of the page's available height. The figure is added at the bottom of the page, but its caption is shown as the first line on the next page, which is ridiculous. I know that there are LaTeX packages that prevent some parts of the document to appear on different pages, but I thought that in Typst this is already enabled by default. Apparently not.

If the caption can't fit on the page, then the whole figure should be shown on the next page. One thing I don't know, is that what if the figure is so tall, that caption would never be able to appear on the same page. Maybe make an exception and only in this case place caption on the next page, or make a compiler error, that caption doesn't fit or make a boolean switch that handles this separation rules.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Sep 11, 2023
  2. freundTech commented on Sep 11, 2023

    @freundTech
    Contributor

    I can't reproduce this. For me the whole figure including caption moves down a page if it gets too big.
    Do you by any chance have set #show figure: set block(breakable: true) or something similar?

  3. Andrew15-5 commented on Sep 11, 2023

    @Andrew15-5
    ContributorAuthor

    Oh, yes, you can say that:

    #show figure.where(kind: image): it => align(center)[
      #it.body
      Рисунок #it.counter.display(). #it.caption
    ]

    I couldn't get rid of the : in the caption, so I did this thing. But documentation doesn't say what is the default #show rule value for each element. So I probably guessed wrong. How to replicate the default look of the figure (for images)?

  4. laurmaedje commented on Sep 11, 2023

    @laurmaedje
    Member

    There is actually a section about this for figures here, but it suffers from the exact same problem. A block should be added there.

  5. freundTech commented on Sep 11, 2023

    @freundTech
    Contributor

    This show rule seems to exactly reproduce the built-in figures:

    #show figure: it => align(center, block(breakable: false)[
      #it.body
      #set block(above: 0.65em)
      #it.supplement #it.counter.display(): #it.caption
    ])

    At least visually. I can't prevent the caption line from being wrapped in another implicit block, which is not there in the original source, so instead of a v(0.65em) I just set block(above: 0.65em)

  6. Andrew15-5 commented on Sep 11, 2023

    @Andrew15-5
    ContributorAuthor

    I don't get why Typst have to complicate things with numbering. In the doc, it says to add it.numbering inside the display(). Shouldn't it be the default behavior? At least in this show rule:

    #show figure: it => align(center, block(breakable: false)[
      #it.body
      #set block(above: 0.65em)
      #it.supplement #it.counter.display(): #it.caption
    ])

    @freundTech, thanks, I was using align and block the other way around, so I used block(width: 100%), but this is better.

    One other thing that is strange, that block is by default breakable: true but in here I can remove breakable and it will still work the same (as default show rule; in my document). Maybe it works differently then I think.

  7. Andrew15-5 commented on Sep 11, 2023

    @Andrew15-5
    ContributorAuthor

    I don't get why Typst have to complicate things with numbering. In the doc, it says to add it.numbering inside the display(). Shouldn't it be the default behavior? At least in this show rule:

    Ok, one thing that I see is that I can override #set figure(numbering: "i") and then the display() will show different numbering style, but with display(it.numbering) it won't change the style. But this is a very rare example.

  8. laurmaedje commented on Sep 11, 2023

    @laurmaedje
    Member

    Counters and numbering aren't ideal yet. They will be improved at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions