The single most problematic thing about the cooperation between texform and
breqn is the excessive amount of grouping used in TexForm. I suspect this is
due to TexForm originally producing TeX, not LaTeX.
In the patch below, I removed most groups, and now even typesetting
4*integrate(1/sqrt tan x,x)
nearly works. (integrate(1/sqrt tan x,x) still doesn't...)
Note that I REALLY think that we should have a new domain LaTeXForm, patching
against TexForm is only for convenience.
Maybe somebody could step in and do a proper cleanup. Some unittesting would
also be extremely appropriate here, I think we could simply compare strings.
Even more importantly, maybe somebody could find out how to produce a png from,
say integrate(1/sqrt tan x,x), so that the overfull boxes are included.
Martin
diff -c /home/martin/fricas/src/algebra/
/home/martin/martin/Axiom/tex.spad.pamphlet
*** /home/martin/fricas/src/algebra/tex.spad.pamphlet 2008-11-04
09:10:03.000000000 +0100
--- /home/martin/martin/Axiom/tex.spad.pamphlet 2008-11-04 11:03:35.000000000
+0100
***************
*** 216,222 ****
-- num : S := concat("%AXIOM STEP NUMBER: ",string(stepNum)$S)
-- [["\["]$(L S), [""]$(L S), ["\]",num]$(L S)]$Rep
num : S := concat(["\setcounter{equation}{", string(stepNum-1)$S,
"}"])$S
! [[num,"\begin{equation}"]$(L S), [""]$(L S), ["\end{equation}]"]$(L
S)]$Rep
coerce(expr : E): $ ==
f : $ := new()$%
--- 216,222 ----
-- num : S := concat("%AXIOM STEP NUMBER: ",string(stepNum)$S)
-- [["\["]$(L S), [""]$(L S), ["\]",num]$(L S)]$Rep
num : S := concat(["\setcounter{equation}{", string(stepNum-1)$S,
"}"])$S
! [[num,"\begin{equation}"]$(L S), [""]$(L S), ["\end{equation}"]$(L
S)]$Rep
coerce(expr : E): $ ==
f : $ := new()$%
***************
*** 386,392 ****
"\rightarrow",
formatTex(second args,prec)]
op = "VCONCAT" =>
! group concat("\begin{array}{c}",
concat(concat([concat(formatTex(u, minPrec),"\\")
for u in args]::L S),
"\end{array}"))
--- 386,392 ----
"\rightarrow",
formatTex(second args,prec)]
op = "VCONCAT" =>
! concat("\begin{array}{c}",
concat(concat([concat(formatTex(u, minPrec),"\\")
for u in args]::L S),
"\end{array}"))
***************
*** 397,414 ****
op = "QUOTE" =>
group concat("{\tt '}",formatTex(first args, minPrec))
op = "BRACKET" =>
! group addBrackets ungroup formatTex(first args, minPrec)
op = "BRACE" =>
! group addBraces ungroup formatTex(first args, minPrec)
op = "PAREN" =>
! group parenthesize ungroup formatTex(first args, minPrec)
op = "OVERBAR" =>
null args => ""
! group concat ["\overline ",formatTex(first args, minPrec)]
op = "ROOT" =>
null args => ""
tmp : S := group formatTex(first args, minPrec)
! null rest args => group concat ["\sqrt ",tmp]
group concat
["\root ",group formatTex(first rest args, minPrec)," \of ",tmp]
op = "SEGMENT" =>
--- 397,414 ----
op = "QUOTE" =>
group concat("{\tt '}",formatTex(first args, minPrec))
op = "BRACKET" =>
! addBrackets formatTex(first args, minPrec)
op = "BRACE" =>
! addBraces formatTex(first args, minPrec)
op = "PAREN" =>
! parenthesize formatTex(first args, minPrec)
op = "OVERBAR" =>
null args => ""
! concat ["\overline ",formatTex(first args, minPrec)]
op = "ROOT" =>
null args => ""
tmp : S := group formatTex(first args, minPrec)
! null rest args => concat ["\sqrt ",tmp]
group concat
["\root ",group formatTex(first rest args, minPrec)," \of ",tmp]
op = "SEGMENT" =>
***************
*** 458,464 ****
-- need to handle indentation someday
null args => ""
tmp := formatNaryNoGroup(" \\ ", args, minPrec)
! group concat ["\begin{array}{l} ",tmp," \end{array} "]
op = "MATRIX" => formatMatrix rest args
op = "ZAG" =>
concat [" \zag{",formatTex(first args, minPrec),"}{",
--- 458,464 ----
-- need to handle indentation someday
null args => ""
tmp := formatNaryNoGroup(" \\ ", args, minPrec)
! concat ["\begin{array}{l} ",tmp," \end{array} "]
op = "MATRIX" => formatMatrix rest args
op = "ZAG" =>
concat [" \zag{",formatTex(first args, minPrec),"}{",
***************
*** 495,501 ****
hold := group concat [hold," ",formatTex(first args,minPrec)]
s := concat [s," ",hold]
if opPrec < prec then s := parenthesize s
! group s
formatMatrix(args : L E) : S ==
-- format for args is [[ROW ...],[ROW ...],[ROW ...]]
--- 495,501 ----
hold := group concat [hold," ",formatTex(first args,minPrec)]
s := concat [s," ",hold]
if opPrec < prec then s := parenthesize s
! s
formatMatrix(args : L E) : S ==
-- format for args is [[ROW ...],[ROW ...],[ROW ...]]
***************
*** 504,550 ****
for i in 2..#(first(args) pretend L E) repeat
cols := concat(cols,"c")
cols := concat(cols,"} ")
! group addBrackets concat
["\begin{array}",cols,formatNaryNoGroup(" \\ ",args,minPrec),
" \end{array} "]
formatFunction(op : S, args : L E, prec : I) : S ==
! group concat [op, " ", parenthesize formatNary(",",args,minPrec)]
formatNullary(op : S) ==
op = "NOTHING" => ""
! group concat [op,"()"]
formatUnary(op : S, arg : E, prec : I) ==
p : I := position(op,unaryOps)
p < 1 => error "unknown Tex unary op"
opPrec := unaryPrecs.p
s : S := concat [op,formatTex(arg,opPrec)]
! opPrec < prec => group parenthesize s
op = "-" => s
! group s
formatBinary(op : S, args : L E, prec : I) : S ==
! p : I := position(op,binaryOps)
p < 1 => error "unknown Tex binary op"
op :=
op = "|" => " \mid "
op = "**" => " \sp "
! op = "/" => " \over "
! op = "OVER" => " \over "
op = "+->" => " \mapsto "
op
- opPrec := binaryPrecs.p
s : S := formatTex(first args, opPrec)
! t : S := formatTex(first rest args, opPrec)
! op = " \over " => group concat ["\frac",s,t]
s := concat [s, op, t]
! group
! opPrec < prec => parenthesize s
! s
formatNary(op : S, args : L E, prec : I) : S ==
! group formatNaryNoGroup(op, args, prec)
formatNaryNoGroup(op : S, args : L E, prec : I) : S ==
null args => ""
--- 504,552 ----
for i in 2..#(first(args) pretend L E) repeat
cols := concat(cols,"c")
cols := concat(cols,"} ")
! addBrackets concat
["\begin{array}",cols,formatNaryNoGroup(" \\ ",args,minPrec),
" \end{array} "]
formatFunction(op : S, args : L E, prec : I) : S ==
! concat [op, " ", parenthesize formatNary(",",args,minPrec)]
formatNullary(op : S) ==
op = "NOTHING" => ""
! concat [op,"()"]
formatUnary(op : S, arg : E, prec : I) ==
p : I := position(op,unaryOps)
p < 1 => error "unknown Tex unary op"
opPrec := unaryPrecs.p
s : S := concat [op,formatTex(arg,opPrec)]
! opPrec < prec => parenthesize s
op = "-" => s
! s
formatBinary(op : S, args : L E, prec : I) : S ==
! p : I := position(op, binaryOps)
p < 1 => error "unknown Tex binary op"
+ opPrec := binaryPrecs.p
op :=
op = "|" => " \mid "
op = "**" => " \sp "
! op = "/" or op = "OVER"
! => if width(first args)$E < 80
! and width(second args)$E < 80
! then " \frac "
! else (opPrec := 800; " / ")
op = "+->" => " \mapsto "
op
s : S := formatTex(first args, opPrec)
! t : S := formatTex(second args, opPrec)
! op = " \frac " => concat ["\frac", group s, group t]
s := concat [s, op, t]
! opPrec < prec => parenthesize s
! s
formatNary(op : S, args : L E, prec : I) : S ==
! formatNaryNoGroup(op, args, prec)
formatNaryNoGroup(op : S, args : L E, prec : I) : S ==
null args => ""
Diff finished. Tue Nov 4 11:36:46 2008
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---