Skip to content

Enhanced Figure Placement Options #3967

Open

Description

@Beiri22

Description

Currently, the figure placement in typst documents is restricted to 'top', 'bottom', or 'auto' (which places figures at either the top or bottom based on the figure element's location). This approach, while functional, has several limitations:

Contextual Placement:
The need arises for figures to be positioned relative to their main reference in the text, especially within large paragraphs. The current method, which aligns figures based on their point of definition, often results in suboptimal placements. When trying to define the figure inmidst a paragraph, the paragraph gets split, which disrupts the flow of text. Ideally, figures could dynamically align with the reference used within the text, maintaining coherence and visual integrity.

Adjacent Page Placement for Double-Sided Documents:
In double-sided documents, it would be highly beneficial for figures not be limited to the current page. They could automatically appear on an adjacent visible page—either the previous or the next. This placement ensures that figures are readily visible without necessitating a page turn and increases the systems degree of freedom. The ability to automatically adjust figure placement significantly reduces the manual effort involved in repositioning figures following text modifications. Implementing these features would greatly enhance the usability and flexibility of typst for producing professionally formatted documents.

Thank you for considering these enhancements.

Use Case

Placing figures in general (point 1) and especially in double sided documents like theses (point 2)

Activity

  1. added
    feature request
    on Apr 20, 2024
  2. Beiri22 commented on Apr 20, 2024

    @Beiri22
    ContributorAuthor

    (see #3159 and #3951)

  3. added
    layout
    on Apr 29, 2024
  4. laurmaedje commented on Jul 1, 2024

    @laurmaedje
    Member

    Another case are full page figures as requested in #4442.

  5. p-e-n-t-h-a commented on Sep 1, 2026

    @p-e-n-t-h-a

    I agree with @Beiri22 here, this is a real limitation essential for scientific writing, and honestly a bit surprising that this feature is missing.

    It appears to me that it is currently impossible to "put this figure near its reference point" without either manually shuffling the figure definition around the source (fragile, breaks on any edit, not even possible with paragraphs that are longer than one page) or accepting a layout that doesn't match the reference. (If there is a good option here, please help.)

    This is a genuine regression in ergonomics compared to LaTeX, where this behavior is easily achieved by placing the figure definition within the paragraph. This workaround is not possible in Typst, since the "insert a figure mid-paragraph" behavior (splitting the paragraph) makes the it actively harmful to the surrounding text flow. Also the #box(figure...) workaround does nothing in this case, since the figure does not float anymore.

    I suggest maybe adding this to the known limitations between Typst and LaTeX, since it might deter people to start writing their thesis using Typst, knowing proper figure placement cannot be achieved. At least for me this is one of the major reasons why even choosing LaTeX over Word. It should do the layouting for me and not force me to do parbreaks that don't make sense just to place my figure in the vicinity of it's first reference.

    Typst example illustrating the problem

    #set page("a5")
    #set par(justify: true)
    = Placed to early
    #figure(square(), caption: [Hi], placement: top)<fig:ref1>
    #lorem(480)
    *@fig:ref1*
    #lorem(300)
    #pagebreak()
    = Placed ok but creates unwanted parbreak
    #lorem(480)
    *@fig:ref2*
    #figure(square(), caption: [Hi], placement: top)<fig:ref2>
    #lorem(300)
    #pagebreak()
    = Placed to late
    #lorem(480)
    *@fig:ref3*
    #lorem(300)
    #figure(square(), caption: [Hi], placement: top)<fig:ref3>
    #pagebreak()
    = Placed inline
    #lorem(480)
    *@fig:ref5*
    #box[#figure(square(), caption: [Hi], placement: top)<fig:ref5>]
    #lorem(300)
    #pagebreak()
    

    yields:
    typ.pdf

    Easy LaTeX approach

    \documentclass{article}
    \usepackage[a5paper]{geometry}
    \usepackage{blindtext}
    \newcommand{\typstsquare}{\rule{2cm}{2cm}}
    \begin{document}
    \section{Placed exactly how it should be}
    \blindtext[3]
    \textbf{Figure~\ref{fig:ref2}}
    \begin{figure}[t]
        \centering
        \typstsquare
        \caption{Hi}
        \label{fig:ref2}
    \end{figure}
    \blindtext[3]
    \end{document}
    

    yields:
    tex.pdf

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

    feature requestlayout

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions