void boverb(int p1, int p2) { int treg; double h, b, d, d1, d2; extern double Overgap, Overwid, Overline; treg = salloc(); yyval = p1; d = EM(Overgap, ps); h = eht[p1] + eht[p2] + d; b = eht[p2] - d; dprintf(".\tS%d <- %d over %d; b=%g, h=%g\n", yyval, p1, p2, b, h); nrwid(p1, ps, p1); nrwid(p2, ps, p2); printf(".nr %d \\n(%d\n", treg, p1); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); printf(".nr %d \\n(%d+%gm\n", treg, treg, Overwid); d2 = eht[p2]-ebase[p2]-d; /* denom */ printf(".ds %d \\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\v'%gm'\\\n", yyval, REL(d2,ps), treg, p2, p2, REL(-d2,ps)); d1 = 2 * d + ebase[p1]; /* num */ printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\*(%d\\v'%gm'\\\n", p2, p1, REL(-d1,ps), p1, REL(d1,ps)); printf("\\h'-\\n(%du-\\n(%du/2u+%gm'\\v'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n", treg, p1, Overline, REL(-d,ps), treg, 2*Overline, Overline, REL(d,ps)); ebase[yyval] = b; eht[yyval] = h; lfont[yyval] = rfont[yyval] = 0; sfree(p2); sfree(treg); }
void boverb(int p1, int p2) { int treg; #ifndef NEQN float h, b, d; #else /* NEQN */ int h, b, d; #endif /* NEQN */ treg = oalloc(); yyval.token = p1; #ifndef NEQN d = VERT(EM(0.3, ps)); h = eht[p1] + eht[p2] + d; #else /* NEQN */ d = VERT(1); h = eht[p1] + eht[p2]; #endif /* NEQN */ b = eht[p2] - d; #ifndef NEQN if(dbg)printf(".\tb:bob: S%d <- S%d over S%d; b=%g, h=%g\n", yyval.token, p1, p2, b, h); #else /* NEQN */ if(dbg)printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n", yyval.token, p1, p2, b, h); #endif /* NEQN */ nrwid(p1, ps, p1); nrwid(p2, ps, p2); printf(".nr %d \\n(%d\n", treg, p1); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); #ifndef NEQN printf(".nr %d \\n(%d+\\s%s.5m\\s0\n", treg, treg, tsize(EFFPS(ps))); printf(".ds %d \\v'%gp'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n", yyval.token, eht[p2]-ebase[p2]-d, treg, p2, p2); printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gp'\\*(%d\\\n", p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1); printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%gp'\\l'\\n(%du-.2m'\\h'.1m'\\v'%gp'\n", treg, p1, ebase[p1]+d, treg, d); #else /* NEQN */ printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n", yyval.token, eht[p2]-ebase[p2]-d, treg, p2, p2); printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n", p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1); printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n", treg, p1, ebase[p1], treg, d); #endif /* NEQN */ ebase[yyval.token] = b; eht[yyval.token] = h; lfont[yyval.token] = rfont[yyval.token] = 0; ofree(p2); ofree(treg); }
void fromto(int p1, int p2, int p3) { double b, h1, b1, t; int subps; yyval = salloc(); lfont[yyval] = rfont[yyval] = 0; h1 = eht[yyval] = eht[p1]; b1 = ebase[p1]; b = 0; subps = ps; ps += deltaps; nrwid(p1, ps, p1); printf(".nr %d \\n(%d\n", yyval, p1); if (p2 > 0) { nrwid(p2, subps, p2); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2); eht[yyval] += eht[p2]; b = eht[p2]; } if (p3 > 0) { nrwid(p3, subps, p3); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3); eht[yyval] += eht[p3]; } printf(".ds %d ", yyval); /* bottom of middle box */ if (p2 > 0) { t = eht[p2]-ebase[p2]+b1; printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'%s\\*(%d%s", REL(t,ps), yyval, p2, DPS(ps,subps), p2, DPS(subps,ps)); printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", yyval, p2, REL(-t,ps)); } printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n", yyval, p1, p1, yyval, p1); if (p3 >0) { t = h1-b1+ebase[p3]; printf("\\v'%gm'\\h'-\\n(%du-\\n(%du/2u'%s\\*(%d%s\\h'\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", REL(-t,ps), yyval, p3, DPS(ps,subps), p3, DPS(subps,ps), yyval, p3, REL(t,ps)); } printf("\n"); ebase[yyval] = b + b1; dprintf(".\tS%d <- %d from %d to %d; h=%g b=%g\n", yyval, p1, p2, p3, eht[yyval], ebase[yyval]); sfree(p1); if (p2 > 0) sfree(p2); if (p3 > 0) sfree(p3); }
void sqrt(int p2) { static int af = 0; int nps; /* point size for radical */ double radscale = 0.95; if (ttype == DEVPOST) radscale = 1.05; nps = ps * radscale * eht[p2] / EM(1.0,ps) + 0.99; /* kludgy */ nps = max(EFFPS(nps), ps); yyval = p2; if (ttype == DEVCAT || ttype == DEVAPS) eht[yyval] = EM(1.2, nps); else if (ttype == DEVPOST) eht[yyval] = EM(1.15, nps); else /* DEV202, DEVPOST */ eht[yyval] = EM(1.15, nps); dprintf(".\tS%d <- sqrt S%d;b=%g, h=%g, nps=%d\n", yyval, p2, ebase[yyval], eht[yyval], nps); printf(".as %d \\|\n", yyval); nrwid(p2, ps, p2); if (af++ == 0) printf(".af 10 01\n"); /* make it two digits when it prints */ printf(".nr 10 %.3fu*\\n(.su/10\n", 9.2*eht[p2]); /* this nonsense */ /* guesses point size corresponding to height of stuff */ printf(".ds %d \\v'%gm'\\s(\\n(10", yyval, REL(ebase[p2],ps)); if (ttype == DEVCAT || ttype == DEVAPS) printf("\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'", p2); else /* DEV202, DEVPOST so far */ printf("\\(sr\\l'\\n(%du\\(rn'", p2); printf("\\s0\\v'%gm'\\h'-\\n(%du'\\^\\*(%d\n", REL(-ebase[p2],ps), p2, p2); lfont[yyval] = rfont[yyval] = ROM; }
void sqrt(int p2) { #ifndef NEQN float nps; nps = (int)(EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT))); #endif /* NEQN */ yyval.token = p2; #ifndef NEQN eht[yyval.token] = VERT(EM(1.2, nps)); if(dbg)printf(".\tsqrt: S%d <- S%d;b=%g, h=%g\n", yyval.token, p2, ebase[yyval.token], eht[yyval.token]); if (ital(rfont[yyval.token])) printf(".as %d \\|\n", yyval.token); #endif /* NEQN */ nrwid(p2, ps, p2); #ifndef NEQN printf(".ds %d \\v'%gp'\\s%s\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%s", yyval.token, ebase[p2], tsize(nps), p2, tsize(ps)); printf("\\v'%gp'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2); lfont[yyval.token] = ROM; #else /* NEQN */ printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'", p2, ebase[p2], -eht[p2], p2); printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2); eht[p2] += VERT(1); if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", p2, p2, ebase[p2], eht[p2]); #endif /* NEQN */ }
void fatbox(int p) { int sh; yyval = p; sh = ps / 4; nrwid(p, ps, p); printf(".ds %d \\*(%d\\h'-\\n(%du+0.05m'\\*(%d\n", p, p, p, p); if(dbg)printf(".\tfat %d, sh=0.05m\n", p); }
int fatbox(int p) { int sh; int yyval; yyval = p; sh = ps / 4; nrwid(p, ps, p); printf(".ds %d \\*(%d\\h'-\\n(%du+%du'\\*(%d\n", p, p, p, sh, p); if (dbg) printf(".\tfat %d, sh=%d\n", p, sh); return yyval; }
void lpile(int type, int p1, int p2) { int bi, hi, i, gap, h, b, nlist, nlist2, mid; yyval = oalloc(); #ifndef NEQN gap = VERT(EM(0.4, ps)); /* 4/10 m between blocks */ #else /* NEQN */ gap = VERT(1); #endif /* NEQN */ if (type == '-') gap = 0; nlist = p2 - p1; nlist2 = (nlist+1)/2; mid = p1 + nlist2 -1; h = 0; for (i = p1; i < p2; i++) h += eht[lp[i]]; eht[yyval] = h + (nlist-1)*gap; b = 0; for (i = p2-1; i > mid; i--) b += eht[lp[i]] + gap; #ifndef NEQN ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]] : b - VERT(EM(0.5, ps)) - gap; #else /* NEQN */ ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]] : b - VERT(1) - gap; #endif /* NEQN */ if (dbg) { printf(".\tS%d <- %c pile of:", yyval, type); for (i = p1; i < p2; i++) printf(" S%d", lp[i]); printf(";h=%d b=%d\n", eht[yyval], ebase[yyval]); } nrwid(lp[p1], ps, lp[p1]); printf(".nr %d \\n(%d\n", yyval, lp[p1]); for (i = p1+1; i < p2; i++) { nrwid(lp[i], ps, lp[i]); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", lp[i], yyval, yyval, lp[i]); } printf(".ds %d \\v'%du'\\h'%du*\\n(%du'\\\n", yyval, ebase[yyval], type == 'R' ? 1 : 0, yyval); for (i = p2-1; i >= p1; i--) { hi = eht[lp[i]]; bi = ebase[lp[i]]; switch (type) { case 'L': printf("\\v'%du'\\*(%d\\h'-\\n(%du'\\v'0-%du'\\\n", -bi, lp[i], lp[i], hi-bi+gap); continue; case 'R': printf("\\v'%du'\\h'-\\n(%du'\\*(%d\\v'0-%du'\\\n", -bi, lp[i], lp[i], hi-bi+gap); continue; case 'C': case '-': printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d", -bi, yyval, lp[i], lp[i]); printf("\\h'-\\n(%du-\\n(%du/2u'\\v'0-%du'\\\n", yyval, lp[i], hi-bi+gap); continue; } } printf("\\v'%du'\\h'%du*\\n(%du'\n", eht[yyval]-ebase[yyval]+gap, type != 'R' ? 1 : 0, yyval); for (i = p1; i < p2; i++) ofree(lp[i]); lfont[yyval] = rfont[yyval] = 0; }
void shift2(int p1, int p2, int p3) { int effps, h1, h2, h3, b1, b2, b3, subsh, d1, d2, supsh, treg; #ifndef NEQN int effps2; #endif /* NEQN */ treg = oalloc(); yyval = p1; if (dbg) printf(".\tshift2 s%d <- %d %d %d\n", yyval, p1, p2, p3); effps = EFFPS(ps+deltaps); #ifndef NEQN eht[p3] = h3 = VERT((eht[p3] * effps) / EFFPS(ps)); ps += deltaps; effps2 = EFFPS(ps+deltaps); #endif /* NEQN */ h1 = eht[p1]; b1 = ebase[p1]; h2 = eht[p2]; b2 = ebase[p2]; #ifndef NEQN b3 = ebase[p3]; d1 = VERT(EM(0.5, effps2)); #else /* NEQN */ h3 = eht[p3]; b3 = ebase[p3]; d1 = VERT(1); #endif /* NEQN */ subsh = -d1+h2-b2; if (d1+b1 > h2) /* move little sub down */ subsh = b1-b2; #ifndef NEQN supsh = -VERT((4*(h1-b1))/10) - b3; d2 = VERT(EM(0.2, effps)); if (VERT(4*(h1-b1)/10)+h3 < h1-b1) #else /* NEQN */ supsh = - VERT(1) - b3; d2 = VERT(1); if (VERT(1)+h3 < h1-b1) #endif /* NEQN */ supsh = -(h1-b1) + (h3-b3) - d2; #ifndef NEQN eht[yyval] = h1 + max(0, h3-VERT((6*(h1-b1))/10)) + max(0, h2-b1-d1); #else /* NEQN */ eht[yyval] = h1 + max(0, h3-VERT(1)) + max(0, h2-b1-d1); #endif /* NEQN */ ebase[yyval] = b1+max(0, h2-b1-d1); #ifndef NEQN if (rfont[p1] == ITAL && lfont[p2] == ROM) printf(".ds %d \\|\\*(%d\n", p2, p2); if (rfont[p2] == ITAL) printf(".as %d \\|\n", p2); #endif /* NEQN */ nrwid(p2, effps, p2); #ifndef NEQN if (rfont[p1] == ITAL && lfont[p3] == ROM) printf(".ds %d \\|\\|\\*(%d\n", p3, p3); else printf(".ds %d \\|\\*(%d\n", p3, p3); #endif /* NEQN */ nrwid(p3, effps, p3); printf(".nr %d \\n(%d\n", treg, p3); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); #ifndef NEQN printf(".as %d \\v'%du'\\s%d\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", p1, subsh, effps, p2, p2, -subsh+supsh); printf("\\s%d\\*(%d\\h'-\\n(%du+\\n(%du'\\s%d\\v'%du'\n", effps, p3, p3, treg, effps2, -supsh); #else /* NEQN */ printf(".as %d \\v'%du'\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", p1, subsh, p2, p2, -subsh+supsh); printf("\\*(%d\\h'-\\n(%du+\\n(%du'\\v'%du'\n", p3, p3, treg, -supsh); #endif /* NEQN */ ps += deltaps; #ifndef NEQN if (rfont[p2] == ITAL) rfont[yyval] = 0; /* lie */ #endif /* NEQN */ ofree(p2); ofree(p3); ofree(treg); }
void diacrit(int p1, int type) { int c, t; c = salloc(); t = salloc(); nrwid(p1, ps, p1); printf(".nr 10 %gm\n", max(REL(eht[p1]-ebase[p1]-1,ps), 0)); /* vert shift if high */ if (type == HIGHBAR) printf(".nr 10 \\n(10+%gm\n", Dvshift); else if (type == LOWBAR) printf(".nr 10 0\n"); else printf(".if \\n(ct>1 .nr 10 \\n(10+%gm\n", Dvshift); printf(".nr %d %gm\n", t, Dhshift); /* horiz shift if high */ printf(".if \\n(ct>1 .nr %d %gm\n", t, Dh2shift); /* was .1 and .15 */ switch (type) { case VEC: printf(".ds %d %s\n", c, lookup(deftbl, "vec_def")->cval); break; case DYAD: printf(".ds %d %s\n", c, lookup(deftbl, "dyad_def")->cval); break; case HAT: printf(".ds %d %s\n", c, lookup(deftbl, "hat_def")->cval); break; case TILDE: printf(".ds %d %s\n", c, lookup(deftbl, "tilde_def")->cval); break; case DOT: printf(".ds %d %s\n", c, lookup(deftbl, "dot_def")->cval); break; case DOTDOT: printf(".ds %d %s\n", c, lookup(deftbl, "dotdot_def")->cval); break; case BAR: case LOWBAR: case HIGHBAR: printf(".ds %d \\v'%gm'\\h'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n", c, -Barv, Barh, p1, 2*Barh, Barh, Barv); break; case UNDER: printf(".ds %d \\v'%gm'\\l'\\n(%du-%gm\\(ul'\\h'%gm'\\v'%gm'\n", c, -Ubarv, p1, Ubarh, Ubarh, Ubarv); /* printf(".ds %d \\v'-%gm'\\l'\\n(%du\\(ul'\\v'%gm'\n", c, Ubarv, p1, Ubarv); */ printf(".nr %d 0\n", t); printf(".nr 10 0-.1m-%gm\n", REL(ebase[p1],ps)); printf(".if \\n(ct%%2=1 .nr 10 0\\n(10-.1m\n"); break; case UTILDE: printf(".ds %d %s\n", c, lookup(deftbl, "utilde_def")->cval); printf(".nr %d 0\n", t); printf(".nr 10 0-%gm\n", REL(ebase[p1],ps)); printf(".if \\n(ct%%2=1 .nr 10 0\\n(10-%gm\n", 0.1); break; } nrwid(c, ps, c); if (lfont[p1] != ITAL) printf(".nr %d 0\n", t); printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d", p1, p1, c, t, c); printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t); if (type != UNDER && type != UTILDE) eht[p1] += EM(Dheight, ps); /* was .15 */ dprintf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%g, b=%g\n", type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]); sfree(c); sfree(t); }