Re: TeXForm, OutputForm questions ?
- To: mathgroup@smc.vnet.net
- Subject: [mg11118] Re: TeXForm, OutputForm questions ?
- From: "P.J. Hinton" <paulh@wolfram.com>
- Date: Sun, 22 Feb 1998 14:55:43 -0500
Your query has been forwarded to me by the comp.soft-sys.math.mathematica moderator. > To: comp-soft-sys-math-mathematica@moderators > Message-ID: <34E97FB6.460C374C@ico.unil.ch> > Date: Tue, 17 Feb 1998 13:16:54 +0100 > From: Alexej Jerschow <Alexej.Jerschow@ico.unil.ch> To: mathgroup@smc.vnet.net > Subject: [mg11118] TeXForm, OutputForm questions ? > 1) TeXForm creates matrices where the columns are separated by \& rather > than &, so I have to change that every time I include text in the LaTeX > file. Can this be switched ? > 2) Matrices are created with the\matrix command, this does not seem to > suit amstex or amsmath package. Simple way to fix this ? > 3) Possibility to create LaTeX tabulars with formulae as entries ? (so > that I don't have to include $ pairs for every entry myself) The behavior of TeXForm under Mathematica 2.x and 3.0 are significanly different. It is not clear from the behaviors you describe what version you might be using. Could you give me a more precise description of what you do to generate the TeX form of matrices and tables? If you are using Mathematica 3.0, I may be able to provide you with some guidance on how to get the best output possible by taking advantage of the front end's typesetting mechanisms. > These questions may be rather related to Mathematica output form: > 4) Simple way to represent exp ans exp rather than e^{...}. (* First, disable spell warning message because exp is similar to Exp *) Off[General::spell1] (* Temporarily disable protection on changes to the Power function *) Unprotect[Power] (* Use Format to tell TeXForm how to format expression. See Mathematica book, Section 2.8.16 *) Format[Power[E,x_],TeXForm]:= exp[x] (* Restore protection on Power *) Protect[Power] (* Reenable spelling warnings *) On[General::spell1] (* Now when we apply TeXForm... *) E^(x^2+y^2) // TeXForm (* we get exp instead *) \exp({x^2} + {y^2}) > 5) represent factors like \frac{1}{\sqrt{2}} as 2^{-1/2}, possible ? Similar line of reasoning, except this time we have to turn to Mathematica 3.0's box typesetting mechanism: Unprotect[Power] Format[Power[x_,Rational[-1,2]],TeXForm]:=SuperscriptBox[MakeBoxes[x], RowBox[{ RowBox[{"-", "1"}], "/", "2"}]] Protect[Power] When we evaluate: 1/(x^2 + y^2)^(1/2) // TeXForm We get: {{\big({x^2}+{y^2}\big)}^{-1/2}} > 6) represent \cos(\frac{\beta}{2})^2 rather as \cos^2\frac{\beta}{2}, > possible ? Similar to question (5) Format[Power[Cos[x_],2],TeXForm]:= RowBox[{ SuperscriptBox["Cos", "2"], "(", MakeBoxes[x], ")"}] Evaluation of: Cos[beta/2]^2 //TeXForm Gives: {{\cos }^2}\Big(\frac{\beta}{2}\Big) -- P.J. Hinton Mathematica Programming Group paulh@wolfram.com Wolfram Research, Inc. http://www.wolfram.com/~paulh/