# [NTG-context] Side figure bug in mkiv?

Henri Menke henrimenke at gmail.com
Thu Jul 18 23:29:05 CEST 2019

On 19/07/19 3:18 AM, Duncan Hothersall wrote:
> I think I have identified a bug in the side figure mechanism which is demonstrated by the minimal example below. The {\bf …} construct causes the para in which it appears to stop behaving properly with the side figure, and the text overflows. The preceding and following paras which don't have {\bf …} do behave properly.
>
> I wondered if emphasis like \bf should be done differently (with a start/stop mechanism?) in mkiv, but I found nothing to suggest it.
>
> \starttext
> Blah blah.
> \placefigure[right,none]{}{\externalfigure[cow][width=0.30\makeupwidth]}
> Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah. Blah blah blah blah blah blah blah blah.
> {\bf Blah blah} blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
> Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
> \stoptext

Your formatting obscures the problem because compiling this example
works fine.  I think you are starting a new paragraph before {\bf ...}.
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 \parshape to
make the paragraph flow around the figure.  The \parshape primitive only
applies to a single paragraph, so ConTeXt communicates the current
\parshape settings to the next paragraph using \everypar.  However, when
a new paragraph starts in a group, i.e.

blah blah blah ...

{\bf Blah blah} blah ...

TeX inserts the \everypar tokens inside that group because only the
first letter starts the paragraph.  That is to say is effectively looks
like this

\everypar inserted inside the group
~~~~~|
v
{\bf \the\everypar Blah blah} blah ...
^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Setting of \everypar are discarded again when leaving the group and
\parshape is lost.

You have to explicitly start a new paragraph before opening a group.
The easiest way to do this is

\dontleavehmode{\bf Blah blah} blah ...

Now the \everypar tokens are inserted directly after \dontleavehmode
outside the group and the problem goes away.

For what it's worth, the MKIV way to switch to bold face is \bold{text}
instead of {\bf text} but it also doesn't fix your problem because
neither of the two start a new paragraph before the first letter and
therefore \the\everypar is still inside a group.

Cheers, Henri

>
> Thanks for any help.
>
> Duncan
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>