Changes

Jump to navigation Jump to search
1,557 bytes added ,  23:02, 18 July 2019
Paragraph in a group issue
\stoptext
</context>
 
=== The “paragraph in a group” problem ===
 
Another common issue with sidefloats is starting a paragraph in a group.
 
<context source="yes" mode="mkiv">
\placefigure[right,none]{}{\externalfigure[cow][width=0.25\textwidth]}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 
{\bf Oeps} \samplefile{lorem}
</context>
As you can see the paragraph starting with “Oeps” just overflows into the picture.
That is a well-known problem and there are posts about it on the mailing
list every once in a while. The sidefigure mechanism uses <code>\parshape</code> to
make the paragraph flow around the figure. The <code>\parshape</code> primitive only
applies to a single paragraph, so ConTeXt communicates the current
<code>\parshape</code> settings to the next paragraph using <code>\everypar</code>. However, when
a new paragraph starts in a group, i.e.
<texcode>
{\bf Oeps} ...
</texcode>
TeX inserts the <code>\everypar</code> tokens inside that group because only the
first letter starts the paragraph. That is to say is effectively looks
like this
<texcode>
% \everypar inserted inside the group
% ~~~v
{\bf \the\everypar Opes} ...
% ~~~~~~~~~~~~~~~~~~~~~^
% Setting of \everypar are discarded again when leaving the group and \parshape is lost.
</texcode>
You have to explicitly start a new paragraph before opening a group.
The easiest way to do this is
<texcode>
\dontleavehmode{\bf Oeps} ...
</texcode>
Now the <code>\everypar</code> tokens are inserted directly after {{cmd|dontleavehmode}}
outside the group and the problem goes away.
= Syntax =
28

edits

Navigation menu