File: equationh.lex

package info (click to toggle)
tth 4.08+ds-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,376 kB
  • ctags: 124
  • sloc: xml: 291; makefile: 174; sh: 168; ansic: 131
file content (1399 lines) | stat: -rw-r--r-- 50,679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
<equation>\\lefteqn { 
  if(!eqalignrow) mkkey(eqstr,eqstrs,&eqdepth);       /* Start new row */ 
  if(tth_istyle&1)eqalignrow=eqalignrow+6*(levhgt[eqclose]-1)+TTH_HGT;else
    eqalignrow=eqalignrow+levhgt[eqclose];
  levhgt[eqclose]=1; /* new */ 
  TTH_TEX_FN("{#1}\\tth_lefteq#tthdrop1",1);
}

<equation>\\stackrel   {
  TTH_TEX_FN("{\\buildrel{#1}\\over{#2}}#tthdrop2",2);
}

<equation>{NL}  TTH_CHECK_LENGTH;  TTH_INC_LINE;
 
<equation>\\cr(cr)?{WSP}*\}  {
  TTH_INC_MULTI;
  if(*halstring){ /* halign and tabular */
    TTH_SCAN_STRING("\\tth_halcr}");
  }else{
    unput('}');
  }
} /* see also at \begin{array} = \matrix */

 /* Version that uses tabular code: */
<equation>\\end\{array\}  TTH_SCAN_STRING("\\end{tabular}");

<equation>\\end\{eqnarray\*?\} {
  if(tth_debug&2)fprintf(stderr,"end eqnarray, eqdepth=%d, eqclose=%d, tth_multinum=%d, eqalignlog=%d.\n",eqdepth,eqclose,tth_multinum,eqalignlog);
  TTH_SCAN_STRING("}}\\tth_endeqnarray"); 
}
<equation>\\nonumber  if(eqalignlog <= 100) eqalignlog=eqalignlog+100;
 /* Font faces and styles etc.*/
<equation,tokexp,exptokarg>\\mathrm  TTH_SWAP("\\rm ");
<equation,exptokarg>\\boldsymbol |
<equation,tokexp,exptokarg>\\mathbf  TTH_SWAP("\\bf ");
<equation,tokexp,exptokarg>\\mathit   TTH_SWAP("\\it ");
<equation,tokexp,exptokarg>\\mathcal  TTH_SWAP("\\it ");
<equation,tokexp,exptokarg>\\mathtt   TTH_SWAP("\\tt ");
<equation,tokexp,exptokarg>\\mathsf   TTH_SWAP("\\sffamily ");
<equation>\\mit{SP}*
<equation>\\ifmmode{WSP}* TTH_INC_MULTI; 
<equation>\\iff TTH_MATHI(219);


<equation>&   {
 /* halign */
  /*if(*halstring) {TTH_SCAN_STRING("}\\tth_mhamper{");*/
  if(*halstring) {TTH_SCAN_STRING("\\tth_mhamper");
  }else{ yy_push_state(mamper);
  }
 }
<equation>\\tth_mhamper   yy_push_state(hamper);

 /* hamper for halign */
<mamper>{WSP}  TTH_INC_MULTI;  
<mamper>{ANY}  {  
  yyless(0);yy_pop_state();
  tth_enclose(TTH_EQA1,eqstr,TTH_EQA2,eqstore);
  if(eqaligncell && !tth_LaTeX && eqalignlog){ 
    /* This ends the second cell of eqaligno. */
    strcat(eqstr,TTH_CELL_R);
  } else strcat(eqstr,TTH_EQA3);
  if(eqaligncell) {
    tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
    rmkey(eqstrs,&eqdepth);
  }
  mkkey(eqstr,eqstrs,&eqdepth);
  *eqstr=0;
  eqaligncell++;
}

<equation,mamper>\\multispan   TTH_TEX_FN("\\tthemultispan{#1}#tthdrop1",1);
<equation,mamper>\\multicolumn   TTH_TEX_FN("\\tthemultispan{#1}#tthdrop2",2);
  /*  interior in array */
<mamper>\\tthemultispan\{[0-9]+\} {
  yy_pop_state();  
  chscratch=strstr(yytext,"multi");
  TTH_CCPY(argchar,chscratch+strcspn(chscratch,"{")+1);
  *(argchar+strcspn(argchar,"}"))=0;
  tth_enclose(TTH_EQA1,eqstr,TTH_EQA2,eqstore);
  sprintf(eqstr+strlen(eqstr),"%s\"%s\"%s\n",TTH_EQA4,argchar,">");
  if(eqaligncell) {
    tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
    rmkey(eqstrs,&eqdepth);
  }
  mkkey(eqstr,eqstrs,&eqdepth);
  *eqstr=0;
  eqaligncell++;
 }
<equation>\\tthemultispan\{[0-9]+\} { /* line start in array */
  chscratch=strstr(yytext,"multi");
  TTH_CCPY(argchar,chscratch+strcspn(chscratch,"{")+1);
  *(argchar+strcspn(argchar,"}"))=0;
  sscanf(argchar,"%d",&colspan);
 }
<mamper>\\[a-zA-Z@]+   { /* expand first */
  TTH_DO_MACRO
  else{
    yyless(0);yy_pop_state();
    tth_enclose(TTH_EQA1,eqstr,TTH_EQA2,eqstore);
    if(eqaligncell && !tth_LaTeX && eqalignlog){ 
      /* This ends the second cell of eqaligno. */
      strcat(eqstr,TTH_CELL_R);
    } else strcat(eqstr,TTH_EQA3);
    if(eqaligncell) {
      tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
      rmkey(eqstrs,&eqdepth);
    }
    mkkey(eqstr,eqstrs,&eqdepth);
    *eqstr=0;
    eqaligncell++;
  }
}

<equation>\\noalign  { 
  if(tth_debug&33) fprintf(stderr,"noalign in equation:\n");
  if(!eqalignrow) mkkey(eqstr,eqstrs,&eqdepth);
  if(tth_istyle&1)eqalignrow=eqalignrow+6*(levhgt[eqclose]-1)+TTH_HGT;else
    eqalignrow=eqalignrow+levhgt[eqclose];
  levhgt[eqclose]=1;
  strcpy(eqstr,TTH_NOALIGN);
  TTH_TEX_FN("{#1}\\special{html:</td></tr>}\\tth_eqfin#tthdrop1",1);
  }
<equation>\\\\\*?{SP}*(\[[^\]]*\])? | /* Was later. */
<equation>\\tth_cr |
<equation>\\cr(cr)? {  
  if(eqclose && (active[eqclose-1] || mtrx[eqclose-1])){ 
    /* If this is really an array-type environment. */
    if(tth_debug&16)fprintf(stderr,
	"Active tth_cr. yytext=%s eqclose=%d, active=%d\n",
			    yytext,eqclose,active[eqclose-1]);
    if(strstr(yytext,"tth_")){ /* Prefix special opening */
      sprintf(scrstring,TTH_EQ11,
	      (lefteq ? "left":(eqalignlog ?"right":"center")),colspan);
	      /*(colspan? colspan : 1)); Avoid colspan=0; not now necc.*/
      tth_enclose(scrstring,eqstr,TTH_EQA2,eqstore);
    }else{
      /* Next line ensures \cr is equivalent to \nonumber\\ */
      if(strstr(yytext,"\\cr"))if(eqalignlog <= 100) eqalignlog=eqalignlog+100;
      tth_enclose(TTH_EQA1,eqstr,TTH_EQA2,eqstore);  
    }
    if(tth_debug&16)fprintf(stderr,
   "TTH_CR, eqalignlog=%d, colspan=%d, envirchar=%s, tth_multinum=%d, tth_LaTeX=%d.\n",
	   eqalignlog,colspan,envirchar,tth_multinum,tth_LaTeX);
    if(eqaligncell){ /* If there is a preceding & (cell) prefix it. */
      tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
      rmkey(eqstrs,&eqdepth);
    }
    /* If this row is an eqalign or is not the first.*/
    if((eqalignlog&&(eqalignlog-100))||eqalignrow){
      sprintf(eqchar,((eqalignlog&&(eqalignlog-100))?TTH_EQ7:TTH_EQ10),
	      (lefteq ? "left":((eqalignlog&&(eqalignlog-100)) ?
				"right":"center")),colspan);
      tth_prefix(eqchar,eqstr,eqstore); /* Prefix its opening */
      *eqchar=0;
    }
    if(eqalignrow){                     /* If this row is not the first.*/
      tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore); /* Prefix previous row */
      rmkey(eqstrs,&eqdepth);
    }
    if(tth_LaTeX && tth_multinum && strlen(envirchar) && (eqalignlog==1) ){
      strcat(eqstr,TTH_EQ8);
      strcpy(scratchstring,"(\\theequation)");
    }else{
      if((eqalignlog>1)&&(eqalignlog-100)) strcat(eqstr,TTH_EQ9);
      *scratchstring=0;
    }
    strcat(scratchstring,"\\tth_closerow");
    TTH_SCAN_STRING(scratchstring);
    /*mtrx[eqclose-1]=0; A mistake. Should be done only at end.*/
  }else if(*halstring){ /* halign and tabular */
    TTH_SCAN_STRING("\\tth_halcr");
  }else{
    fprintf(stderr,"**** Improper \\\\ or \\cr outside array environment ignored, Line %d.\n",tth_num_lines);
  }
}

<equation>\\tth_closerow {
  if(tth_LaTeX && tth_multinum && strlen(envirchar) && (eqalignlog==1) ){
    equatno++;sprintf(envirchar,"%d",equatno);tth_multinum++;
  }
  strcat(eqstr,"</td></tr>"); /* Close the row */
  *eqchar=0;
  mkkey(eqstr,eqstrs,&eqdepth);     /* Start new row */
  *eqstr=0;
  /* eqalignrow++; old */
  if(tth_istyle&1)eqalignrow=eqalignrow+6*(levhgt[eqclose]-1)+TTH_HGT;else
    eqalignrow=eqalignrow+levhgt[eqclose];
  levhgt[eqclose]=1; /* new */
  eqaligncell=0;
  lefteq=0;
  colspan=1;
  if(eqalignlog >= 100) eqalignlog=eqalignlog-100;
}

<equation,textbox>\{ {
  if(tth_debug&16) {
    fprintf(stderr,"Start Group {, eqdepth=%d, eqclose=%d, tth_flev=%d, levdelim=%s\n",eqdepth,eqclose,tth_flev,levdelim[eqclose]);
  }
  if(tth_flev < 0) tth_flev=tth_flev-99;
   mkkey(eqstr,eqstrs,&eqdepth);
   *eqstr=0;
   eqclose++;
   tophgt[eqclose]=0;
   levhgt[eqclose]=1;
   TTH_PUSH_CLOSING;
 }

<getsubp>\} {
  if(mtrx[eqclose-1] || active[eqclose-1] || tophgt[eqclose]){
    /* Terminate getsubp state */
    yyless(0);
    TTH_SCAN_STRING("#");
  }else{
  /* Just enter the brace termination code. */
    TTH_SCAN_STRING("\\tth_closebrace");
  }
}
<getsubp>\\tth_closebrace |
<equation,textbox>\} { 
  TTH_TEXCLOSE else{
  do{
  if(tth_debug&16) {
    if(active[eqclose]) {
    fprintf(stderr,
         "Active Group }, eqdepth=%d, eqclose=%d, tth_flev=%d, levdelim=%s, active=%d\n"
	    ,eqdepth,eqclose,tth_flev,levdelim[eqclose],active[eqclose]);}
    else {fprintf(stderr,
	      "Close Group }, eqdepth=%d, eqclose=%d, tth_flev=%d, levdelim=%s\n"
	       ,eqdepth,eqclose,tth_flev,levdelim[eqclose]);}
  }
  if(tophgt[eqclose] != 0){ /* If fraction */
    if(tth_debug&16)fprintf(stderr,"Fraction closing.\n");
    if(levhgt[eqclose] > 1 || (eqclose > tth_flev && TTH_COMPLEX)){ 
      /* If bottom contains a fraction or we are topped out. */
      /* Try bottom compression*/
      oa_removes=b_align(eqstr,tth_debug);
      tth_enclose(TTH_LEV1,eqstr,TTH_LEV2,eqstore);
    }else{ /* Put br at end if we are still closing a real cell */
      if((eqclose <= tth_flev) && (active[eqclose-1]!=30)) strcat(eqstr,TTH_BR);
    }
    tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
    rmkey(eqstrs,&eqdepth);
    TTH_CLOSEGROUP;TTH_POP_CLOSING; /* put closing before cell end */
    if(active[eqclose-1]!=30){ 
      /* CELL1/2 test for non-zero levdelim 0,+1 */
      tth_enclose(TTH_CELL1,eqstr,TTH_CELL2,eqstore); 
      if(eqclose <= tth_flev) yy_push_state(getsubp); 
      if(tth_debug&16) fprintf(stderr,"Whole fraction:%s\n",eqstr);
    }
  }else {
    TTH_CLOSEGROUP;TTH_POP_CLOSING;
  }
  if(eqclose > tth_flev) hgt=1; else hgt=tophgt[eqclose]+levhgt[eqclose];
  if(tth_debug&16) fprintf(stderr,"eqclose=%d,tth_flev=%d,hgt=%d,%d,%d\n",
	  eqclose,tth_flev,hgt,tophgt[eqclose],levhgt[eqclose]);
  if(levhgt[eqclose-1] < hgt) levhgt[eqclose-1]=hgt;
  if(tth_debug&2 && (levdelim[eqclose][0]||levdelim[eqclose+1][0]))
    fprintf(stderr,"Delimiting:%s%d%s\n",
	    levdelim[eqclose],hgt,levdelim[eqclose+1]);
  if(levdelim[eqclose][0]){
    delimit(levdelim[eqclose],hgt,eqchar);
  }
  if(levdelim[eqclose+1][0]){
    delimit(levdelim[eqclose+1],hgt,eqchar2);
  }
  /* Cut spurious cells off end of eqchar and eqstr if necessary*/
  chscratch=eqchar+strlen(eqchar)-strlen(TTH_CELL3);
  if( (strstr(chscratch,TTH_CELL3)==chscratch) &&
      (strstr(eqstr,TTH_CELL_START)==eqstr+strspn(eqstr," \n"))){ 
    *chscratch=0;
  }
  chscratch=eqstr+strlen(eqstr)-strlen(TTH_CELL3);
  if( (strstr(eqchar2,TTH_CELL_START)==eqchar2+strspn(eqchar2," \n")) &&
      (strstr(chscratch,TTH_CELL3)==chscratch) ){
    *chscratch=0;
  } /* Section could be combined with delimit immediately above. */
  /* rely on no delimiters on active closures. False for matrix. */
  if(levdelim[eqclose+1][0] && (hgt > 1)) yy_push_state(getsubp);
  *levdelim[eqclose]=0;
  *levdelim[eqclose+1]=0;

  tth_enclose(eqchar,eqstr,eqchar2,eqstore);
  *eqchar=0;
  *eqchar2=0;
  if(active[eqclose-1]==30){ /* eqlimited section for mathop, overbrace */
    if(tth_debug&2)fprintf(stderr,"Mathop eqlimited:%s\n",eqstr);
    if(strlen(eqlimited)+strlen(eqstr)< TTH_DLEN) {
      strcat(eqlimited,eqstr);
      if(tth_debug&2)fprintf(stderr,"EQlimited=||%s||\n",eqlimited);
    }else{
      fprintf(stderr,
          "Error: Fatal! Exceeded eqlimited storage. Over/underbrace too long.\n");
      TTH_EXIT(5);
    }
    strcpy(eqstr,eqstrs[eqdepth-1]);
    yy_push_state(getsubp);
    if(levhgt[eqclose] == 1)levhgt[eqclose]=2; /* Force fraction closure */
    active[eqclose-1]=0;
  }else{
    tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
  }
  rmkey(eqstrs,&eqdepth);
  if(tth_flev <  0) tth_flev=tth_flev+99;
  active[eqclose]=0;
  mtrx[eqclose]=0;
  eqclose--;
  if(eqclose < 0) {
    fprintf(stderr,"**** Error! Fatal! Negative closure count, line:%d\n",tth_num_lines);
    TTH_EXIT(4);
  }
  } while (active[eqclose]);
  if(tth_debug&16) fprintf(stderr,
   "Completing Close Group, eqdepth=%d, eqclose=%d, tth_flev=%d, levdelim=%s\n"
	    ,eqdepth,eqclose,tth_flev,levdelim[eqclose]);
  }
}

<equation>\$\$ {  /* Cope with ambiguous style at equation end */
  if(displaystyle){
    if(tth_debug&2)fprintf(stderr,"$$ in displaystyle\n");
    TTH_SCAN_STRING("}\\tth_endequation");
  }else{
    yyless(1);
    TTH_SCAN_STRING("}\\tth_endinline");
  }
 }

<equation>\\tth_endinline {
  TTH_TEXCLOSE else{
    if(tth_debug&2) fprintf(stderr,"Leaving inline eq, eqclose=%d, eqdepth=%d, tth_flev=%d, levhgt=%d, tophgt=%d\n",  
	      eqclose,eqdepth,tth_flev,levhgt[eqclose],tophgt[eqclose]);
    TTH_CLOSEGROUP;TTH_POP_CLOSING;
    if(tth_inlinefrac && (levhgt[eqclose]+tophgt[eqclose]>1))
      tth_enclose(TTH_TSTY1,eqstr,TTH_TSTY2,eqstore);
    if(eqdepth==1){
      rmkey(eqstrs,&eqdepth); /*eqdepth--;*/
      tth_flev=tth_flev0;
      horizmode=1;
      if(tth_tagpurge){
	tagpurge(eqstr);
	tth_tagpurge=0;
      }
      fprintf(tth_fdout,"%s",eqstr);*eqstr=0;
    }else{
      if(displaystyle)displaystyle--;
      eqdepth--;
      if(tth_debug&2)fprintf(stderr,
			     "Equation in a textbox inside an equation.\n");
      TTH_OUTPUT(TTH_TEXTBOX1);
    }
    yy_pop_state();
  }
}
 /* Force all equations to end enclosed. */
<equation>\\end\{equation\*?\} { 
  if(strstr(yytext,"*")==NULL){    /* end{equation} */
    if(tth_multinum < 2) { 
      TTH_SCAN_STRING("}\\tth_numbereq");
    }else {
      /* end of equation which needs to unincrement*/
      equatno--;
      TTH_SCAN_STRING("}\\tth_endequation");
    }
  }else {TTH_SCAN_STRING("}\\tth_endequation");} /* embracing essential */
}
<equation>\\end\{displaymath\} |
<equation>\\\]     TTH_SCAN_STRING("}\\tth_endequation");

<equation>\\tth_numbereq {
      strcat(eqstr,TTH_DISP3);
      TTH_SCAN_STRING("(\\theequation)\\tth_endnumbered");
}
<equation>\\tth_endeqnarray  equatno--;TTH_SCAN_STRING("\\tth_endequation");
<equation>\\tth_endequation |     
<equation>\\tth_endnumbered {
  TTH_TEXCLOSE else{
  eqaligncell=0;
  if(tth_debug&2) fprintf(stderr,
	 "End equation %d, %s. eqalignlog=%d, tth_eqwidth=%d\n",
		equatno,yytext,eqalignlog,tth_eqwidth);
  if(tth_multinum)tth_multinum=1;
  {
    if(eqalignlog){
      sprintf(scrstring,TTH_DISPE,tth_eqwidth);
      tth_enclose(scrstring,eqstr,TTH_DISP6,eqstore);
/*        tth_enclose(scrstring,eqstr,TTH_DISP4,eqstore); */
    }else{
      sprintf(scrstring,TTH_DISP1,tth_eqwidth);
      if(strstr(yytext,"numb")){
	tth_enclose(scrstring,eqstr,TTH_DISP4,eqstore);
      }else{
	tth_enclose(scrstring,eqstr,TTH_DISP2,eqstore);
      }
    }
    if(tth_debug&2) fprintf(stderr,
       "Leaving display eq, eqclose=%d, eqdepth=%d, tth_flev=%d\n",  
         eqclose,eqdepth,tth_flev);
    if(eqdepth==1){
      rmkey(eqstrs,&eqdepth);/*eqdepth--;*/
    }else{
      fprintf(stderr,
   "**** Error: Fatal Abnormal eqdepth %d on display equation exit, line %d\n",
	      eqdepth,tth_num_lines);TTH_EXIT(2);
    }
    if(eqclose > 0) { 
      fprintf(stderr,
    "**** Error: Fatal Abnormal eqclose %d on Display Equation End, line %d\n",
	      eqclose,tth_num_lines);TTH_EXIT(3);
    }
    yy_pop_state();
    tth_flev=tth_flev0; /* Necessary if textstyle has been used. */
    horizmode=1; /* Make sure we now recognize \n\n */
    displaystyle=0;
    *environment=0;
    eqalignlog=0;
    TTH_CLOSEGROUP;TTH_POP_CLOSING;
    fprintf(tth_fdout,"%s\n",eqstr);*eqstr=0;
  }
  }
}
 /* Single character fractions .*/
<equation>[\$\{]{WSP}*[0-9a-zA-Z]{WSP}*\\over{WSP}*[0-9a-zA-Z]{WSP}*[\$\}] {
  if(active[eqclose]){ /* reembrace to protect active closure */
    TTH_INC_MULTI; 
    sprintf(scratchstring,"{%s}",yytext);
    TTH_SCAN_STRING(scratchstring);
  }else  if((eqclose > tth_flev || !displaystyle)){
    TTH_INC_MULTI; 
    chscratch=yytext+strspn(yytext,"${ \t\n");
    chs2=strstr(chscratch,"\\over")+5;
    sprintf(scratchstring,"<sup>%c</sup>/<sub>%c</sub>",
	    *(chscratch),*(chs2+strspn(chs2," \t\r\n")));
    TTH_OUTPUT(scratchstring);
  }else{ /* split to prevent treatment */
    strcpy(scratchstring,yytext);
    jscratch=strspn(yytext,"${ \t");
    yyless(jscratch);
    *(scratchstring+jscratch)=0;
    TTH_SCAN_STRING(scratchstring);
  }
 }

<equation>{WSP}+\\(over|above|atop|choose) {
  TTH_INC_MULTI; 
  yyless(strspn(yytext," \t\r\n"));
}
<equation>\\(over|above|atop|choose){WSP}* {
  TTH_INC_MULTI; 
  if(tth_debug&16)fprintf(stderr,
	  "Over Close Group, depth=%d, eqclose=%d, levhgt=%d\n",
	  eqdepth,eqclose,levhgt[eqclose]);
  if(levhgt[eqclose] > 1 || (eqclose > tth_flev && TTH_COMPLEX)) {
    /* Remove unnecessary cell and bottoms from single cells*/
    oa_removes=b_align(eqstr,tth_debug);
    tth_enclose(TTH_LEV1,eqstr,TTH_LEV2,eqstore);
  }else { /* Fix a strange alignment problem. Removed 15 Oct 2003
    if((tth_istyle&1) && !strstr(yytext,"atop") && !strstr(yytext,"choose"))
      tth_prefix("&nbsp;",eqstr,eqstore); */
  }
  if(strstr(yytext,"atop") || strstr(yytext,"choose"))
     strcat(eqstr,TTH_ATOP);
  else strcat(eqstr,TTH_DIV);
  mkkey(eqstr,eqstrs,&eqdepth);
  *eqstr=0;
  tophgt[eqclose]=levhgt[eqclose]+1;
  levhgt[eqclose]=1; 
  if(strstr(yytext,"choose")){
    strcat(levdelim[eqclose],"(");
    tth_push_depth--;
    TTH_PRETEXCLOSE("\\tth_chooseclose");
    tth_push_depth++;
  }
 } 
<equation,getsubp>\\tth_chooseclose  strcpy(levdelim[eqclose+1],")");
     /*TTH_SCAN_STRING("\\right)"); doesn't work. Imbalances closures.*/

 /* End of Fraction*/

 /* Sub/p scripts. */
 /* Dont make prime a superscript, it becomes too small.
   This case will not be used if we are doing a full cell (getsubsup). */
<equation>\^\\prime{SP}*	TTH_MATHI(162); 
<equation>\^		{
  strcat(eqstr,TTH_SUP1);yy_push_state(exptokarg);
  TTH_CCPY(expchar,TTH_SUP2);
  }
<equation>\_		{
  strcat(eqstr,TTH_SUB1);yy_push_state(exptokarg);
  TTH_CCPY(expchar,TTH_SUB2);
  }
 /* Version that uses tabular:*/
<equation>\\begin{WSP}*\{array\}(\[.\])? {
  TTH_INC_MULTI; 
  TTH_SCAN_STRING("\\begin{tabular}");
}
<equation>\\eqalign(no)*{WSP}*\{	|
<equation>\\(border)?matrix{WSP}*\{ { /*border not really supported*/
  TTH_INC_MULTI; 
  TTH_HAL_PUSH;*halstring=0;
  if(strstr(yytext,"eq") != NULL) eqalignlog++;/*make both levels 1*/
  TTH_EQA_PUSH;
  /*This instead of the previous makes level 1 only. Intended for lone
   \eqno, but breaks the standard layout. So don't do it.*/
  /*  if(strstr(yytext,"eq") != NULL) eqalignlog++;*/
  TTH_PUSH_CLOSING;
  if(strstr(yytext,"eq") == NULL) eqalignlog=0;
  /*if(strstr(yytext,"eq") != NULL) eqalignlog++; else eqalignlog=0;*/
  if(tth_debug&2) {
    fprintf(stderr,
     "Matrix {, eqdepth=%d, eqclose=%d, eqalignlog=%d, tth_flev=%d, levdelim=%s.\n"
	    ,eqdepth,eqclose,eqalignlog,tth_flev,levdelim[eqclose]);
  }
  mkkey(eqstr,eqstrs,&eqdepth);
  eqclose++;
  *eqstr=0;
  levhgt[eqclose]=1;
  tophgt[eqclose]=0;
  eqaligncell=0;
  eqalignrow=0;
  tth_push_depth--;
  TTH_PRETEXCLOSE("\\tth_cr\\tth_matrixclose");
  tth_push_depth++;
  mtrx[eqclose-1]=1;
  if(tth_debug&16)fprintf(stderr,"Set Matrix: eqclose=%d,eqdepth=%d\n",eqclose,eqdepth);/**/
 }
<equation>\\tth_matrixclose {
  if(tth_debug&16) fprintf(stderr,"Matrix close %d, levhgt=%d, rows=%d\n",
			   eqclose,levhgt[eqclose],eqalignrow);
  if(tth_istyle&1) levhgt[eqclose]=(eqalignrow+6*(levhgt[eqclose]-1)+TTH_HGT)/6; else       levhgt[eqclose]=levhgt[eqclose]+eqalignrow;
  tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore);
  rmkey(eqstrs,&eqdepth);
  if(eqalignlog){
    /* For 50% but just first line */
    tth_enclose(TTH_EQ3,eqstr,TTH_EQ2,eqstore);
  }else{
    tth_enclose(TTH_EQ1,eqstr,TTH_EQ2,eqstore);
  }
  TTH_EQA_POP;
  TTH_HAL_POP;
  /* Enclose unless this is the end of an eqalign type construct. */
  if(eqaind || !eqalignlog)tth_enclose(TTH_CELL5,eqstr,TTH_CELL5,eqstore);
  active[eqclose-1]=0;
}

<equation>\\cases  {
  TTH_TEX_FN("\\mbox{\\left\\lbrace\\matrix{#1}\\right.}#tthdrop1",1);
}
<equation>\\pmatrix {
  TTH_TEX_FN("\\left(\\matrix{#1}\\right)#tthdrop1",1);
}

 /*  textboxes. Because of problems as subscript, removed this to builtins. 
     <equation,exptokarg>\\textrm    |
     but this does not generally seem to be a good plan.
     But the approach below breaks with unenclosed subscript texts.
 */
<equation,exptokarg>\\raisebox\{[^\}]*\}({SP}?\[[^\]]*\]){0,2}{SP}* |
<equation,exptokarg>\\[hvmf]box{WSP}* |
<equation,exptokarg>\\textrm    |
<equation,exptokarg>\\textmd    |
<equation,exptokarg>\\textnormal {
  TTH_INC_MULTI;
  strcpy(scratchstring,"\\tth_tbone");strcat(scratchstring,"\\rm ");  TTH_SCAN_STRING("\\tth_tbox");
}
<equation,exptokarg>\\textbf  {
  strcpy(scratchstring,"\\tth_tbone");strcat(scratchstring,"\\bf ");  TTH_SCAN_STRING("\\tth_tbox");
}
<equation,exptokarg>\\textsl |
<equation,exptokarg>\\textit {
  strcpy(scratchstring,"\\tth_tbone");strcat(scratchstring,"\\it ");  TTH_SCAN_STRING("\\tth_tbox");
}
<equation,exptokarg>\\texttt {
  strcpy(scratchstring,"\\tth_tbone");strcat(scratchstring,"\\tt ");  TTH_SCAN_STRING("\\tth_tbox");
}
<equation,exptokarg>\\textsf {
  strcpy(scratchstring,"\\tth_tbone");strcat(scratchstring,"\\sffamily ");  TTH_SCAN_STRING("\\tth_tbox");
}
<equation,exptokarg>\\textsc {
  strcpy(scratchstring,"\\tth_tbone");strcat(scratchstring,"\\scshape ");  TTH_SCAN_STRING("\\tth_tbox");
}
<equation>\\tth_tbox {
  if(tth_debug&2)fprintf(stderr,
    "Start textbox. eqclose %d. push_depth %d. Line %d\n"
			 ,eqclose,tth_push_depth,tth_num_lines);
  if(!displaystyle) yy_push_state(textbox);  
  TTH_SWAP(scratchstring);
  /* This had to be moved into tth_tbone */
  /*TTH_PRETEXCLOSE("\\tth_boxclose");*/
}
<exptokarg>\\tth_tbox {
  if(tth_debug&2)fprintf(stderr,
      "Start textbox exptokarg. Displaystyle %d. eqclose %d, push_depth %d, Line %d\n"
			 ,displaystyle,eqclose,tth_push_depth,tth_num_lines);
  yy_pop_state(); 
  if(!displaystyle)yy_push_state(textbox);
  yy_push_state(exptokarg); 
  TTH_SWAP(scratchstring);
}
<equation,textbox>\\tth_boxclose  { /* box closure*/
    if(tth_debug&2) fprintf(stderr,"Box closure, eqclose=%d\n",eqclose);
    if(!displaystyle) yy_pop_state(); /* textbox state end */
  }
<equation,textbox>\\tth_tbone  {
  if(tth_debug&8)fprintf(stderr,"tbone at push_depth %d\n",tth_push_depth);
  TTH_OUTPUT(TTH_TEXTBOX1);
  tth_push_depth--;TTH_PRETEXCLOSE("\\tth_boxclose");tth_push_depth++;
}
<equation,tokexp,exptokarg,textbox>\\hbox{SP}+to {GET_DIMEN;} /* Override new handling */

<equation>\$            |
<equation>(\\end|\\begin)\{math\} |
<equation>\\(\)|\()          {
  /* Deal with single $ or inline in display equations or boxes.*/
  if(displaystyle==1){ /* Open inline in box enclose it.*/
    if(tth_debug&2)fprintf(stderr,"Inline inside displaystyle.\n");
    TTH_SCAN_STRING("{$");
    displaystyle++;
  }else if(displaystyle==2){
    if(!strstr(tth_font_open[tth_push_depth],TTH_ITAL1)){
      strcat(tth_font_open[tth_push_depth],tth_font_open[0]);
      strcat(tth_font_close[tth_push_depth],tth_font_close[0]);   
    }
    displaystyle++;
  }else if(displaystyle==3){ /* End enclosure inserted. */
    if(tth_debug&2)fprintf(stderr,"End Inline inside displaystyle.\n");
    TTH_SCAN_STRING("}");
    displaystyle=1;
  }else if(strstr(tth_texclose[tth_push_depth],"tth_boxclose")) {
    if(tth_debug&2) fprintf(stderr,"Inline inside box.\n");
    if(!strstr(tth_font_open[tth_push_depth],TTH_ITAL1)){
      strcat(tth_font_open[tth_push_depth],tth_font_open[0]);
      strcat(tth_font_close[tth_push_depth],tth_font_close[0]); 
    }
  }else{
    TTH_SCAN_STRING("}\\tth_endinline");
  }
 }
		/* Math greek and symbols */
<equation>\\alpha{SP}*	TTH_MATHS("a");
<equation>\\beta{SP}*	TTH_MATHS("b");
<equation>\\gamma{SP}*	TTH_MATHS("g");
<equation>\\delta{SP}*	TTH_MATHS("d");
<equation>\\epsilon{SP}*	TTH_MATHS("e");
 /* <equation>\\varepsilon{SP}*	TTH_MATHS("e"); */ 
<equation>\\varepsilon{SP}* {
  if(tth_unicode){
    TTH_MATHI(129); /*Kludge for coding translation */
  }else{
    TTH_MATHS("e");
  }
}			  
<equation>\\zeta{SP}*	TTH_MATHS("z");
<equation>\\eta{SP}*   	TTH_MATHS("h")
<equation>\\theta{SP}*	TTH_MATHS("q");
<equation>\\vartheta{SP}*   TTH_MATHS("J");
<equation>\\iota{SP}*	TTH_MATHS("i");
<equation>\\kappa{SP}*	TTH_MATHS("k");
<equation>\\lambda{SP}*	TTH_MATHS("l");
<equation>\\lambdar{SP}*	TTH_MATHS("l");
<equation>\\mu{SP}*     	TTH_MATHS("m");
<equation>\\nu{SP}*     	TTH_MATHS("n");
<equation>\\xi{SP}*     	TTH_MATHS("x");
<equation>\\pi{SP}*      TTH_MATHS("p");
<equation>\\varpi{SP}*	TTH_MATHS("v");
<equation>\\rho{SP}*    	TTH_MATHS("r");
<equation>\\varrho{SP}*	TTH_MATHS("r");
<equation>\\sigma{SP}*	TTH_MATHS("s");
<equation>\\varsigma	TTH_MATHS("V");
<equation>\\tau{SP}*    	TTH_MATHS("t");
<equation>\\upsilon{SP}*	TTH_MATHS("u");
<equation>\\phi{SP}*    	TTH_MATHS("f");
<equation>\\varphi{SP}*	TTH_MATHS("j");
<equation>\\chi{SP}*    	TTH_MATHS("c");
<equation>\\psi{SP}*    	TTH_MATHS("y");
<equation>\\omega{SP}*	TTH_MATHS("w");
<equation>\\Gamma{SP}*	TTH_MATHS("G");
<equation>\\Delta{SP}*	TTH_MATHS("D");
<equation>\\Theta{SP}*	TTH_MATHS("Q");
<equation>\\Lambda	TTH_MATHS("L");
<equation>\\Xi{SP}*	TTH_MATHS("X");
<equation>\\Pi{SP}*     	TTH_MATHS("P");
<equation>\\Sigma{SP}*	TTH_MATHS("S");
<equation>\\Upsilon{SP}*	TTH_MATHS("U");
<equation>\\Phi{SP}*    	TTH_MATHS("F");
<equation>\\Psi{SP}*    	TTH_MATHS("Y");
<equation>\\Omega{SP}*	TTH_MATHS("W");

<equation>\\ell{SP}*     TTH_MATHC("<i>l</i>");
<equation>\\aleph{SP}*	TTH_MATHI(192);
<equation>\\imath{SP}*	TTH_MATHS("i"); 
<equation>\\jmath{SP}*	TTH_MATHC("j"); 
<equation>\\wp{SP}*  	TTH_MATHI(195);
<equation>\\cal{SP}*(R|\{R\}) |
<equation>\\Re{SP}*  	TTH_MATHI(194);
<equation>\\cal{SP}*(I|\{I\}) |
<equation>\\Im{SP}*  	TTH_MATHI(193);
<equation>\\partial{SP}*     TTH_MATHI(182);
<equation>\\infty{SP}*  	TTH_MATHI(165);
<equation>\\angle{SP}*  	TTH_MATHI(208);
<equation>\'{SP}*	TTH_MATHI(162);
<equation>\\prime{SP}*	TTH_MATHI(162);
<equation>\\emptyset{SP}*	TTH_MATHI(198);
<equation>\\nabla{SP}*	TTH_MATHI(209);
<equation>\\surd{SP}*	TTH_MATHI(214);
<equation>\|            |
<equation>\\vert{SP}* 	TTH_MATHS("|");
<equation>\\parallel{SP}* |
<equation>\\\|           |
<equation>\\Vert{SP}* 	TTH_MATHS("||");
<equation>\\lbrack{SP}*  TTH_MATHC("[");
<equation>\\rbrack{SP}*  TTH_MATHC("]");
<equation>\\lbrace{SP}*  TTH_MATHC("{");
<equation>\\rbrace{SP}*  TTH_MATHC("}");
<equation>\\rceil{SP}*   TTH_MATHI(249);
<equation>\\rfloor{SP}*  TTH_MATHI(251);
<equation>\\lceil{SP}*   TTH_MATHI(233);
<equation>\\lfloor{SP}*  TTH_MATHI(235);
<equation>\\langle{SP}*		TTH_MATHI(225);
<equation>\\rangle{SP}*		TTH_MATHI(241);
\\textbackslash{SP}*            |
<equation>\\backslash{SP}* 	|
<equation>\\setminus{SP}* 	TTH_MATHC("\\"); 
<equation>\\forall{SP}*	TTH_MATHS("\"");
<equation>\\exists{SP}*	TTH_MATHS("$");
<equation>\\neg{SP}*  	TTH_MATHI(216);
<equation>\\clubsuit{SP}*	TTH_MATHI(167);
<equation>\\diamondsuit{SP}*	TTH_MATHI(168);
<equation>\\heartsuit{SP}*	TTH_MATHI(169);
<equation>\\spadesuit{SP}*	TTH_MATHI(170);

<equation>-      TTH_MATHS("-");
  /*Risky. <equation>\+      TTH_MATHS("+"); */
<equation>\\top{SP}*         TTH_MATHC("T"); 
<equation>\\bot{SP}* 	|
<equation>\\perp{SP}*	TTH_MATHS("^");
<equation>\\circ{SP}*	TTH_MATHI(176);
<equation>\\\~{SP}*     	TTH_MATHC("&#126;"); 
<equation>\\sim{SP}*		TTH_MATHS(" ~ ");
<equation>\\pmod |     /* Incorrect for now; needs parens.*/
<equation>\\bmod{SP}*	TTH_MATHC(" mod ");
<equation>\<		TTH_MATHC(" &lt; ");
<equation>\>		TTH_MATHC(" &gt; ");
<equation>\<\<		|
<equation>\\ll{SP}*		TTH_MATHC(" &lt;&lt; ");
<equation>\>\>		|
<equation>\\gg{SP}*		TTH_MATHC(" &gt;&gt; ");
<equation>\\ast{SP}*		TTH_MATHS("*");
<equation>\\star{SP}*	TTH_MATHS("*");
<equation>\\diamond{SP}*	TTH_MATHI(224);
<equation>\\bullet{SP}*     	TTH_MATHI(183);
<equation>\\cdot{SP}*		TTH_MATHC("&#183;"); 
 /*<equation>\\cdot	TTH_MATHI(215);*/
<equation>\\cup{SP}* 	TTH_MATHI(200);
<equation>\\cap{SP}* 	TTH_MATHI(199);
<equation>\\pm{SP}*		TTH_MATHI(177);
<equation>\\mp{SP}*		TTH_MATHS("-&#177;");
<equation>\\lor{SP}* 	|
<equation>\\vee{SP}*		TTH_MATHI(218);
<equation>\\land{SP}*        |
<equation>\\wedge{SP}*	TTH_MATHI(217);
<equation>\\oplus{SP}*	TTH_MATHI(197);
<equation>\\otimes{SP}*	TTH_MATHI(196);
<equation>\\oslash{SP}*	TTH_MATHI(198);

<getsubp>\\tthtensor{WSP}*    TTH_INC_MULTI;/* Don't mess up if it is in wrong place*/
<equation>\\tthtensor{SP}* {
  if(eqclose <= tth_flev-1 && displaystyle){
    /*If we end with a CELL3, cut it off. */
    if( ((jscratch=strlen(eqstr)) >= (js2=strlen(TTH_CELL3))) && 
	strcmp(eqstr+jscratch-js2,TTH_CELL3) == 0){
      *(eqstr+jscratch-js2)=0;
    }
    strcat(eqstr,TTH_CELL_L);
    if(levhgt[eqclose] == 1)levhgt[eqclose]=2;
    if(hgt < 2) hgt=2;
    yy_push_state(getsubp);
  }
}

<equation>\\int{SP}* 	{
 if(eqclose > tth_flev-1 || !displaystyle ){
   TTH_MATHI(242); /* TTH_OUTPUT(" "); perhaps not */
 }else{
   delimit("&#242;",2,eqchar);
   strcat(eqstr,eqchar);
   *eqchar=0;
   if(levhgt[eqclose] == 1)levhgt[eqclose]=2;
   hgt=3;
   yy_push_state(getsubp);
 }
 }
<equation>\\oint{SP}*\\limits{SP}* 	|
<equation>\\oint{SP}* {
  if(eqclose > tth_flev-1){
    TTH_MATHC("(");TTH_MATHI(242);TTH_MATHC(")");
  }else{
    TTH_OINT;
    yy_push_state(getsubp);
  }
 }

<equation>\\bigcap{SP}*  TTH_LIMITOP(199);
<equation>\\bigcup{SP}*  TTH_LIMITOP(200);
<equation>\\bigvee{SP}*  TTH_LIMITOP(218);
<equation>\\bigwedge{SP}*  TTH_LIMITOP(217);
<equation>\\bigotimes{SP}*  TTH_LIMITOP(196);
<equation>\\bigoplus{SP}*  TTH_LIMITOP(197);
<equation>\\sum{SP}*  TTH_LIMITOP(229);
<equation>\\prod{SP}* TTH_LIMITOP(213);
<equation>\\int{SP}*\\limits{SP}* 	TTH_LIMITOP(242);
<equation>\\limits{SP}*  /* Drop a limits command if not combined */

<equation>\\bigcap{SP}*\\nolimits{SP}*  TTH_MATHI(199);
<equation>\\bigcup{SP}*\\nolimits{SP}*  TTH_MATHI(200);
<equation>\\bigvee{SP}*\\nolimits{SP}*  TTH_MATHI(218);
<equation>\\bigwedge{SP}*\\nolimits{SP}*  TTH_MATHI(217);
<equation>\\bigotimes{SP}*\\nolimits{SP}*  TTH_MATHI(196);
<equation>\\bigoplus{SP}*\\nolimits{SP}*  TTH_MATHI(197);
<equation>\\sum{SP}*\\nolimits{SP}*  TTH_MATHI(229);
<equation>\\prod{SP}*\\nolimits{SP}* TTH_MATHI(213);

<equation>\\div{SP}*  	TTH_MATHI(184);
<equation>\\times{SP}*		TTH_MATHC("&times;"); 
 /*<equation>\\times	TTH_MATHI(180);*/
<equation>\\le(ss)?sim{SP}*		TTH_MATHC(" &lt;~"); 
<equation>\\g(e|tr)sim{SP}*		TTH_MATHC(" &gt;~"); 

<equation>\\mid{SP}*    TTH_MATHC(" ");TTH_MATHC("|");TTH_MATHC(" ");
<equation>\\leq{SP}*	TTH_MATHC(" ");TTH_MATHI(163);TTH_MATHC(" ");
<equation>\\le{SP}*	TTH_MATHC(" ");TTH_MATHI(163);TTH_MATHC(" ");
<equation>\\ge{SP}*     TTH_MATHC(" ");TTH_MATHI(179);TTH_MATHC(" ");
<equation>\\geq{SP}*    TTH_MATHC(" ");TTH_MATHI(179);TTH_MATHC(" ");
<equation>\\equiv{SP}*	TTH_MATHC(" ");TTH_MATHI(186);TTH_MATHC(" ");
<equation>\\approx{SP}*	TTH_MATHC(" ");TTH_MATHI(187);TTH_MATHC(" ");
<equation>\\not{SP}*={SP}*        |
<equation>\\neq{SP}*	TTH_MATHC(" ");TTH_MATHI(185);TTH_MATHC(" ");
<equation>\\ne{SP}*	TTH_MATHC(" ");TTH_MATHI(185);TTH_MATHC(" ");
<equation>\\not\\subset{SP}*	TTH_MATHC(" ");TTH_MATHI(203);TTH_MATHC(" ");
<equation>\\subset{SP}*	TTH_MATHC(" ");TTH_MATHI(204);TTH_MATHC(" ");
<equation>\\subseteq{SP}*  TTH_MATHC(" ");TTH_MATHI(205);TTH_MATHC(" ");
<equation>\\supset{SP}*	TTH_MATHC(" ");TTH_MATHI(201);TTH_MATHC(" ");
<equation>\\supseteq{SP}*  TTH_MATHC(" ");TTH_MATHI(202);TTH_MATHC(" ");
<equation>\\in{SP}*	TTH_MATHC(" ");TTH_MATHI(206);TTH_MATHC(" ");
<equation>\\not\\in{SP}* |
<equation>\\notin{SP}*	TTH_MATHC(" ");TTH_MATHI(207);TTH_MATHC(" ");
<equation>\\ni{SP}*  |
<equation>\\owns{SP}*    TTH_MATHC(" ");TTH_MATHI(39);TTH_MATHC(" ");
<equation>\\simeq{SP}*  |
<equation>\\cong{SP}*    TTH_MATHC(" ");TTH_MATHI(64);TTH_MATHC(" ");
<equation>\\propto{SP}*	TTH_MATHC(" ");TTH_MATHI(181);TTH_MATHC(" ");
<equation>\\gets          |
<equation>\\leftarrow	    TTH_MATHI(172);
<equation>\\longleftarrow   TTH_MATHI(172);
   /* A slight kludge */
<equation>\\longmapsto |
<equation>\\mapsto |
<equation>\\to  |
<equation>\\rightarrow	    TTH_MATHI(174);
<equation>\\longrightarrow  TTH_MATHI(174);
<equation>\\uparrow	    TTH_MATHI(173);
<equation>\\downarrow	    TTH_MATHI(175);
<equation>\\updownarrow	    TTH_MATHC(yytext);
<equation>\\Updownarrow	    TTH_MATHC(yytext);
<equation>\\longleftrightarrow |
<equation>\\leftrightarrow  TTH_MATHI(171);
<equation>\\Leftarrow	    TTH_MATHI(220);
<equation>\\Longleftarrow   TTH_MATHI(220);
<equation>\\Rightarrow	    TTH_MATHI(222);
<equation>\\Longrightarrow  TTH_MATHI(222);
<equation>\\RA		    TTH_MATHC(yytext);
<equation>\\Longleftrightarrow |
 /* moved before if code <equation>\\iff TTH_MATHI(219); */
<equation>\\Leftrightarrow  TTH_MATHI(219);
<equation>\\Uparrow	    TTH_MATHI(221);
<equation>\\Downarrow	    TTH_MATHI(223);
 /* <equation>\\dots{SP}*	TTH_MATHI(188); Not in math mode */
<equation>\\dotsb{SP}*	TTH_MATHI(188);
<equation>\\dotsc{SP}*	TTH_MATHI(188);
<equation>\\dotsi{SP}*	TTH_MATHI(188);
<equation>\\ldots{SP}*	TTH_MATHI(188);
<equation>\\cdots{SP}*	TTH_MATHI(188);
<equation>\\ddots{SP}*   TTH_OUTPUT("<sup><big>&#183;</big></sup>&#183;<sub><big>&#183;</big></sub>");
<equation>\\vdots{SP}*   TTH_OUTPUT(":");
<equation>\\atsign{SP}*		TTH_MATHC("@");
\\dag |
<equation>\\dagger       TTH_OUTPUT(TTH_DAG);
\\ddag |
<equation>\\ddagger       TTH_OUTPUT(TTH_DDAG);

<equation>\\arccos{SP}*		TTH_MATHC("arccos");  
<equation>\\arcsin{SP}*		TTH_MATHC("arcsin");  
<equation>\\arctan{SP}*		TTH_MATHC("arctan");  
<equation>\\arg{SP}*		TTH_MATHC("arg");  
<equation>\\cos{SP}*		TTH_MATHC("cos");  
<equation>\\cosh{SP}*		TTH_MATHC("cosh");  
<equation>\\cot{SP}*		TTH_MATHC("cot");  
<equation>\\coth{SP}*		TTH_MATHC("coth");  
<equation>\\csc{SP}*		TTH_MATHC("csc");  
 /* <equation>\\deg{SP}*        TTH_MATHC("&deg;");  Incorrect TeX */
<equation>\\deg{SP}*		TTH_MATHC("deg");
<equation>\\dim{SP}*		TTH_MATHC("dim");  
<equation>\\exp{SP}*		TTH_MATHC("exp");  
<equation>\\hom{SP}*		TTH_MATHC("hom");  
<equation>\\ker{SP}*		TTH_MATHC("ker");  
<equation>\\lg{SP}*		TTH_MATHC("lg");  
<equation>\\ln{SP}*		TTH_MATHC("ln");  
<equation>\\log{SP}*		TTH_MATHC("log");  
<equation>\\sec{SP}*		TTH_MATHC("sec");  
<equation>\\sin{SP}*		TTH_MATHC("sin");  
<equation>\\sinh{SP}*		TTH_MATHC("sinh");  
<equation>\\tan{SP}*		TTH_MATHC("tan");   
<equation>\\tanh{SP}*		TTH_MATHC("tanh");  

<equation>\\Pr{SP}*(\\(no)?limits{SP}*)?	|
<equation>\\inf{SP}*(\\(no)?limits{SP}*)?     |
<equation>\\gcd{SP}*(\\(no)?limits{SP}*)?	|
<equation>\\det{SP}*(\\(no)?limits{SP}*)?	|
<equation>\\max{SP}*(\\(no)?limits{SP}*)?     |
<equation>\\min{SP}*(\\(no)?limits{SP}*)?     |
<equation>\\sup{SP}*(\\(no)?limits{SP}*)?     |
<equation>\\liminf{SP}*(\\(no)?limits{SP}*)?	|
<equation>\\limsup{SP}*(\\(no)?limits{SP}*)?	|
<equation>\\lim{SP}*(\\(no)?limits{SP}*)?	{
  if(strstr(yytext,"nolimit")){js2=0;}else{js2=1;}
  *(yytext+1+strcspn(yytext+1," \\"))=0;
  if(eqclose >tth_flev-1 || js2==0){          TTH_MATHC(yytext+1);
  }else{
    strcat(eqstr,TTH_CELL3);
    strcat(eqlimited,yytext+1);
    oa_removes=0;
    yy_push_state(getsubp);
    if(levhgt[eqclose] == 1) levhgt[eqclose]=2; /* Force fraction closure */
  }
 }
<equation>\\mathop{WSP}*\{ |
<equation>\\(over|under)brace{WSP}*\{ {
 if(eqclose > tth_flev-1 || !displaystyle ){
   unput('{');
 }else{
  TTH_INC_MULTI; 
  strcat(eqstr,TTH_CELL3);
  mkkey(eqstr,eqstrs,&eqdepth);
  eqclose++;
  if(tth_flev<0)tth_flev=tth_flev-99;
  TTH_PUSH_CLOSING;
  active[eqclose-1]=30;
    /*TTH_PRETEXCLOSE("\\tth_eqlimited");*/
  oa_removes=0;
  if(*(yytext+1) == 'o'){
    TTH_CCPY(closing,TTH_OBRB);
    strcpy(eqstr,TTH_OBR);
  }else if(*(yytext+1) == 'u'){
    TTH_CCPY(closing,TTH_OBR);
    strcpy(eqstr,TTH_OBRB); 
  }else {
    strcpy(eqstr,"");
    unput(' ');
  }
  mkkey(eqstr,eqstrs,&eqdepth);
  *eqstr=0;
  tophgt[eqclose]=1;
  levhgt[eqclose]=1;
  active[eqclose]=1;
  unput('{');
 }
}
<equation>\\tth_eqlimited  { /* not done eqlimited section for mathop, overbrace */
    if(tth_debug&2)fprintf(stderr,"Mathop eqlimited:%s\n",eqstr);
    if(strlen(eqlimited)+strlen(eqstr)< TTH_DLEN) {
      strcat(eqlimited,eqstr);
      if(tth_debug&2)fprintf(stderr,"EQLIMITED=||%s||\n",eqlimited);
    }else{
      fprintf(stderr,
          "Error: Fatal! Exceeded eqlimited storage. Over/underbrace too long.\n");
      TTH_EXIT(5);
    }
    *eqstr=0;
    /*strcpy(eqstr,eqstrs[eqdepth-1]);*/
    yy_push_state(getsubp);  /*Does not work here */
    if(levhgt[eqclose] == 1)levhgt[eqclose]=2; /* Force fraction closure */
    /*active[eqclose-1]=0;*/
}
 /* end of symbols */

<equation>\\ensuremath    /* Nothing needs doing */
<equation>\\overrightarrow	TTH_SWAP("\\buildrel\\rightarrow\\over ");
<equation>\\overleftarrow	TTH_SWAP("\\buildrel\\leftarrow\\over ");

 /* Above accents expressed with braces. Removed {WSP} 11 Apr */
<equation>\\bar\{.\} { /* single character bar; convert to \sar */
  *(yytext+1)='s';
  TTH_SCAN_STRING(yytext);
 }
<equation>\\qrt\{       |
<equation>\\(wide)?hat\{   |
<equation>\\vec\{   |
<equation>\\(wide)?tilde\{ |
<equation>\\dd?ot\{   |
<equation>\\sar\{   |    /* single character bar tth special; see above */
<equation>\\bar\{	|    /* using a rule for multiple characters barred.*/ 
<equation>\\overline\{ {
  if(tth_debug&2) {
    fprintf(stderr,"Start Overaccent {, eqdepth=%d, eqclose=%d, tth_flev=%d, levdelim=%s.\n",eqdepth,eqclose,tth_flev,levdelim[eqclose]);
  }
  if(*(yytext+2)=='d') *(yytext+1)='2';
  if(strstr(yytext,"wide")==yytext+1) yytext=yytext+4; /* skip wide */
  if(eqclose > tth_flev && *(yytext+1)=='q'){TTH_OUTPUT(scratchstring);}
  if(eqclose > tth_flev && tth_istyle&2 && *(yytext+1)!='q'){
    /* Testing of stylesheet aproach for inline use: -w2 not Netscape. */
    switch(*(yytext+1)){
    case 'h':      TTH_OUTPUT("<span class=\"overacc1\">");TTH_MATHI(217);
      TTH_OUTPUT("</span>");break;
    case 't':TTH_OUTPUT("<span class=\"overacc1\">~</span>");break;
    case 'o': case 'b': case 's': 
      TTH_OUTPUT("<span class=\"overacc2\">");TTH_MATHI(190);
      TTH_OUTPUT("</span>");break;
    case 'd':TTH_OUTPUT("<span class=\"overacc1\">&#183; </span>");break;
    case '2':TTH_OUTPUT("<span class=\"overacc1\">&#183;&#183; </span>");break;
    case 'v':
      TTH_OUTPUT("<span class=\"overacc2\">");TTH_MATHI(174);
      TTH_OUTPUT("</span>");break;
    }
  }else{ /*Display or non-style in-line*/
    mkkey(eqstr,eqstrs,&eqdepth);
    eqclose++;
    *eqstr=0;
    if(tth_flev<0)tth_flev=tth_flev-99;
    TTH_PUSH_CLOSING;
    if(eqclose > tth_flev){ /* Inline levels will be enclosed in [()]. */
      TTH_CCPY(closing,"");
      switch(*(yytext+1)){
      case 'o': case 'b': case 's': TTH_MATHS("`");break;
      case 'd': TTH_CCPY(closing,"\\dot");break;
      case '2': TTH_CCPY(closing,"\\ddot");break;
      case 't': TTH_CCPY(closing,"\\tilde");break;
      case 'h': TTH_MATHC("^");break;
      case 'v': TTH_CCPY(closing,"\\vec");break;
      case 'q': /* output moved above to fix inline */ break;
      default : fprintf(stderr,"Overaccent error:%s,%d\n",yytext,*(yytext+1));
      }
    }else{ /* Display case*/ 
      TTH_CCPY(closing,TTH_OA3);
      switch(*(yytext+1)){
      case 'o': strcpy(eqstr,TTH_DIV);
	strcat(eqstr,TTH_OA5);TTH_CCPY(closing,TTH_OA3);
	break;
      case 'b': case 's': TTH_OUTPUT(TTH_OA1);
	TTH_OUTPUT((tth_istyle&1 ? "-":"_"));TTH_OUTPUT(TTH_OA2);break;
      case 'd': TTH_OUTPUT(TTH_OA1); 
	if(tth_istyle&1) {TTH_MATHI(215);} else {TTH_OUTPUT(".");}
	TTH_OUTPUT(TTH_OA2);break;
      case '2': TTH_OUTPUT(TTH_OA1);
	if(tth_istyle&1) {TTH_MATHI(215);TTH_MATHI(215);} else 
	  {TTH_OUTPUT("..");} TTH_OUTPUT(TTH_OA2);break;
	  /* case '2': strcpy(eqstr,"..<br />");break; */
      case 't':TTH_OUTPUT(TTH_OA1);TTH_OUTPUT("~");strcat(eqstr,TTH_OA2);break;
      case 'h':TTH_OUTPUT(TTH_OA1);TTH_OUTPUT("^");strcat(eqstr,TTH_OA2);break;
      case 'v':TTH_OUTPUT(TTH_OA1);TTH_MATHI(174);TTH_OUTPUT(TTH_OA2);break;
	/* case 'v': TTH_MATHI(174);strcat(eqstr,"<br />");break; */
      case 'q': {
      if(tth_debug&2)fprintf(stderr,"qrtlen=%d\n",qrtlen);
      sprintf(eqstr,"</td><td nowrap=\"nowrap\" align=\"left\">%s&nbsp;&nbsp;",TTH_OA1);
      for(i=0;i<qrtlen2;i++) strcat(eqstr,"&nbsp;");
      if(tth_istyle&1){
	TTH_OUTPUT(TTH_SYMBOL);
	chr1[0]=190;
	for(i=0;i<0.6*qrtlen-.22;i++) strcat(eqstr,TTH_SYMPT(chr1));
	TTH_OUTPUT(TTH_SYMEND);
      }else       for(i=0;i<qrtlen;i++) strcat(eqstr,"_");
      TTH_OUTPUT(TTH_OA2);
      strcat(eqstr,TTH_large);
      TTH_OUTPUT(scratchstring);
      strcat(eqstr,TTH_SIZEEND);
      break;
      }
      default : fprintf(stderr,"Overaccent error:%s,%d\n",yytext,*(yytext+1));
      }
    }
    mkkey(eqstr,eqstrs,&eqdepth);
    *eqstr=0;
    tophgt[eqclose]=1; /* Was 2 since it is symmetrical */
    levhgt[eqclose]=1;
    active[eqclose]=1;
  }
  unput('{');
}

  /* Implementing sqrt as a command with optional argument.*/
<equation>\\sqrt TTH_SCAN_STRING("\\expandafter\\tthsqrtexp");
<equation>\\tthsqrtexp  TTH_TEX_FN_OPT("\\tth_sqrt#tthdrop2",2,"");
<psub>\\tth_sqrt#tthdrop2 {
  if((jscratch=indexkey("#1",margkeys,&margmax))!=-1)
    strcpy(scrstring,margs[jscratch]);
  else fprintf(stderr,"Error getting sqrt 1st argument");
  qrtlen2=strlen(scrstring);
  if((jscratch=indexkey("#2",margkeys,&margmax))!=-1){
    chr1[0]=214;
    if((js2=strlen(margs[jscratch]))==1 && !qrtlen2){ /* Single character */
      if(qrtlen2){ /* optional argument root of */
	sprintf(scratchstring,"<sup>%s%s%s</sup>",
		TTH_FOOTNOTESIZE,scrstring,TTH_SIZEEND);
	TTH_OUTPUT(scratchstring);
      }
      sprintf(dupstore,"{\\surd %s}",margs[jscratch]);
      TTH_SCAN_STRING(dupstore);
      *dupstore=0;
    }else if(strcspn(margs[jscratch],"{}\\")==js2
	     && !(tth_istyle&1)     /* Only for non-compressed */
	     && !qrtlen2    /* And non index */
	     ){/* multiple char qrt case.*/
      sprintf(scratchstring,"%s%s%s",TTH_SYMBOL,TTH_SYMPT(chr1),TTH_SYMEND);
      sprintf(dupstore,"\\qrt{%s}",margs[jscratch]);
      qrtlen=strlen(dupstore)-6;
      js2=0;
      chscratch=dupstore+5;
      while((jscratch=strcspn(chscratch," )(^_")) != strlen(chscratch)){
	js2++;
	chscratch=chscratch+jscratch+1;
	if(!strcspn((chscratch-1),"^_"))js2++;
      }
      qrtlen=qrtlen-(0.5*js2);
      TTH_SCAN_STRING(dupstore);*dupstore=0;
    }else{ /* Default case, embedded groups or commands.  Or index*/
      if(qrtlen2){
	sprintf(scratchstring,
	   "<sup>%s%s%s</sup>%s%s%s",TTH_FOOTNOTESIZE,scrstring,TTH_SIZEEND,
		TTH_SYMBOL,TTH_SYMPT(chr1),TTH_SYMEND);
      }else{
	sprintf(scratchstring,"%s%s%s",TTH_SYMBOL,TTH_SYMPT(chr1),TTH_SYMEND);
      }
      if(eqclose > tth_flev-1 ) { /* put in braces if topped out */
	TTH_OUTPUT(scratchstring);
	TTH_MATHC("{");
	TTH_PUSH_CLOSING;
	/* TTH_CCPY(closing,"}"); Came in wrong order after fraction. 
	 so fixed in the dupstore call.*/
	if(tth_debug&2) {
	  fprintf(stderr,
	      "Start Sqrt {, eqdepth=%d, eqclose=%d, tth_flev=%d, levdelim=%s.\n"
		  ,eqdepth,eqclose,tth_flev,levdelim[eqclose]);
	}
	mkkey(eqstr,eqstrs,&eqdepth);
	*eqstr=0;
	if(tth_flev < 0) tth_flev=tth_flev-99;
	eqclose++;
	tophgt[eqclose]=0;
	levhgt[eqclose]=1;
	sprintf(dupstore,"%s}\\}",margs[jscratch]);	
      }else{ /* use overline */
	sprintf(dupstore,"{\\overline{%s}\\tth_makeroot}",margs[jscratch]);
	tth_root_depth++;
	/* pass to delimit code via global stack. */
	TTH_SCAN_STRING(dupstore); /* defer the contents scan. Do index */
	tth_flev=tth_flev-99;  /* No built-up in index */
	/* use double braces to ensure inline enclosure works correctly. */
	sprintf(dupstore,"{{%s}\\tth_rootindex}",scrstring);
      }
      TTH_SCAN_STRING(dupstore);
      *dupstore=0;
    }
    yy_pop_state();
    rmdef(margkeys,margs,&margmax);    /* Dump two arguments */
    rmdef(margkeys,margs,&margmax);
  }else{fprintf(stderr,"Error finding sqrt argument");}
} /* end of tth_sqrt*/
<equation>\\tth_rootindex  {
    TTH_CCPY(tth_root_index[tth_root_depth],eqstr);
    tth_root_len[tth_root_depth]=strlen(eqstr);
    *eqstr=0;
    tth_flev=tth_flev+99;
}
<equation>\\tth_makeroot   strcpy(levdelim[eqclose],"&#214;");


 /* Above accents etc without braces: embrace following token (and rescan). */
<equation>\\sqrt{WSP}*   |
<equation>\\(wide)?hat{WSP}*   |
<equation>\\vec{WSP}*   |
<equation>\\(wide)?tilde{WSP}* |
<equation>\\dd?ot{WSP}*   |
<equation>\\bar{WSP}*	|
<equation>\\overline{WSP}*   {  /* overline needs leading WSP */
  TTH_INC_MULTI; 
  strcpy(dupstore,yytext);
  *(dupstore+strcspn(dupstore," \t\r\n"))=0;
  /* yy_push_state(embracetok); OLD */
  *expchar=0;TTH_CCPY(exptex,dupstore);*dupstore=0;
  yy_push_state(exptokarg); /* overaccent */
 }
<equation>\\eqno[^\$]*\$\$ { /*This is default.*/
  TTH_INC_MULTI;
  if((tth_flev > 0 )){
    strcpy(scrstring,yytext+5);
    *(scrstring+strlen(scrstring)-2)=0;
    sprintf(scratchstring,"}\\special{html:%s}%s\\tth_endnumbered",
	    (eqalignlog ? TTH_DISP5 : TTH_DISP3),scrstring);
    /*fprintf(stderr,"Ending eqno: %s\n",scratchstring); */
    TTH_SCAN_STRING(scratchstring);
  }else{
    yyless(5);  TTH_MATHC("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  }
 }
<equation>\\eqno     { /* Fallback only */
  if((tth_flev > 0 ) && (eqaligncell)) {
    tth_enclose(TTH_EQ1,eqstr,TTH_EQ4,eqstore);
    strcat(eqstr,TTH_CELL4);
  }
  TTH_MATHC("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
 }
<equation>\\[Bb]ig[lmr]?{WSP}* {
  TTH_INC_MULTI; 
  TTH_SCAN_STRING("\\left.\\tth_size2\\right");
 }
<equation>\\[Bb]igg[lmr]?{WSP}* {
  TTH_INC_MULTI; 
  TTH_SCAN_STRING("\\left.\\tth_size3\\right");
 }
<equation>\\tth_size2  levhgt[eqclose]=2;
<equation>\\tth_size3  levhgt[eqclose]=3;
<equation>\\left{WSP}*     {
  TTH_INC_MULTI;yy_push_state(bigdel);strcpy(scratchstring,"{");}
<equation>\\right{WSP}*    {
  TTH_INC_MULTI;yy_push_state(bigdel);strcpy(scratchstring,"}");}

<equation>\\global         ;
<equation>\\bmath          ;
<equation>\\textstyle {
  if(eqdepth>2){ /* Problem with implied grouping of an eq insufficient.
                    to end dupgroup. So avoid such situations.*/
    tth_flev=tth_flev-99;
    TTH_CCPY(argchar,"\\tth_endtextstyle");
    storetype=5;
    yy_push_state(dupgroup);
  }
}
<equation>\\tth_endtextstyle  tth_flev=tth_flev+99;
<equation>\\displaystyle
<equation>\\scriptstyle
<equation>\\smash

  /* Default equation actions. */
  /* Was single character. IE gave problems. */
<equation>[a-zA-Z]+  {
    strcat(eqstr,tth_font_open[tth_push_depth]);
    strcat(eqstr,yytext);
    strcat(eqstr,tth_font_close[tth_push_depth]);
 }

<equation>{SP}*      TTH_MATHC(" ");
<equation>[ ]=[ ]           |
<equation>\\(%|$|&|#|\\|_)  |
<equation>[()\[\]]          |
<equation>[+\-\*=/\.,:;\?!] |
<equation>[0-9]*  { 
  if(*(yytext) == '\\'){ chscratch=yytext+1;} else {chscratch=yytext;}
  if(*chscratch=='&')chscratch="&amp;";
  /* If the font has been changed, use it for non-letters too */
  if(!tth_mathitalic || strcmp(tth_font_open[tth_push_depth],TTH_ITAL1)!=0 ){
    strcat(eqstr,tth_font_open[tth_push_depth]);
    strcat(eqstr,chscratch);
    strcat(eqstr,tth_font_close[tth_push_depth]);
  }else{
    strcat(eqstr,chscratch);
  }
}
<equation>{WSP}*={WSP}*     TTH_INC_MULTI; TTH_SCAN_STRING(" = ");



  /**** tth pseudo-TeX ******/
<equation>#tthbigsup {
  if(tth_debug&8) fprintf(stderr,"#tthbigsup, eqhgt=%d\n",eqhgt);
  strcat(eqstr,TTH_BR);
  *expchar=0;
  if(strlen(eqlimited)){
    tth_symext(eqlimited,eqstr+strlen(eqstr));
    *eqlimited=0;
    for(i=0;i<oa_removes;i++){TTH_CCAT(expchar,TTH_OA4);}
    oa_removes=0;
  }else{
    for(i=1;i<=eqhgt-2;i++){
      strcat(eqstr,TTH_BRN);
    }
  }
  if(!strlen(expchar)){TTH_CCAT(expchar,TTH_NULL_BOTTOM);}  /* IE fix */
  TTH_CCAT(expchar,TTH_CELL3); /* make compatible with cell trim code. */
  yy_push_state(exptokarg); /* tthbigsup code */
 }
<equation>\\tth_eqfin { /* Finish an eq group and attach to previous key */
  tth_prefix(eqstrs[eqdepth-1],eqstr,eqstore); /* prefix previous row.*/
  rmkey(eqstrs,&eqdepth);
  mkkey(eqstr,eqstrs,&eqdepth);     /* Start new row */
  *eqstr=0;
 }
<equation>\\tth_lefteq {
  lefteq=1;
  colspan=3;
 }

 /* End of Equation code. */

<getsubp>{WSP}*   {
 TTH_INC_MULTI;
} 
<getsubp>\\limits
<getsubp>(\^|\_) { /* unenclosed subp. Embrace or expand it */
  *expchar=0;strcpy(exptex,yytext);yy_push_state(exptokarg);
  if(tth_debug&8)fprintf(stderr,"Expanding big subpscript\n");
 }
<getsubp>\^\{ {
  storetype=1;
  yy_push_state(dupgroup);
  *dupstore=0;
 }
<getsubp>\_\{ {
  storetype=2;
  yy_push_state(dupgroup);
  *dupstore=0;
 }
<getsubp>\\[a-zA-Z@]+              {
  TTH_DO_MACRO
    else{
      yyless(0);TTH_SCAN_STRING("#");
    }
 }
\\tthscriptsize {
  if(tth_htmlstyle&4){
    TTH_OUTPUT("<span class=\"smaller\">");TTH_PRECLOSE("</span>");
  }else{
    TTH_OUTPUT("<small>");TTH_PRECLOSE("</small>");
  }
}
<getsubp>. { /* No more subp's */
  if(*yytext != '#') yyless(0);
  storetype=0;
  yy_pop_state();
  if(strlen(supstore) || strlen(substore)){ /* Need to deal with subp */
    strcpy(dupstore,"{\\tthscriptsize{");
    strcat(dupstore,supstore);
    strcat(dupstore,"}}#tthbigsup{\\tthscriptsize{");
    strcat(dupstore,substore);
    strcat(dupstore,"}}");
    if(tth_istyle&1) eqhgt=0.8*hgt+0.7; else eqhgt=hgt;
    if(tth_debug&8)fprintf(stderr,"Scanning subpscripts:%s\n",dupstore);
    TTH_SCAN_STRING(dupstore);
    *dupstore=0;
    *argchar=0;
    *supstore=0;
    *substore=0;
    strcpy(expchar,"<!--sup\n-->"); /* make non-null */
    yy_push_state(exptokarg); /* scanning subpscripts */
  }else if(strlen(eqlimited)){ /* No delimiters but a limited symbol */
    tth_symext(eqlimited,eqstr+strlen(eqstr));
    for(i=0;i<oa_removes;i++){strcat(eqstr,TTH_OA4);}
    oa_removes=0;
    strcat(eqstr,"</td><td nowrap=\"nowrap\">");
    *eqlimited=0;
  }  
 }

 /* New big, left, right, delimiters section */

<bigdel>(\\\{|\\lbrace)   { 
  yy_pop_state();strcpy(levdelim[eqclose+1],"{");unput(*scratchstring);}
<bigdel>(\\\}|\\rbrace)   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"}");unput(*scratchstring);}
<bigdel>\(   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"(");unput(*scratchstring);}
<bigdel>\)   {
  yy_pop_state();strcpy(levdelim[eqclose+1],")");unput(*scratchstring);}
<bigdel>(\[|\\lbrack)   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"[");unput(*scratchstring);}
<bigdel>(\]|\\rbrack)   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"]");unput(*scratchstring);}
<bigdel>\\lceil   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"&#233;");unput(*scratchstring);}
<bigdel>\\rceil   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"&#249;");unput(*scratchstring);}
<bigdel>\\lfloor   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"&#235;");unput(*scratchstring);}
<bigdel>\\rfloor   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"&#251;");unput(*scratchstring);}
<bigdel>\\langle   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"&#225;");unput(*scratchstring);}
<bigdel>\\rangle   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"&#241;");unput(*scratchstring);}
<bigdel>(\||\\vert)   {
  yy_pop_state();strcpy(levdelim[eqclose+1],"|");unput(*scratchstring);}
<bigdel>(\/|\\backslash)   {
  yy_pop_state();*levdelim[eqclose+1]=*yytext;unput(*scratchstring);}
<bigdel>\.   yy_pop_state();*levdelim[eqclose+1]=0;unput(*scratchstring);
<bigdel>. { /* unknown bigdelimiter; make blank and then rescan. */
  yy_pop_state();yyless(0);
  TTH_SCAN_STRING(scratchstring);
}