<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%% S. Lurp --- STRETCHY Docs --- MIT License
Stretchy provides various macros for creating your own stretchy symbols.
These all require knowledge regarding the usage of PDF path painting operators.
For an in-depth explanation on PDFs and the usage of pdf\TeX{} primitives, you may consult my article
\url{https://github.com/Shlurp/pdfTeX-explanation/blob/master/pdftex-explanation.pdf}{here}.

\subsection{Stretchy Coordinates}

All Stretchy painting commands should utilize the Stretchy coordinate system.
This is accessed and manipulated via the following macros:
\blist
    \item \macro\strty@p;
    \item \macro\strty@pd;
    \item \macro\strty@trans;
    \item \macro\strty@setpttrans.
\elist
Essentially, all these macros do is apply a transformation to the coordinates provided.
That is, if you specify a line from $(x_0,y_0)$ to $(x_1,y_1)$, Stretchy will transform these coordinates
according to the Current Stretchy Transformation (CST) $\CST$, and draw a line from $\CST(x_0,y_0)$ to
$\CST(x_1,y_1)$.
The idea is similar for cubic B\'ezier curves (the start, end, and control points are transformed via $T$).

In order to facilitate this, you must pass the coordinates to \macro\strty@p.
That is, instead of doing something like

\blisting
0 0 m
10 0 l
S
\elisting

You should do
\blisting
\strty@p{0}{0} m
\strty@p{10}{0} l
S
\elisting

The CST is specified by \macro\strty@trans, which is a macro accepting $2$ parameters and must expand to
two groups.
For example,
\blisting
\def\strty@trans#1#2{{-#2}{#1}}
\elisting
will rotate all points by $90$ degrees.

Stretchy provides some useful macros for basic arithmetic operations.
\blist
    \item \macro\strty@nopt{} computes a dimension expression, and expands to the result without the trailing
        {\tt pt}.
        For example \inlinecode|\strty@nopt{1pt+2pt}| will expand to {\tt3}.
    \item \macro\strty@add{} accepts two parameters (numbers), and expands to their sum.
    \item \macro\strty@mult{} accepts two parameters (numbers), and expands to their product.
\elist

The definitions of \macro\strty@add{} and \macro\strty@mult{} are simply
\listfile{strty-utils.tex}[9-10]

The definition of \macro\strty@setpttrans{} is simply
\listfile{strty-utils.tex}[61-63]
that is, it simply multiplies each component by \macro\strty@ptm, which is defined to be {\tt.996264} (the
ratio between \TeX{} and PDF pts).
Let us define this transformation to be $\PTT$.

\macro\strty@pd{} is a macro accepting four parameters:
\getmacrousage{\strty@pd {&lt;x&gt;}{&lt;y&gt;}{&lt;dx&gt;}{&lt;dy&gt;}}
it transforms the point $(x,y)$ to $\CST(x,y)+(dx,dy)$ where $dx,dy$ are dimensions.
This is useful e.g. in \macro\sqrtyrsqint, where the rounded edges are a set dimension, and thus the vertical
edges must be offset by a set dimension.

\subsection{Stretchy Utilities}

In {\tt strty-utils.tex}, Stretchy defines some useful utilities.
Most of these are internal to Stretchy or were discussed previously, but we take the time to discuss one:
\macro\strty@scalebox.
This accepts two parameters:
\getmacrousage{\strty@scalebox {&lt;scale&gt;}{&lt;material&gt;}}
and scales {\it material} by {\it scale}.
For example \inlinecode|\strty@scalebox{2}{\stretchylogo}| will produce

\medskip
\centerline{\strty@scalebox{2}{\stretchylogo}}

\subsection{Repeated Symbols}

In {\tt strty-repeatedsyms.tex}, Stretchy defines all the repeated symbols (listed above) as well as some
useful auxillary macros.

\macroexp{\strty@circle {x}{y}{r}}
This expands to PDF code for drawing a circle centered at $(x,y)$ (dimensions, not affected by the CST) with a
radius of $r$ (not a dimension).
The axis points of the circle end up being
\blist
    \item right: $\CST(r,0)+(x,y)$;
    \item left: $\CST(-r,0)+(x,y)$;
    \item top: $\CST(0,r)+(x,y)$;
    \item bottom: $\CST(0,-r)+(x,y)$.
\elist

In order to draw the circle, Stretchy draws four cubic B\'ezier curves.
The value \macro\strty@cd{} determines the distance of the control points from the axis points of the circle.
\emacroexp

\macroexp{\strty@repeatedsum {&lt;name&gt;}{&lt;symbol&gt;}{&lt;kerning&gt;}}
This defines a macro of name {\it name} which accepts a single parameter $N$, and paints the symbol
{\it symbol} $N$ times with {\it kerning} placed between subsequent symbols.
For example, 
\listfile{strty-repeatedsyms.tex}[61-62]
defines the two variants of \macro\strtyint{} and \macro\strtyintlimits{} (one for display math and the other
for textstyle math).
This defines the macros \macro\strty@dint@sym{} and \macro\strty@tint@sym.
For example, \inlinecode|\strty@dint@sym{5}| paints
$$ \strty@dint@sym{5} $$
\emacroexp

\macroexp{\strty@extensible {&lt;name&gt;}{&lt;bg code&gt;}{&lt;fg code&gt;}{&lt;symbol&gt;}{&lt;dx&gt;}{&lt;dy&gt;}{&lt;kerning&gt;}}
This defines a macro of name {\it name} which accepts a single parameter $N$ and paints the symbol
{\it symbol} $N$ times with {\it kerning} placed between subsequent symbols.
{\it bg code} is PDF code placed before painting the symbols, and {\it fg code} is PDF code placed after
painting the symbols.

If the resulting width of painting $N$ {\it symbol}s is $w$, then we define $\CST$ to be
$$ \CST\colon(x,y) \mapsto \left({{x(w+dx)}\over{2}}\,,\,y\cdot dy\right) $$
that is, $\CST$ stretches the $x$-axis by a factor of ${{w+dx}\over2}$ and the $y$-axis by a factor of $dy$.

For example, \macro\strty@dsqint@sym{} is the symbol for \macro\strtysqint{} in display math, and is defined
like so:
\listfile{strty-repeatedsyms.tex}[124-134]
\emacroexp

\macroexp{\strty@createoplims \&lt;macro&gt;{nolim sup kern}{nolim sub kern}{lim sup kern}{lim sub kern}}\hfil\break
This defines two macros, \macro\macro@nolim{} and \macro\macro@lim{} which accept three arguments each, $N$,
{\it sup} and {\it sub}.
These then pass $N$ to \macro\macro{} (which is a repeating macro, e.g. defined by \macro\strty@extensible),
and place {\it sup} and {\it sub} in the super- and subscripts, with kerning according to the parameters given.

For example, the definition of \macro\strtyint{} and \macro\strtyintlimits{} is
\listfile{strty-repeatedsyms.tex}[61-80]
\benum
    \item lines 61 and 62 define the symbols;
    \item lines 63 and 64 define the kerning of the super and subscripts;
    \item the rest define the actual macros.
\eenum
\emacroexp

\subsection{Stretched Symbols}

Stretchy provides the following auxillary macros for creating stretched symbols.

\macroexp{\strty@hstretch {&lt;name&gt;}{&lt;left&gt;}{&lt;right&gt;}{&lt;code&gt;}}
This defines a macro named {\it name} which accepts a parameter $w$, and creates a symbol of width $w$.
This symbol consists of (from left to right):
\benum
    \item the material {\it left};
    \item the code {\it code};
    \item the material {\it right}.
\eenum
The CST is set to be the composition of $\PTT$ with
$$ (x,y)\mapsto((w-w_l-w_r)\cdot x+w_l\,,\,y) $$
where $w_l,w_r$ are the widths of {\it left} and {\it right}, respectively.
That is, $(0,0)$ is mapped to $(w_l,0)$, $(1,0)$ is mapped to $(w-w_r,0)$, and $(0,1)$ is mapped to $(0,1)$.
So the left side of {\it code} maps to $w_l$ (the edge of {\it left}), and the right side to $w-w_r$ (the edge
of {\it right}).
\emacroexp

\macroexp{\strty@vstretch {&lt;name&gt;}{&lt;top&gt;}{&lt;bottom&gt;}{&lt;code&gt;}}
This defines a macro named {\it name} which accepts a parameter $h$, and creates a symbol of height $h$.
This symbol consists of (from top to bottom):
\benum
    \item the material {\it top};
    \item the code {\it code};
    \item the material {\it bottom}.
\eenum
The CST is set to be the composition of $\PTT$ with
$$ (x,y)\mapsto(x\,,\,(d-h_t-h_b)\cdot y+h_b) $$
where $h_t,h_b$ are the heights of {\it top} and {\it bottom}, respectively.
That is, $(0,0)$ is mapped to $(0,h_b)$, $(1,0)$ is mapped to $(1,0)$, and $(0,1)$ is mapped to $(0,d-h_t)$.
So the top of {\it code} maps to $d-h_t$ (the bottom of {\it top}), and the bottom to $h_b$ (the top
of {\it bottom}).
\emacroexp

\macroexp{\strty@hvstretch {&lt;name&gt;}{&lt;tl&gt;}{&lt;tr&gt;}{&lt;bl&gt;}{&lt;br&gt;}{&lt;top code&gt;}{&lt;bot code&gt;}{&lt;mid code&gt;}}
This defines a\hfil\break macro named {\it name} which accepts two parameters $w,h$.
It creates a symbol of width $w$ and height $h$ of the form:
$$ \pmatrix{\hbox{\it tl}&amp;\hbox{\it top code}&amp;\hbox{\it tr}\cr
&amp;\hbox{\it mid code}\cr
\hbox{\it bl}&amp;\hbox{\it bot code}&amp;\hbox{\it br}} $$
The transformations for each code are as follows:
\blist
    \item {\it top code}: let $w_{\it tl},w_{\it tr}$ be the widths of {\it tl} and {\it tr} respectively.
        Then $\CST$ is the composition of $\PTT$ with
        $$ (x,y) \mapsto ((w-w_{\it tl}-w_{\it tr})\cdot x+w_{\it tl}\,,\,y) $$
        that is, the left side of {\it top code} maps to $w_{\it tl}$, and the right side to $w-w_{\it tr}$.
    \item {\it bot code}: let $w_{\it bl},w_{\it br}$ be the widths of {\it bl} and {\it br} respectively.
        Then $\CST$ is the composition of $\PTT$ with
        $$ (x,y) \mapsto ((w-w_{\it bl}-w_{\it br})\cdot x+w_{\it bl}\,,\,y) $$
        that is, the left side of {\it top code} maps to $w_{\it bl}$, and the right side to $w-w_{\it br}$.
    \item {\it mid code}: let $h_t,h_b$ be the heights of the top and bottom materials, respectively.
        Then $\CST$ is the composition of $\PTT$ with
        $$ (x,y) \mapsto (w\cdot x\,,\,(h-h_t-h_b)\cdot y+h_b) $$
        so
        \blist
            \item $(0,0)$ (the bottom left of {\it mid code}) maps to $(0,h_b)$ (the top left of the bottom
                material);
            \item $(1,0)$ (the bottom right) maps to $(w,h_b)$ (the top right of the bottom material);
            \item $(0,1)$ (the top left) maps to $(0,h-h_t)$ (the bottom left of the top material);
            \item $(1,1)$ (the top right) maps to $(w,h-h_t)$ (the bottom right of the top material).
        \elist
\elist
\emacroexp

To create a stretched symbol, there are four steps:
\benum
    \item precisely measure the dimensions of the glyph you're making stretchy;
    \item crop the glyph where you want (either using form XObjects, or clipping paths);
    \item use \macro\strty@XXstretch{} (${\tt XX}\in\{{\tt h},{\tt v},{\tt hv}\}$) on the cropped sections of
        the glyph, as well as the code to connect them.
        This creates a stretchable symbol;
    \item define macro to get the material (super-, sub-script, and main material) and compute the dimensions
        to stretch the symbol to.
\eenum

For example, we can measure (textstyle) $\prod$ to get the (rough) dimensions of the strokes

\bigskip
\def\mbscale{7}
\def\mbstrokewd{0}
\centerline{\measurebox{\mbnodp{$\prod$}}{%
    \measureh{b=.5\mbht, e=10pt, stroke=.01, color=blue, dash=.1, label=(top stroke top), noprint, legend}%
    \measureh{b=.5\mbht, e=9.6pt, stroke=.01, color=blue, dash=.1, label=(top stroke bot), noprint, legend}%
    \measurew{b=1.59pt, e=2.56pt, stroke=.01, color=red, dash=.1, label=(left stroke), noprint, legend}%
    \measurew{b=\mbwd-2.574pt, e=\mbwd, stroke=.01, color=red, dash=.1, label=(right stroke left),
    noprint, legend, y=.5\mbht-1pt}%
    \measurew{e=\mbwd, b=\mbwd-1.604pt, stroke=.01, color=red, dash=.1, label=(right stroke right),
    noprint, legend, y=.5\mbht-1pt}%
}}

Now we can create our own stretched \macro\prod, with the following code:

\blisting
\bgroup
\setbox0=\hbox{\mbnodp{$\prod$}}    % product with no depth
\setbox1=\vbox to.5\ht0{\copy0\vss}
\setbox2=\vbox to.5\ht0{\vss\copy0}
\setbox3=\hbox to.5\wd0{\copy1\hss} % tl
\setbox4=\hbox to.5\wd0{\hss\copy1} % tr
\setbox5=\hbox to.5\wd0{\copy2\hss} % bl
\setbox6=\hbox to.5\wd0{\hss\copy2} % br
\pdfxform3 \xdef\prodtl{\pdfrefxform\the\pdflastxform}
\pdfxform4 \xdef\prodtr{\pdfrefxform\the\pdflastxform}
\pdfxform5 \xdef\prodbl{\pdfrefxform\the\pdflastxform}
\pdfxform6 \xdef\prodbr{\pdfrefxform\the\pdflastxform}
\egroup

\strty@hvstretch{stretchedprod}{\prodtl}{\prodtr}{\prodbl}{\prodbr}%
{   % top connecting horizontal line
    \strty@p{0}{5} m
    \strty@p{1}{5} l
    \strty@p{1}{4.6} l
    \strty@p{0}{4.6} l
    h
    f
}%
{}%
{%  connecting vertical lines
    \strty@pd{0}{0}{1.59pt}{0pt} m
    \strty@pd{0}{1}{1.59pt}{0pt} l
    \strty@pd{0}{1}{2.56pt}{0pt} l
    \strty@pd{0}{0}{2.56pt}{0pt} l
    h
    f
    \strty@pd{1}{0}{-2.574pt}{0pt} m
    \strty@pd{1}{1}{-2.574pt}{0pt} l
    \strty@pd{1}{1}{-1.604pt}{0pt} l
    \strty@pd{1}{0}{-1.604pt}{0pt} l
    h
    f
}
\elisting

\bgroup
\setbox0=\hbox{\mbnodp{$\prod$}}    % product with no depth
\setbox1=\vbox to.5\ht0{\copy0\vss}
\setbox2=\vbox to.5\ht0{\vss\copy0}
\setbox3=\hbox to.5\wd0{\copy1\hss} % tl
\setbox4=\hbox to.5\wd0{\hss\copy1} % tr
\setbox5=\hbox to.5\wd0{\copy2\hss} % bl
\setbox6=\hbox to.5\wd0{\hss\copy2} % br
\pdfxform3 \xdef\prodtl{\pdfrefxform\the\pdflastxform}
\pdfxform4 \xdef\prodtr{\pdfrefxform\the\pdflastxform}
\pdfxform5 \xdef\prodbl{\pdfrefxform\the\pdflastxform}
\pdfxform6 \xdef\prodbr{\pdfrefxform\the\pdflastxform}
\egroup

\strty@hvstretch{stretchedprod}{\prodtl}{\prodtr}{\prodbl}{\prodbr}%
{   % top connecting horizontal line
    \strty@p{0}{5} m
    \strty@p{1}{5} l
    \strty@p{1}{4.6} l
    \strty@p{0}{4.6} l
    h
    f
}%
{}%
{%  connecting vertical lines
    \strty@pd{0}{0}{1.59pt}{0pt} m
    \strty@pd{0}{1}{1.59pt}{0pt} l
    \strty@pd{0}{1}{2.56pt}{0pt} l
    \strty@pd{0}{0}{2.56pt}{0pt} l
    h
    f
    \strty@pd{1}{0}{-2.574pt}{0pt} m
    \strty@pd{1}{1}{-2.574pt}{0pt} l
    \strty@pd{1}{1}{-1.604pt}{0pt} l
    \strty@pd{1}{0}{-1.604pt}{0pt} l
    h
    f
}

Doing then \inlinecode|\stretchedprod{20pt}{20pt}|, will give, for example:

\centerline{\stretchedprod{20pt}{20pt}}

The rest of the code to get the dimensions of the limits and main material and pass to \macro\stretchedprod is
standard.

</pre></body></html>