Re: fences (variable size math symbols)

Subject: Re: fences (variable size math symbols)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 10 Jun 1998 12:14:01 +0100
>  Can you post an example of the source text upon which you expect
> to operate along with a description of what the expected output would

OK one more try.

This is, I (and jade) believe, a valid piece of mathml. The intention is
that it is one possible rendering of the expression in the comment at
the top. (It would be good style to have more nested <mrow> elements, or
use content markup but that isn't the point here. I have made some
of the attributes explicit here although they are in fact the default
values as implied by the operator dictionary of mathml. (I can implement
the dictionary in dsssl, so it should make no difference whether the
attributes are explicit or not).

<math>

<!-- a + ( a^{[X]} + {1 \over2}
        ||  x + {A^A}^A
         ) + b -->

<mrow>
  <mi>a</mi>
  <mo>+</mo>
  <mo form="prefix" fence="true" stretchy="true">(</mo>
    <msup>
      <mi>a</mi>
      <mrow>
        <mo  form="prefix" fence="true" stretchy="true">[</mo>
          <mi>X</mi>
        <mo  form="postfix" fence="true" stretchy="true">]</mo>
      </mrow>
    </msup>
    <mo>+</mo>
    <mfrac>
      <mn>1</mn>
      <mn>2</mn>
    </mfrac>
  <mo  form="infix" fence="true" stretchy="true">||</mo>
    <mi>x</mi>
    <mo>+</mo>
    <msup>
      <msup>
        <mi>A</mi>
        <mi>A</mi>
      </msup>
      <mi>A</mi>
    </msup>
  <mo form="postfix" fence="true" stretchy="true">)</mo>
  <mo>+</mo>
  <mi>b</mi> 
</mrow>

</math>


Note that the three operators "(" "||" and ")" are all to be the same
size, large enough to cover the whole expression, including the parts
`outside' the brackets. A fence flow object only lets me specify
two characters that stretch so is not sufficient. If I make one fence
flow object that wraps up the expression between ( and || then they will
be the same size, but then an outer fence flow object that wraps up
a null open with the closing ) will make that closing ) large enough to
cover the sub expression _including_ ( and || and so typically will make
the ) larger than the (.

What I want to come out of the tex backend is this.

\fenced{%
  a +
 \makefence\mathopen( 
    a^{\fenced{\makefence\mathopen[X\makefence\mathclose]}}
   + {1\over2}
 \makefence\mathbin\|
   x+ {A^A}^A 
 \makefence\mathclose)
 + b }


where \fenced should be the outcome of a math-sequence flow object that
contains fences. and \fence<mathclass><character> stretches the
specified character and gives it spacing for the appropriate class.

The question is. How do I get from here to there?

Not really what dsssl do I need to do that, but what FOT output should I
be trying to produce?

The tex (which isn't very polished as I just wrote it this morning, to
go with this message) has several features that I would rather like to
preserve.

1) All fences in the specified expression grow by the same amount.
2) Line breaking may happen within the expression, if so a suitable
   indenation is applied to the broken sections.
3) Line breaking does not affect the calculated size of the characters.

David

plain tex document setting the above expression in wide and narrow
measures follows. (With apologies to those who don't speak TeX or math
-- is there a better list for this type of question. I tried www-math
list before but it is excessively quiet)

-----------------------------------------------------------------

\catcode`\@=11
\def\fenced{%
  \mathpalette\d@fence}
\def\@gobbletwo#1#2{}

\def\d@fence#1#2{%
  \setbox\z@\hbox{%
    \let\makefence\@gobbletwo
    \m@th
    $#1#2$}%
  \begingroup
  \edef\@fenceht{\the\ht\z@}%
  \edef\@fencedp{\the\dp\z@}%
  #2%
  \endgroup}

\def\makefence#1#2{%
  #1{\hbox{$%
    \n@space
     \left#2%
     \hbox{\vrule height\@fenceht depth\@fencedp width 0pt}%
     \right.%
     $}}%
    \ifx#1\mathbin
     \hskip\z@ plus1fill
      \penalty0
     \hskip\z@ plus-2fill
     \null
     \hskip\z@ plus1fill
    \fi}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% display a math expression and indicate horizontal measure.
\def\display#1{%
   \vbox{\hsize#1\bigskip\hrule\bigskip
  \everypar{\hfil}\parfillskip\z@ plus 1fil
   \noindent$\expression$%
   \bigskip\hrule}}

% Today's test expression
\def\expression{%
%
\fenced{%
  a +
 \makefence\mathopen( 
    a^{\fenced{\makefence\mathopen[X\makefence\mathclose]}}
   + {1\over2}
 \makefence\mathbin\|
   x+ {A^A}^A 
 \makefence\mathclose)
 + b }}

% wide measure
\display{\hsize}

% same again to narrow measure
\display{1.5in}



\bye


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • RE: fences (variable size math symbols), (continued)
    • Reynolds, Gregg - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id SAA27384Mon, 8 Jun 1998 18:49:56 -0400 (EDT)
      • David Carlisle - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id EAA14601Tue, 9 Jun 1998 04:54:46 -0400 (EDT)
        • Chris Maden - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id QAA24947Tue, 9 Jun 1998 16:07:55 -0400 (EDT)
      • Sebastian Rahtz - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id FAA15099Tue, 9 Jun 1998 05:06:12 -0400 (EDT)
      • David Carlisle - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id HAA24814Wed, 10 Jun 1998 07:16:40 -0400 (EDT) <=
    • Reynolds, Gregg - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id LAA19791Tue, 9 Jun 1998 11:44:01 -0400 (EDT)
      • Sebastian Rahtz - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id MAA20486Tue, 9 Jun 1998 12:04:47 -0400 (EDT)