When typesetting images on a grid, several factors are involved. The first one
is the presence of a caption or title.
No caption
If no caption is provided, then the bottom of the images is aligned to the
grid. The top alignment depends on the height of the image. To align the top
to the x-height of the body font, the images need to have a multiple of the height of the base line distance plus the x-height of the body font.
\startplacefigure [location={none,left}]
\externalfigure [dummy] [height=\dimexpr2\lineheight+\exheight\relax]
\stopplacefigure
However, the image is then aligned to the second line. To align it to the first
line, as you requested, provide the option high
.
\startplacefigure [location={none,left,high}]
\externalfigure [dummy] [height=\dimexpr2\lineheight+\exheight\relax]
\stopplacefigure
With caption
A caption makes things slightly more complicated. Between the float and the
caption there is a \blank
inserted, which shifts the image up. To align it
to the base line, the depth of a strut needs to be compensated.
\setupcaptions [figure] [inbetween={\blank[\strutdepth]}]
To align all figures to the first line, you can use the sidealign
key
globally. Then it is not necessary to specify the value with each figure.
\setupfloats [figure] [sidealign=line]
Fine tuning
Another option to fine tune the vertical placement of the floats is to use the
command \movesidefloat
. The argument can be eg. +2*line
or -1*line
. The
command is used directly before the \startplacefigure
.
Documentation
Further details about float placement and grids are explained in the details
manual.
Complete example
\useMPlibrary [dum]
\setuplayout [grid=yes]
\setupinterlinespace [line=20pt]
\setupfloats [figure] [sidealign=line]
\setupcaptions [figure] [inbetween={\blank[\strutdepth]}]
\starttext
\showgrid
\startplacefigure [title=A short caption, location=left]
\externalfigure [dummy] [height=\dimexpr2\lineheight+\exheight\relax]
\stopplacefigure
\input ward
\startplacefigure
[title={There is not so much basic instruction, as of now, as there was
in the old days, showing the differences between good and bad typographic design.},
location=left]
\externalfigure [dummy] [height=\dimexpr3\lineheight+\exheight\relax]
\stopplacefigure
\input zapf
\startplacefigure [title=Short caption, location=left]
\externalfigure [dummy] [height=\dimexpr5\lineheight+\exheight\relax]
\stopplacefigure
\input ward
\page
\movesidefloat [line]
\startplacefigure [location={none,left}]
\externalfigure [dummy] [height=\dimexpr2\lineheight+\exheight\relax]
\stopplacefigure
\input ward
\movesidefloat [line]
\startplacefigure [location={none,left}]
\externalfigure [dummy] [height=\dimexpr3\lineheight+\exheight\relax]
\stopplacefigure
\input zapf
\movesidefloat [line]
\startplacefigure [location={none,left}]
\externalfigure [dummy] [height=\dimexpr5\lineheight+\exheight\relax]
\stopplacefigure
\input ward
\stoptext
\setupfloat[figure][sidealign=line]