forked from tririver/MathGR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeset.m
More file actions
181 lines (123 loc) · 29.3 KB
/
typeset.m
File metadata and controls
181 lines (123 loc) · 29.3 KB
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
(* ::Package:: *)
(* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
BeginPackage["MathGR`typeset`", {"MathGR`tensor`"}]
ToTeXString::usage="ToTeXString[expr] translates expr into TeXForm and return the result in a string"
ToTeX::usage="ToTeX[expr] prints expr into TeXForm"
ToTeXHook::usage="ToTeXHook is set of transformations before export to TeX"
ToTeXTemplate::usage="ToTeXTemplate = True (default, export header and tail of tex) or False (no header or tail, only the equation)."
DecorateTeXString::usage="DecorateTeXString[s] does post processing for a TeX string."
Begin["`Private`"]
Needs["MathGR`utilPrivate`"]
(* ::Section:: *)
(* TraditionalForm and TeX output *)
altUp:= Alternatives @@ IdxUpList
altDn:= Alternatives @@ IdxDnList
idxQ[idx__]:= MatchQ[{idx}, {(IdxPtn|_UE|_DE) ..}]
makeBoxesTsrQ = !MatchQ[#, List|Rule|Alternatives|Sequence]&
mkPd[form_][i___] := Sequence @@ (MakeBoxes[\[CapitalSampi]@#, form] & /@ {i})
(*SetOptions[$Output, PageWidth -> 200]*)
If[!defQ@ToTeXHook, ToTeXHook = {}]
removeTextAndCurly[s_String]:= s // StringReplace[#, "\\text{"~~f__~~"}"/;StringFreeQ[f,{"{","}"}] :>f ] & // StringReplace[#, "$":>""] &
removeWaste[s_String]:= s // StringReplace[#, "\\text{}" :> "{}"] & // StringReplace[#, "){}^" :> ")^"] & // StringReplace[#, "\\partial {}_" :> "\\partial_"] &
replaceTimeDot[s_String]:= If[!StringFreeQ[s, "\\partial ^{-2}"], s (* dot acting on Pm2 looks wrong *),
StringReplace[s, {"\\partial_0\\partial_0\\partial_0" :> "\\dddot", "\\partial_0\\partial_0" :> "\\ddot", "\\partial_0" :> "\\dot"}]]
breakLine[s_String]:= s // StringReplace[#, {"+":>"\n + ", f_~~"-" /; f=!="\n"&&f=!="{" :> f<>"\n - ", "=":>"\n= ", "\\to":>"\n \\to "}] &
addHeaderTail[s_String]:= If[!ToTeXTemplate, s, Print["Hint: set ToTeXTemplate = False to output equation only."]; "%Generated by MathGR/typeset.m, "<>DateString[]<>
".\n\\documentclass{revtex4}\n\\usepackage{breqn}\n\\begin{document}\n\\begin{dmath}\n"<>s<>"\n\\end{dmath}\n\\end{document}\n"]
finalCleanUp[s_String]:= s // StringReplace[#, {"\n\n"->"\n"}] & (* Shouldn't be necessary. Just in case. *)
If[!defQ@DecorateTeXString, DecorateTeXString = (# // removeWaste // replaceTimeDot // removeTextAndCurly // breakLine // addHeaderTail // finalCleanUp) & ]
If[!defQ[ToTeXTemplate], ToTeXTemplate = True]
ToTeXString[e_]:= e//.ToTeXHook // PolynomialForm[#, TraditionalOrder -> False]& // ToString[#, TeXForm] & // DecorateTeXString
ToTeX[e_] := ToTeXString[e] // Print
MakeBoxes[\[CapitalSampi], TraditionalForm]:="\[PartialD]"
MakeBoxes[Dta, TraditionalForm]:="\[Delta]"
MakeBoxes[tsr_[idx__], TraditionalForm]/;(idxQ[idx]&&makeBoxesTsrQ[tsr]):= With[
{idList={idx}/.{altUp[i_]:>SuperscriptBox["", i], UE[i_]:>SuperscriptBox["", ToString@i], altDn[i_]:>SubscriptBox["", i], DE[i_]:>SubscriptBox["", ToString@i]}},
TagBox[RowBox[{MakeBoxes[tsr, TraditionalForm]}~Join~idList], "mgrTsr", SyntaxForm->"symbol"]]
MakeBoxes[PdT[f_, PdVars[i0:DE@0..., i__]], TraditionalForm] /; FreeQ[{i}, DE@0] := With[{id0 = mkPd[TraditionalForm]@i0, id = mkPd[TraditionalForm]@i},
TagBox[RowBox[{id, id0, MakeBoxes[f, TraditionalForm]}], "mgrPdT", SyntaxForm -> "^"]]
MakeBoxes[PdT[f_, PdVars[i0:DE@0..]], TraditionalForm] := With[{id0 = mkPd[TraditionalForm]@i0},
TagBox[RowBox[{id0, MakeBoxes[f, TraditionalForm]}], "mgrPdT", SyntaxForm -> "symbol"]]
(* ::Section:: *)
(* All the below only run with a frontend *)
If[$FrontEnd===Null, Print["(typeset.m): No FrontEnd detected. StandardForm and input aliases definitions skipped."],
(* ::Section:: *)
(* Tensor *)
(*
MakeBoxes[tsr_[idx__], StandardForm]/;(idxQ[idx]&&makeBoxesTsrQ[tsr]):= TagBox[RowBox[{AdjustmentBox[MakeBoxes[tsr, StandardForm], BoxMargins -> {{0, -0.2}, {0, 0}}],
StyleBox[ GridBox[{idx} /. {
{(a:altUp)[i_]:>TagBox[StyleBox[MakeBoxes[i, StandardForm], FontColor->IdxColor@a], a],
IdxDnPtn:>"", UE@n_:>TagBox[StyleBox[MakeBoxes[n, StandardForm], FontColor->IdxColor@UE],UE], DE@n_:>""},
{IdxUpPtn:>"", (a:altDn)[i_]:>TagBox[StyleBox[MakeBoxes[i, StandardForm], FontColor->IdxColor@a], a],
DE@n_:>TagBox[StyleBox[MakeBoxes[n, StandardForm], FontColor->IdxColor@DE],DE], UE@n_:>""}
}, ColumnSpacings->0, RowSpacings->0], FontSize->10]}], "mgrTsr"(*, SyntaxForm->"symbol"*)];
parseUD[lst_, StandardForm]:= Sequence @@ (Map[If[#[[1]] === "", #[[2]], #[[1]]] &, Transpose[lst]] /. {TagBox[i_ | StyleBox[i_, __], tag_] :> tag@ToExpression[i, StandardForm]});
MakeExpression[TagBox[RowBox[{AdjustmentBox[t_, ___], StyleBox[GridBox[idx__, ___], ___]}], "mgrTsr", OptionsPattern[]], StandardForm] :=
With[{h = ToExpression[t, StandardForm], i = parseUD[idx, StandardForm]}, HoldComplete@h@i];
*)
(* The new box form has advantages: (1) Uniform look in input/output/code blocks/pdf. (2) Robust against edit/copy-paste. Not possible to leave imcomplete boxes. (3) No longer additional brackets. *)
MakeBoxes[tsr_[idx__], StandardForm]/;(idxQ[idx]&&makeBoxesTsrQ[tsr]):= TagBox[GridBox[{{GridBox[{{MakeBoxes[tsr, StandardForm]}}, Selectable->True],
GridBox[{idx} /. {
{(a:altUp)[i_]:>StyleBox[TagBox[GridBox[{{MakeBoxes[i, StandardForm]}}, Selectable->True], a], FontColor->IdxColor@a, FontSize->10],
IdxDnPtn:>"", UE@n_:>StyleBox[TagBox[GridBox[{{MakeBoxes[n, StandardForm]}}, Selectable->True],UE], FontColor->IdxColor@UE, FontSize->10], DE@n_:>""},
{IdxUpPtn:>"", (a:altDn)[i_]:>StyleBox[TagBox[GridBox[{{MakeBoxes[i, StandardForm]}}, Selectable->True], a], FontColor->IdxColor@a, FontSize->10],
DE@n_:>StyleBox[TagBox[GridBox[{{MakeBoxes[n, StandardForm]}}, Selectable->True],DE], FontColor->IdxColor@DE, FontSize->10], UE@n_:>""}
}, ColumnSpacings->0, RowSpacings->-0.5]}}, ColumnSpacings->0, RowSpacings->0, Selectable->False], "mgrTensor", SyntaxForm->"symbol", Selectable->False];
parseId[lst_, StandardForm]:= Sequence @@ (Map[If[#[[1]] === "", #[[2]], #[[1]]] &, Transpose[lst]]
/. {StyleBox[TagBox[GridBox[{{i_}},___] , tag_,___], ___] | TagBox[GridBox[{{i_}},___] , tag_,___] :> tag@ToExpression[i, StandardForm]});
MakeExpression[TagBox[GridBox[{{GridBox[{{t_}}, ___], GridBox[idx__, ___]}},___], "mgrTensor", ___], StandardForm] :=
With[{h = ToExpression[t, StandardForm], i = parseId[idx, StandardForm]}, HoldComplete@h@i];
(* ::Section:: *)
(* Derivative *)
(*
MakeBoxes[PdT[f_, PdVars[i__]], StandardForm] /; FreeQ[{i}, DE@0] || !FreeQ[{f}, Pm2] :=
With[{id = mkPd[StandardForm]@i}, TagBox[GridBox[{{id, GridBox[{{MakeBoxes[f, StandardForm]}},Selectable\[Rule]True]}}, ColumnSpacings->0, RowSpacings->0], "mgrPd", SyntaxForm -> "^", Selectable\[Rule]False]];
MakeBoxes[PdT[a_, PdVars[dt : DE@0 .., i__]], StandardForm] /; FreeQ[{i}, DE@0]:= With[{id = mkPd[StandardForm]@i, bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]},
TagBox[GridBox[{{id, GridBox[{{OverscriptBox[MakeBoxes[a, StandardForm], bu]}},Selectable\[Rule]True]}}, ColumnSpacings->0, RowSpacings->0], "mgrPd", SyntaxForm -> "^", Selectable\[Rule]False]];
MakeBoxes[PdT[a_, PdVars[dt : DE@0 ..]], StandardForm] /; FreeQ[{a}, Pm2] := With[{bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]}, OverscriptBox[MakeBoxes[a, StandardForm], bu]];
MakeExpression[TagBox[GridBox[{{d__,GridBox[{{f_}},___]}},___], "mgrPd", ___], StandardForm]:=
With[{idExpr=PdVars@@Cases[ToExpression[{d}, StandardForm], \[CapitalSampi][a_]:>a], fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
MakeExpression[TagBox[GridBox[{{d__,GridBox[{{f_}},___]}},___], "mgrPd", ___], StandardForm]:=
With[{idExpr=ToExpression/@{d}, fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
MakeExpression[OverscriptBox[a_, str_String], StandardForm] := With[{pds = Nest[Pd[#, DE@0] &, ToExpression[a, StandardForm],
StringLength[str]]}, HoldComplete[pds]] /; StringMatchQ[str, "\[Bullet]" ..];
MakeBoxes[Pm2[a_, type_], form_] := TagBox[RowBox[{TagBox[StyleBox[SuperscriptBox[MakeBoxes[\[CapitalSampi], form], "-2"], FontColor->IdxColor[type]], type],
"(", MakeBoxes[a, form], ")" }], "mgrPm2"];
MakeExpression[TagBox[RowBox[{TagBox[_, type_], "(", a_, ")"}], "mgrPm2"], StandardForm]:= With[{expr=Pm2[ToExpression[a, StandardForm], type]}, HoldComplete[expr]];
*)
(*
MakeBoxes[PdT[f_, PdVars[i__]], StandardForm] /; FreeQ[{i}, DE@0] || !FreeQ[{f}, Pm2] :=
With[{id = mkPd[StandardForm]@i}, TagBox[RowBox[{id, MakeBoxes[f, StandardForm]}], "mgrPd", Selectable->False]];
MakeBoxes[PdT[a_, PdVars[dt : DE@0 .., i__]], StandardForm] /; FreeQ[{i}, DE@0]:= With[{id = mkPd[StandardForm]@i, bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]},
TagBox[RowBox[{id, OverscriptBox[MakeBoxes[a, StandardForm], bu]}], "mgrPd", Selectable->False]];
MakeBoxes[PdT[a_, PdVars[dt : DE@0 ..]], StandardForm] /; FreeQ[{a}, Pm2] := With[{bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]}, OverscriptBox[MakeBoxes[a, StandardForm], bu]];
MakeExpression[TagBox[RowBox[{d__,f_}], "mgrPd", ___], StandardForm]:=
With[{idExpr=PdVars@@Cases[ToExpression[{d}, StandardForm], \[CapitalSampi][a_]:>a], fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
MakeExpression[OverscriptBox[a_, str_String], StandardForm] := With[{pds = Nest[Pd[#, DE@0] &, ToExpression[a, StandardForm],
StringLength[str]]}, HoldComplete[pds]] /; StringMatchQ[str, "\[Bullet]" ..];
MakeBoxes[Pm2[a_, type_], form_] := TagBox[RowBox[{TagBox[StyleBox[SuperscriptBox[MakeBoxes[\[CapitalSampi], form], "-2"], FontColor->IdxColor[type]], type],
"(", MakeBoxes[a, form], ")" }], "mgrPm2", Selectable->False];
MakeExpression[TagBox[RowBox[{TagBox[_, type_], "(", a_, ")"}], "mgrPm2",___], StandardForm]:= With[{expr=Pm2[ToExpression[a, StandardForm], type]}, HoldComplete[expr]];
*)
MakeBoxes[\[CapitalSampi], StandardForm]:= TagBox["\[PartialD]", "mgrSa", Selectable->False];
MakeExpression[TagBox["\[PartialD]","mgrSa",___], StandardForm]:= HoldComplete@\[CapitalSampi];
MakeBoxes[PdT[f_, PdVars[i__]], StandardForm] /; FreeQ[{i}, DE@0] || !FreeQ[{f}, Pm2] :=
With[{id = mkPd[StandardForm]@i}, TagBox[RowBox[{GridBox[{{id, GridBox[{{MakeBoxes[f, StandardForm]}},Selectable->True]}}, ColumnSpacings->0, RowSpacings->0],""}], "mgrPd", Selectable->False]];
MakeBoxes[PdT[a_, PdVars[dt : DE@0 .., i__]], StandardForm] /; FreeQ[{i}, DE@0]:= With[{id = mkPd[StandardForm]@i, bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]},
TagBox[RowBox[{GridBox[{{id, GridBox[{{OverscriptBox[MakeBoxes[a, StandardForm], bu]}},Selectable->True]}}, ColumnSpacings->0, RowSpacings->0],""}], "mgrPd", Selectable->False]];
MakeBoxes[PdT[a_, PdVars[dt : DE@0 ..]], StandardForm] /; FreeQ[{a}, Pm2] := With[{bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]}, OverscriptBox[MakeBoxes[a, StandardForm], bu]];
MakeExpression[TagBox[GridBox[{{d__,GridBox[{{f_}},___]}},___], "mgrPd", ___], StandardForm]:=
With[{idExpr=PdVars@@Cases[ToExpression[{d}, StandardForm], \[CapitalSampi][a_]:>a], fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
MakeExpression[OverscriptBox[a_, str_String], StandardForm] := With[{pds = Nest[Pd[#, DE@0] &, ToExpression[a, StandardForm],
StringLength[str]]}, HoldComplete[pds]] /; StringMatchQ[str, "\[Bullet]" ..];
MakeBoxes[Pm2[a_, type_], form_] := TagBox[RowBox[{TagBox[StyleBox[SuperscriptBox[MakeBoxes[\[CapitalSampi], form], "-2"], FontColor->IdxColor[type]], type],
"(", MakeBoxes[a, form], ")" }], "mgrPm2", Selectable->False];
MakeExpression[TagBox[RowBox[{TagBox[_, type_], "(", a_, ")"}], "mgrPm2",___], StandardForm]:= With[{expr=Pm2[ToExpression[a, StandardForm], type]}, HoldComplete[expr]];
(* ::Section:: *)
(* Paste the blob calculated in InputAliases.nb *)
aliasesList = {"tp"->TagBox[RowBox[{GridBox[{{TagBox[GridBox[{{GridBox[{{"\[CapitalSampi]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[SelectionPlaceholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],GridBox[{{"\[Placeholder]"}},Selectable->True]}},ColumnSpacings->0,RowSpacings->0],""}],"mgrPd",Selectable->False],"tp0"->OverscriptBox["\[SelectionPlaceholder]","\[Bullet]"],"tp1"->TagBox[RowBox[{GridBox[{{TagBox[GridBox[{{GridBox[{{"\[CapitalSampi]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[SelectionPlaceholder]\""}},Selectable->True],D1],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],GridBox[{{"\[Placeholder]"}},Selectable->True]}},ColumnSpacings->0,RowSpacings->0],""}],"mgrPd",Selectable->False],"tp2"->TagBox[RowBox[{GridBox[{{TagBox[GridBox[{{GridBox[{{"\[CapitalSampi]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[SelectionPlaceholder]\""}},Selectable->True],D2],FontColor->RGBColor[1, 0, 0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],GridBox[{{"\[Placeholder]"}},Selectable->True]}},ColumnSpacings->0,RowSpacings->0],""}],"mgrPd",Selectable->False],"tpt"->TagBox[RowBox[{GridBox[{{TagBox[GridBox[{{GridBox[{{"\[CapitalSampi]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[SelectionPlaceholder]\""}},Selectable->True],DTot],FontColor->RGBColor[0, 0, 1],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],GridBox[{{"\[Placeholder]"}},Selectable->True]}},ColumnSpacings->0,RowSpacings->0],""}],"mgrPd",Selectable->False],"tu"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10]},{""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tuu"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10]},{"",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tud"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],""},{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tdu"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10]},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tdd"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tuuu"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10]},{"","",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tudd"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],"",""},{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tddd"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"","",""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tuuuu"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UP],FontColor->GrayLevel[0],FontSize->10]},{"","","",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tdddd"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"","","",""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DN],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu1"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U1],FontColor->GrayLevel[0],FontSize->10]},{""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td1"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D1],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu1u1"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U1],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U1],FontColor->GrayLevel[0],FontSize->10]},{"",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu1d1"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U1],FontColor->GrayLevel[0],FontSize->10],""},{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D1],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td1u1"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U1],FontColor->GrayLevel[0],FontSize->10]},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D1],FontColor->GrayLevel[0],FontSize->10],""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td1d1"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D1],FontColor->GrayLevel[0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D1],FontColor->GrayLevel[0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu2"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U2],FontColor->RGBColor[1, 0, 0],FontSize->10]},{""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td2"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D2],FontColor->RGBColor[1, 0, 0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu2u2"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U2],FontColor->RGBColor[1, 0, 0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U2],FontColor->RGBColor[1, 0, 0],FontSize->10]},{"",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu2d2"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U2],FontColor->RGBColor[1, 0, 0],FontSize->10],""},{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D2],FontColor->RGBColor[1, 0, 0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td2u2"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],U2],FontColor->RGBColor[1, 0, 0],FontSize->10]},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D2],FontColor->RGBColor[1, 0, 0],FontSize->10],""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td2d2"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D2],FontColor->RGBColor[1, 0, 0],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],D2],FontColor->RGBColor[1, 0, 0],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tut"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UTot],FontColor->RGBColor[0, 0, 1],FontSize->10]},{""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tdt"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DTot],FontColor->RGBColor[0, 0, 1],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tutut"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UTot],FontColor->RGBColor[0, 0, 1],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UTot],FontColor->RGBColor[0, 0, 1],FontSize->10]},{"",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tutdt"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UTot],FontColor->RGBColor[0, 0, 1],FontSize->10],""},{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DTot],FontColor->RGBColor[0, 0, 1],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tdtut"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],UTot],FontColor->RGBColor[0, 0, 1],FontSize->10]},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DTot],FontColor->RGBColor[0, 0, 1],FontSize->10],""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tdtdt"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",""},{StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DTot],FontColor->RGBColor[0, 0, 1],FontSize->10],StyleBox[TagBox[GridBox[{{"\"\[Placeholder]\""}},Selectable->True],DTot],FontColor->RGBColor[0, 0, 1],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu0"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],UE],FontColor->GrayLevel[0.5],FontSize->10]},{""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td0"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{""},{StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],DE],FontColor->GrayLevel[0.5],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu0u0"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],UE],FontColor->GrayLevel[0.5],FontSize->10],StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],UE],FontColor->GrayLevel[0.5],FontSize->10]},{"",""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"tu0d0"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],UE],FontColor->GrayLevel[0.5],FontSize->10],""},{"",StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],DE],FontColor->GrayLevel[0.5],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td0u0"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],UE],FontColor->GrayLevel[0.5],FontSize->10]},{StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],DE],FontColor->GrayLevel[0.5],FontSize->10],""}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False],"td0d0"->TagBox[GridBox[{{GridBox[{{"\[SelectionPlaceholder]"}},Selectable->True],GridBox[{{"",""},{StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],DE],FontColor->GrayLevel[0.5],FontSize->10],StyleBox[TagBox[GridBox[{{"0"}},Selectable->True],DE],FontColor->GrayLevel[0.5],FontSize->10]}},ColumnSpacings->0,RowSpacings->-0.5`]}},ColumnSpacings->0,RowSpacings->0,Selectable->False],"mgrTensor",SyntaxForm->"symbol",Selectable->False]};
SetOptions[$FrontEnd, InputAliases->Select[InputAliases/.Options[$FrontEnd,InputAliases],FreeQ[#,Apply[Alternatives,#1&@@@aliasesList]]&]] (* clean related previous frontend options *)
SetOptions[$FrontEnd, InputAliases -> Union[aliasesList ~Join~ (InputAliases /. Options[$FrontEnd, InputAliases])]];
] (* end of the big if (or tell me how to stop in the middle of a package gracefully?) *)
End[]
EndPackage[]