"Superior" LaTeX text processing using a "Low Level Font Command" input file in texmanager.py & backend_ps.py

Dear All,

I have hacked a bit at texmanager.py and backend_ps.py in order to
generate "superior" text output using LaTeX.

It involves "including" a user specific "low level font command" input
file useing some "new" rcParams and the savefig command with the PS
backend in you main "pylab" script:



The "low level font command" input file has the following included:

\fontencoding{T1} % T1 - Latin 1, etc.
\fontfamily{phv} % cmr - Computer Modern Roman, ptm -
Times-Roman, phv - Helvetica, etc.
\fontseries{m} % m - Medium, b - Bold, bc - Bold Condensed, bx
- Bold Expanded
\fontshape{n} % n - Upright (Normal), it - Italic, sl -
        % sc - Small Caps, ui - Upright Italics,
ol - Outline
\selectfont % Above font changes will now become

or for those who know all the abreviations by hart:


Attached are examples of three "low level font command" files for
different "application", e.g. a Thesis, a Presentation or an Article...

In texmanager.py the "TexManager.get_tex_command" needs to be changed

    def get_tex_command(self, tex, fname):
        fh = file(fname, 'w')
        if rcParams['text.tex.engine'] == 'latex':
            print >>fh, r"""\documentclass{article}
\begin{document}""" % (rcParams['font.latex.package'])
            if rcParams['font.latex.inputfile']:
                inputfile = rcParams['font.latex.inputfile.filename']
                if os.path.exists(inputfile):
                    print >>fh, r"\input{%s}" % inputfile
            print >>fh, r"""%s
\end{document}""" % tex
            command = 'latex -interaction=nonstopmode "%s"'%fname
            s = r"""\def\frac#1#2{ {#1 \over #2} }
""" % tex
            command = 'tex "%s"'%fname
        return command

(or see attached)

And in backend_ps.py, from line 1059:

        if rcParams['text.usetex']:
            if rcParams['text.tex.engine'] == 'latex':
                fontpackage = rcParams['font.latex.package']
                fontpackage = 'type1cm'
            pw, ph = defaultPaperSize
            if width>pw-2 or height>ph-2: pw,ph =
            print >>latexh, r"""\documentclass{scrartcl}
\begin{figure}[th!]""" % (fontpackage, pw, ph, pw-2, ph-2, pw, ph)
            if rcParams['font.latex.inputfile']:
                usefontfile = rcParams['font.latex.inputfile.filename']
                if os.path.exists(usefontfile):
                    print >>latexh, r"\input{%s}" % usefontfile
            print >>latexh, r"""%s
"""% ('\n'.join(renderer.psfrag), epsfile)


(or see attached)

Hope someone (else) finds it usefull.

Vriendelik die uwe,

   Peter-Jan Randewijk
   Senior Lektor - Drywingselektronika & Elektriese Aandrywing

    Departement E&E. Ingenieurswese
    Universiteit Stellenbosch
    Privaatsak X1
    Matieland, 7603
    Tel: +27 (0) 21 808 4457 (w)
    Faks: +27 (0) 21 808 3951 (w)
    Tel: +27 (0) 21 883 8592 (h)
    Sel: +27 (0) 83 556 5809 (h)

backend_ps.py (40.3 KB)

texmanager.py (11.3 KB)

myarticle.llfc (1006 Bytes)

mypresentation.llfc (1005 Bytes)

mythesis.llfc (1006 Bytes)