@@ -15,17 +15,17 @@ public partial record Sumf
1515 {
1616 /// <inheritdoc/>
1717 public override string Latexise ( ) =>
18- Augend . Latexise ( Augend . Priority < Priority )
19- + ( Addend . Latexise ( Addend . Priority < Priority ) is var addend && addend . StartsWith ( "-" )
18+ Augend . Latexise ( Augend . LatexPriority < LatexPriority )
19+ + ( Addend . Latexise ( Addend . LatexPriority < LatexPriority ) is var addend && addend . StartsWith ( "-" )
2020 ? addend : "+" + addend ) ;
2121 }
2222
2323 public partial record Minusf
2424 {
2525 /// <inheritdoc/>
2626 public override string Latexise ( ) =>
27- Subtrahend . Latexise ( Subtrahend . Priority < Priority )
28- + "-" + Minuend . Latexise ( Minuend . Priority <= Priority ) ;
27+ Subtrahend . Latexise ( Subtrahend . LatexPriority < LatexPriority )
28+ + "-" + Minuend . Latexise ( Minuend . LatexPriority <= LatexPriority ) ;
2929 }
3030
3131 public partial record Mulf
@@ -43,16 +43,16 @@ public override string Latexise()
4343 return currIn switch
4444 {
4545 // -1, -2, 2i, i, -i, -2i etc. in the front and not (1+i) etc.
46- Number { Priority : Priority . Sum } and not Complex { RealPart . IsZero : false , ImaginaryPart . IsZero : false } =>
46+ Number { LatexPriority : Priority . Sum } and not Complex { RealPart . IsZero : false , ImaginaryPart . IsZero : false } =>
4747 currIn . Latexise ( false ) ,
48- _ => currIn . Latexise ( currIn . Priority < Priority )
48+ _ => currIn . Latexise ( currIn . LatexPriority < LatexPriority )
4949 } ;
5050 case 1 :
5151 if ( longArray [ index - 1 ] is Integer ( - 1 ) )
52- return $ "-{ currIn . Latexise ( currIn . Priority < Priority ) } "; // display "-1 * x * y" as "-x \cdot y", only for the first -1
52+ return $ "-{ currIn . Latexise ( currIn . LatexPriority < LatexPriority ) } "; // display "-1 * x * y" as "-x \cdot y", only for the first -1
5353 break ;
5454 }
55- var currOut = currIn . Latexise ( currIn . Priority < Priority ) ;
55+ var currOut = currIn . Latexise ( currIn . LatexPriority < LatexPriority ) ;
5656
5757 return ( longArray [ index - 1 ] , currIn ) switch // whether we use juxtaposition and omit \cdot
5858 {
@@ -61,20 +61,20 @@ public override string Latexise()
6161
6262 // Don't juxtapose upright variables with numbers like displaying "var2" for "var*2" since "var2" may be interpreted as one variable.
6363 // Also, don't produce upright "ei" (one variable with two chars) for e*i, or "ei^2" for e*i^2.
64- // but "e (2+i)" and "e (2+i)^2" are fine with the parentheses - so we have the priority check.
64+ // but "e (2+i)" and "e (2+i)^2" are fine with the parentheses - so we have the LatexPriority check.
6565 ( Variable { IsLatexUprightFormatted : true }
66- or Complex { ImaginaryPart . IsZero : false , Priority : >= Priority . Mul } /* don't combine upright "i" with an upright variable*/ ,
67- Variable { IsLatexUprightFormatted : true } or Number { Priority : >= Priority . Mul }
68- or Factorialf ( Number { Priority : Priority . Leaf } or Variable { IsLatexUprightFormatted : true } )
69- or Powf ( Number { Priority : Priority . Leaf } or Variable { IsLatexUprightFormatted : true }
70- or Factorialf ( Number { Priority : Priority . Leaf } or Variable { IsLatexUprightFormatted : true } ) , _) ) => false,
66+ or Complex { ImaginaryPart . IsZero : false , LatexPriority : >= Priority . Mul } /* don't combine upright "i" with an upright variable*/ ,
67+ Variable { IsLatexUprightFormatted : true } or Number { LatexPriority : >= Priority . Mul }
68+ or Factorialf ( Number { LatexPriority : Priority . Leaf } or Variable { IsLatexUprightFormatted : true } )
69+ or Powf ( Number { LatexPriority : Priority . Leaf } or Variable { IsLatexUprightFormatted : true }
70+ or Factorialf ( Number { LatexPriority : Priority . Leaf } or Variable { IsLatexUprightFormatted : true } ) , _) ) => false,
7171 // 2 * (3/4) instead of 2 (3/4) which is a mixed number (= 2 + 3/4)
72- ( Number { Priority : Priority . Leaf } , { Priority : Priority . Div } ) => false,
73- // 2 * 3 instead of 2 3 (= 23), 2 * 3^4 instead of 2 3^4 (= 23^4), but "(2+i) 2", "2 (2+i)" and "2 (2+i)^2" are fine with the parentheses - so we have the priority check.
74- ( _, Number { Priority : >= Priority . Mul } or Factorialf ( Number { Priority : Priority . Leaf } )
75- or Powf ( Number { Priority : Priority . Leaf } or Factorialf ( Number { Priority : Priority . Leaf } ) , _) ) => false , // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i"
76- ( var left , var right ) => left . Priority >= right . Priority &&
77- ! ( left . Priority == Priority . Div && right . Priority == Priority . Div ) // Without \cdot, the fraction lines may appear too closely together.
72+ ( Number { LatexPriority : Priority . Leaf } , { LatexPriority : Priority . Div } ) => false,
73+ // 2 * 3 instead of 2 3 (= 23), 2 * 3^4 instead of 2 3^4 (= 23^4), but "(2+i) 2", "2 (2+i)" and "2 (2+i)^2" are fine with the parentheses - so we have the LatexPriority check.
74+ ( _, Number { LatexPriority : >= Priority . Mul } or Factorialf ( Number { LatexPriority : Priority . Leaf } )
75+ or Powf ( Number { LatexPriority : Priority . Leaf } or Factorialf ( Number { LatexPriority : Priority . Leaf } ) , _) ) => false , // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i"
76+ ( var left , var right ) => left . LatexPriority >= right . LatexPriority &&
77+ ! ( left . LatexPriority == Priority . Div && right . LatexPriority == Priority . Div ) // Without \cdot, the fraction lines may appear too closely together.
7878 } ? $@"{prevOut} {currOut}" : $@ "{ prevOut } \cdot { currOut } ";
7979 } ) ;
8080
@@ -125,7 +125,7 @@ public override string Latexise()
125125 }
126126 else
127127 {
128- return "{" + Base . Latexise ( Base . Priority <= Priority ) + "}^{" + Exponent . Latexise ( ) + "}" ;
128+ return "{" + Base . Latexise ( Base . LatexPriority <= LatexPriority ) + "}^{" + Exponent . Latexise ( ) + "}" ;
129129 }
130130 }
131131 }
@@ -134,7 +134,7 @@ public partial record Factorialf
134134 {
135135 /// <inheritdoc/>
136136 public override string Latexise ( ) =>
137- Argument . Latexise ( Argument . Priority <= Priority ) + "!" ;
137+ Argument . Latexise ( Argument . LatexPriority <= LatexPriority ) + "!" ;
138138 }
139139
140140 partial record Signumf
0 commit comments