%%% Surrounded math
\newcount\repeater
\def\dorecurse#1#2{% just a helper
\repeater=0 \loop
#2%
\advance\repeater by1
\ifnum\repeater<#1\relax
\repeat}
% One of those features that the average user will never see is the ability to
% influence \type {\mathsurround}. In \CONTEXT\ for instance this parameter is
% set to \type {0pt} by default and only in special math constructs it might get
% a different value. And even then, this value is small.
%
% It might actually be true that the sole reason for this parameter is its use in
% special situations. This is demonstrated by what happens if we use non-zero
% values. Say that we have this input:
\def\test{%
test \par
\noindent $test$ \par
$test$ \par
test \par
}
\test
% When we set both \type {\parindent} and \type {\mathsurround} to zero, we get:
{\mathsurround 0pt \parindent 0pt \test }
% When we set \type {\mathsurround} to \type {16pt} we get:
{\mathsurround 16pt \parindent 0pt \test }
% When we set \type {\parindent} to \type {32pt} we get:
{\mathsurround 0pt \parindent 32pt \test }
% When we set \type {\mathsurround} to \type {16pt} and \type {\parindent} to
% \type {32pt} we get:
{\mathsurround 16pt \parindent 32pt \test }
% We guess that the assumption is that a \type {\mathsurround} value different
% from zero is not assumed when typesetting a paragraph or at least that the
% assumption is that a paragraph does not start or finish with an inline math
% formula.
% This is what happens. A kern is added at the left and right side of a formula.
% So we get:
{\mathsurround32pt|\hbox{$xx$}|}
% When the paragraph is typeset, this kern removed at linebreaks
% when needed:
{\mathsurround32pt \dorecurse{20}{x {$xx$} xxx }}
% However, as the start of a paragraph is no linebreak, it will stay there!
{\mathsurround32pt \dorecurse{20}{$xx$ } }
% If we use negative values we get similar effects:
{\mathsurround-32pt|\hbox{$xx$}|}
% Or in a vertical box:
{\mathsurround-32pt \dorecurse{20}{$xx$ } }
% Maybe there is an opportunity here to implement marginal notes by abusing
% a math formula at the start of a paragraph! After all, we've run into weirder
% abuse of side effects.
\end