How do I insert an image into the header?

I want to have a header with a logo image on the left and an address field on the right. I am having difficulty in getting this to work correctly. The image is always shown below and to the left of the address which pushes the body of my document down the page?

Thanks.

A MWE would help to understand your problem.

And please tag your question (graphics, layout, etc.).

The main problem here is that images are block level: when Typst sees an image, the current block (e.g. paragraph) ends and a new one begins. One way around that is wrapping images in box().

If you have some content on the left and some on the right, the easiest way is to use horizintal space:

#box(image(...) #h(1fr) Some address

This inserts horizontal space that is exactly enough to fill the available space.

For headers, I usually use a grid instead; it makes it easy to have a center part as well:

#grid(
  columns: (1fr, 1fr),
  align: (left, right),
  rect[Left],
  [Right],
)

#grid(
  columns: (1fr, 1fr, 1fr),
  align: (left, center, right),
  rect[Left],
  [Center],
  [Right],
)

Thanks for the response. What is an MWE?

A Minimal Working Exemple (MWE) is what we call the strictly necessary code to reproduce your issue, so that people can help you work it out!

Have you read How to post in the Questions category?

@Andrew talks about it in Image sizes parent container wrongly?

Providing a MWE/MRE (Minimal Working/Reproducible Example) is essential (for questions based on user-written Typst code). This means that things like width: auto should be excluded from example as block.width is equal to auto by default. This visually adds unnecessary noise to an already non-trivial example

1 Like

The use of #grid proposed by @SillyFreak worked a treat. Exactly what I was looking for for this project.

Thank you all for your help.

1 Like