Is there a Typst equivalent for LaTeX's special page figure placement?

131 Views Asked by At

In LaTeX there's a handy placement option for figures that allows you to place them in another "special page", such that only figures appear in that page and they are vertically centered:

\begin{figure}[p]
\centering
\includegraphics{image.png}
\caption{My caption...}
\end{figure}

Is there a Typst equivalent of this?

1

There are 1 best solutions below

2
ntjess On BEST ANSWER

Sure! You can add #pagebreak before and after the figure, or simply create a page container like the code below. set align(center + horizon) is what ensures the figure is vertically and horizontally centered on this new page.

#set page(height: 3in)
#let my-fig(..args, placement: none) = {
  if placement == page {
    page[
      #set align(center + horizon)
      #figure(..args)
    ]
  } else {
    figure(..args, placement: placement)
  }
}

#let pic = rect(width: 50%, height: 50%, radius: 1em, fill: aqua)

#lorem(30)

#my-fig(pic, caption: [top placement], placement: top)
#my-fig(pic, caption: [page placement], placement: page)

#lorem(100)

enter image description here