@operator = :*
end
def to_latex_local
- # FIXME: too dirty
- if right.instance_of?(LiteralNode) ||
- right.instance_of?(RootNode) ||
- right.instance_of?(FactorialNode)
-
- unless right.to_s.match(/\A[-\.\d]+\z/)
- return "#{left.to_latex}#{right.to_latex}"
- end
+ _right = right.to_latex
+ if _right.match(/\A\(*-?\d/)
+ return "#{left.to_latex} \\times #{_right}"
end
- "#{left.to_latex} \\times #{right.to_latex}"
+ "#{left.to_latex}#{_right}"
end
end
[
'1 / (x + 4)(x - 2) div 5',
'1 / ((x + 4) * (x - 2) / 5)',
- '\frac{1}{(x + 4) \times (x - 2) \div 5}',
'1 / ((x + 4) * (x - 2) div 5)',
- '\frac{1}{(x + 4) \times (x - 2) \divide 5}',
+ '\frac{1}{(x + 4)(x - 2) \div 5}',
+ '\frac{1}{(x + 4)(x - 2) \divide 5}',
],
[
'25.33 - (-0.99)',
[
'(-83.68) * 10.23',
'(-83.68) * 10.23',
- '(-83.68) \times 10.23',
'(-83.68) * 10.23',
'(-83.68) \times 10.23',
+ '(-83.68) \times 10.23',
],
[
'x^2 + 7x - 8',
'x^2 + 7 * x - 8',
- 'x^2 + 7x - 8',
'x^2 + 7 * x - 8',
'x^2 + 7x - 8',
+ 'x^2 + 7x - 8',
],
[
'3.4 / 54 div 2 / 6',
'3.4 / 54 / (2 / 6)',
- '\frac{3.4}{54} \div \frac{2}{6}',
'3.4 / 54 div (2 / 6)',
+ '\frac{3.4}{54} \div \frac{2}{6}',
'\frac{3.4}{54} \divide \frac{2}{6}',
],
[
+ '5 * (-2)',
+ '5 * (-2)',
+ '5 * (-2)',
+ '5 \times (-2)',
+ '5 \times (-2)',
+ ],
+ [
+ '5 * (-2x)',
+ '5 * ((-2) * x)',
+ '5 * ((-2) * x)',
+ '5 \times ((-2)x)',
+ '5 \times ((-2)x)',
+ ],
+ [
'5x * 2y',
'5 * x * 2 * y',
- '5x \times 2y',
'5 * x * 2 * y',
'5x \times 2y',
+ '5x \times 2y',
],
[
'5x^2 * 2y^3',
'5 * x^2 * 2 * y^3',
- '5x^2 \times 2y^3',
'5 * x^2 * 2 * y^3',
'5x^2 \times 2y^3',
+ '5x^2 \times 2y^3',
],
[
'2root(2) * 35',
'2 * sqrt(2) * 35',
- '2\sqrt{2} \times 35',
'2 * sqrt(2) * 35',
'2\sqrt{2} \times 35',
+ '2\sqrt{2} \times 35',
],
- [ '2i', '2 * %i', '2\i', '2 * %i', '2\i', ],
- [ '2e', '2 * %e', '2\e', '2 * %e', '2\e', ],
- [ '2pi', '2 * %pi', '2\pi', '2 * %pi', '2\pi', ],
- ].each do |original, maxima, latex, normalize, ascii_math_ml|
+ [ '2i', '2 * %i', '2 * %i', '2\i', '2\i', ],
+ [ '2e', '2 * %e', '2 * %e', '2\e', '2\e', ],
+ [ '2pi', '2 * %pi', '2 * %pi', '2\pi', '2\pi', ],
+ ].each do |original, maxima, normalize, latex, ascii_math_ml|
context original do
subject.to_latex.should == @latex
end
- it 'normalize' do
- subject.normalize.should == @normalize
- end
-
it 'ascii_math_ml' do
subject.to_ascii_math_ml.should == @ascii_math_ml
end
+ it 'normalize' do
+ subject.normalize.should == @normalize
+ end
+
it 'to_s as normalize' do
subject.to_s.should == @normalize
end