About these pages

Obsolete!

This information is probably all obsolete now we have Mathematica 3.0 which can save directly in TeX format.
 TEXHAX   91_50    W1  V 80  Trunc=80 Size=482 Line=199 Col=1 Alt=0

Date: Fri, 25 Oct 1991 17:36:40 GMT
From: gabriel@sce.carleton.ca (Gabriel Warshaw)
Subject: Exporting Formulae from Mathematica to LaTeX -- Summary
Keywords: LaTeX, Mathematica

        I have been trying to use the "TeXForm" function of
Mathematica to convert mathematical expressions that can be used
directly by LaTex. For the expressions of interest (they consist of
dozens or hundreds of terms), the LaTex output using the
TexForm-generated input is not very readable and some of it completely
unreadable due to misplaced brackets, tiny text, etc.
        I requested help to answer the following:
Is there a better way to get the output I want?  Are there any routines
available to conveniently get output which can be directly used by LaTex without

 errors?

The following is a summary of the responses I received.

One of the ways to save Mathematica output in TeXForm is to use
Splice["infile.mtex"].  To use this function, you need to create an input file
named infile.mtex, using a text editor outside of Mathematica.  In this file,
you must enclose the expressions that you want evaluated by Mathematica with <*
and *> .  Then, within Mathematica, invoke Splice["infile.mtex"].  Mathematica
will take  <*some expression*>  of infile.mtex, evaluate 'some expression' as a
Mathematica input, convert the output to TeXForm and will save in a new file
named infile.tex.  Any text in the inputfile not enclosed between <* and *> is
copied without change to the infile.tex.  Notice that the default format for
Mathematica output by Splice[] is determined by the extension of the input file
name (consult the Mathematica book for other forms):
                input file ->   name.mtex
                output file -> name.tex

Another way to get TeXForm is to use OpenWrite command.  Use the following
syntax:
        if y = Integrate[Sin[x],x]
         then,
                OpenWrite["filename", FormatType->OutputForm]
                Write["filename", TeXForm[y]]
                Close["filename"]
The output file will contain TeXForm of the result of integration.

xxxxxxxxxxxxxxxxxxx

Try instead `Scientific Word' from TCI in New Mexico...
Scientific Word allows you to set up equations in classic WYSWYG style.
The result is then converted to TeX macros for insertion in your TeX document.

xxxxxxxxxxxxxxxxxxx

  Just a short remark to what may/may not be part of the
  problem you describe: we have Mathematica 1.0 for VAX/VMS and
  in this version TeXForm has a bug (among so many other bugs) -
  TeX-commands at the end of a line are broken, like          \ov
  er instead of                                               \over

  Don't know if you have this problem - but it might be....

xxxxxxxxxxxxxxxxxx

A line-splitting algorithm is available for TeX form in the Maple
computer algebra program. That may be of use to you, if you are
willing to use Maple instead.

Two other things to consider:
(a) Is mathematica's display order really what you want to see?
(b) Do you really want to typeset an expression with hundreds
of terms (since it is unfit for consumption by anyone, really)?

There was also a line-splitting algorithm implemented in Macsyma,
but with an EQN/TROFF target, and also, I think one with a TeX
target, but that one was not widely distributed.

Good luck ... incidentally, TeX may choke on really large expressions,
so ASCII may be what you have to use.

-----------------------------------------------------------------------

10:33:12 Wed 29/09/93
Worth mentioning here that I have installed the program nb2tex which does a good
job of converting Mma notebooks to TeX, including graphics.  Link to it in my
bin directory.