# Defining the size of a graphic based on the number of rows it should span in ConTeXt

I am using ConTeXt to make a document containing many illustrations. Some will appear placed like this (the area in brackets is where the illustration will appear:

This is some text. This is some text.
[                       ] X This is some
[                       ] text. This
[                       ] is some text.
[                       ] This is some
[                       ] text. This
[                       ] is some text.
[                       ] This is some
text. This is some text. This is some
text.

In this example, the graphic is exactly 7 rows high, the width is adjusted to match a 1:1 ratio. The top of the graphic aligns with the top of the text in the 2nd row and the bottom of the graphic aligns with the bottom of the text in the 8th row.

• How can I place a graphic in my document in this way, by defining the number of rows the graphic must span?
-

Marco has already answered how to place the figure on the left, and how to set the height of the figure to a specific number of lines.

You also wanted the figure to start one line below the start of the paragraph. To do this, add hang to the location parameter. To start two lines below the start of the paragraph, add 2*hang etc.

For example (I use the visual module for dummy text):

\usemodule [visual]

\setupfloats [spacebefore=, spaceafter=]
\setupindenting[big,yes]

\starttext
\fakewords{20}{30}
\startplacefigure [location={left,none,2*hang}]
\externalfigure[dummy][height=8\lineheight]
\stopplacefigure
\fakewords{150}{250}
\stoptext

gives the following (the blue rectangles denote parindent in front of new paragraphs)

-

The following should do what you want.

\useMPlibrary [dum]

\setupfloats [spacebefore=, spaceafter=]

\starttext
\input ward

\startplacefigure [location={left,none}]
\externalfigure [dum] [height=8\lineheight]
\stopplacefigure

\input knuth
\stoptext

The MP library is just used for the dummy graphic. According to your graphic there should be no space above and below the graphic, so I removed it. Then it is as easy as telling ConTeXt that the graphic should be placed on the left and telling \externalfigure the height of the image. The aspect ratio is kept automatically, if you don't want this then specify the width as well.

The result:

-
Does the figure have to be placed at a paragraph break? (I guess yes.) – Bruno Le Floch Mar 1 '12 at 11:58
It's the other way around. \startplacefigure starts a new paragraph. I don't know of any option to avoid that. However, \stopplacefigure doesn't end the paragraph. – Marco Mar 1 '12 at 12:26