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.

The following example produces a line break after the second text.

\define[2]\smallfigure{\placefigure[margin][#1]{#2}{!}}%

\starttext 
text text\smallfigure{fig1}{A}text text 
\stoptext

linebreak_example

The ConTeXt FAQ addresses this explicitly. However, although the problem seems identical, changing the macro to

\define[2]\smallfigure{\dontleavehmode\placefigure[margin][#1]{#2}{!}}%

does not work as intended and avoiding the macro altogether

\starttext 
text text\dontleavehmode\placefigure[margin][]{A}{!}text text 
\stoptext 

does not work either. Is there a way to avoid the line break?

share|improve this question
1  
How about inserting the figure at the beginning of the paragraph? –  Marco May 18 '12 at 13:32
    
I would normally do that. In this case I prepare documents with different layouts, but the same content. Then it is advantagous to put the figure exactly where it is also mentioned in the text the first time. Otherwise, I would have to tweak every document by itself. It would be great, if that is possible. –  Andy May 18 '12 at 14:34
    
Would “What is the ConTeXt or plain TeX equivalent of \nolinebreak?” help? –  cgnieder May 18 '12 at 15:11
1  
This is a known property of floats and crops up on the mailing list every now and then. If it’s a problem for you, then you might be able to bypass it using the postponing mechanism. In some cases where you don’t need a caption, the hangaround environment may lead to acceptable results too. –  phg May 18 '12 at 19:02
    
@phg Could you make your comment an answer? –  Joseph Wright Aug 6 '12 at 20:52
add comment

1 Answer

up vote 4 down vote accepted

Move the placefigure call

One solution would be to place the figure at the beginning of the paragraph. This keeps the text together.

\starttext

\startplacefigure [title=Caption,location=margin]
  \externalfigure [dummy]
\stopplacefigure
text text
text text

\stoptext

Use the postponing mechanism

The postponing mechanism keeps the text together. However, it influences the float placement. The float appears on the page after the text, which might be undesirable.

text text
\startpostponing [+1]
  \startplacefigure [title=Caption,location=margin]
    \externalfigure [dummy]
  \stopplacefigure
\stoppostponing
text text
share|improve this answer
add comment

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.