Importing Latex inside Coreldraw

 

If you dislike xfig for drawing latex pictures and would like to draw using Coreldraw (or illustrator), there is a very easy way to import all your latex labels inside coreldraw pictures. All you have to do is type the following latex code in labels.tex:


\documentclass{minimal}
\begin{document}
$2^{i+x}$ % Of course, Change this line to the formula you want
\end{document}

Now type out the following Makefile in the same directory:

all:
latex labels.tex
dvips -E labels.dvi -o labels.eps

Now type "make" in the directory, and goto Coreldraw main menu -> File -> Import. Select Files of Type: "EPS, PS, PRN - Postscript". Select labels.eps and click "Import". Place the formula anywhere you want on the canvas and scale it to appropriate size you need. I usually do a 250% on both X and Y.

Wasn't it easy?

 

Another way to accomplish this, and the way I do it, is to wrap the latex stuff in a python script called latex2eps.

#!/usr/bin/env python
import sys,os

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print """Usage: latex2eps '$x$'     """
        print "Output file: labels.eps"
        sys.exit(1)

    print "Entered text = " , sys.argv[1]

    s = """
\documentclass{minimal}
\\begin{document}
%s
\end{document}
    """ % sys.argv[1]


    outf = open("output.tex", "w")
    outf.write(s)
    outf.close()

    os.system("latex output.tex")
    os.system("dvips -E output.dvi -o labels.eps")
    os.remove("output.aux")
    os.remove("output.dvi")
    os.remove("output.log")
    os.remove("output.tex")

Now I can say latex2eps "$x$" on the command line and import it in coreldraw. To speed up the import, I use a macro in coreldraw (link to nice book on CD macros, a more up2date one is here):

Sub latexImporter()
    '
    ' Recorded 2/24/2010
    '
    ' Description:
    '
    '
    Dim impflt As ImportFilter
    Set impflt = ActiveLayer.ImportEx("C:\Directory_in_which_latex2eps_is_run\labels.eps", cdrPSInterpreted)
    impflt.Finish
    Dim s1 As Shape
    Set s1 = ActiveShape
    s1.SetPosition 0, 0
    ActiveDocument.ReferencePoint = cdrCenter
    s1.Stretch 3, 3
End Sub

You can record this yourself using tools->VisualBasic->Record (I usually name and save it in the global macro space in coreldraw) and then set a kestroke to run it using tools->options->customization->Commands->Macros (Select Macro) -> Shortcut Keys.