4

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?

Andy
  • 6,269

1 Answers1

4

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
Marco
  • 26,055