I’m trying to align 2 images side by side but can reach the objetive.
When I put the images, they appear vertically. I want to put them side by side and centered on the page.
This is my code
#figure(
image("image1.jpeg", width: 30%),
)
#figure(
image("image2.jpeg", width: 30%),
)
Images (and most other elements, e.g. paragraphs, headings, tables, as well as shapes like lines and rectangles) are block level, that means that they are laid out vertically under each other. The opposite is inline.
There are a few ways to arrange block content horizontally.
- Here, I would suggest a grid. Grids put multiple things into cells, and you can of course have a grid with only one row. Since you have multiple images, a grid with two column will do the job.
- Related is the table, but since you only care about the layout and not the display of tabular data, it is less appropriate.
- Also somewhat related is the stack, but I would simply not recommend it since it sometimes behaves strangely and I’m not aware of anything you can’t do with a grid instead.
- The last option is to use box, which simply wraps something in an inline element, even if it was normally a block-level element. This is more for cases where you put an element in the middle of a line of text or other content that is already inline; since you want to layout two things that are block-level and nothing else, I wouldn’t suggest it for your use case.
1 Like