Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?
share|improve this question

2 Answers 2

up vote 5 down vote accepted

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)

enter image description here

share|improve this answer

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:

result

share|improve this answer
1  
Does the figure have to be placed at a paragraph break? (I guess yes.) –  Bruno Le Floch Mar 1 '12 at 11:58
2  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.