[texhax] Using TeX tool in application
uwe.lueck at web.de
Thu Jun 5 00:58:36 CEST 2008
"Piotr Turkowski" <pturkowski at gmail.com> wrote 31.05.2008 05:01:59:
> The program will be platform independant by using Qt4
> platform, and as a result it will generate raport from its
> calculations and as you probably feel - it will contain a lot of
> equations. Therefore i've decided to use TeX as a tool to make those
> equtions look good. I plan to write simple *.tex files and convert
> them to pdf. I dont know yet if it will be possible to do it like: tex
> -> pdf, or tex -> dvi -> ps ->pdf, or any other way - the final result
> has to be a pdf file. This is dictated by the platform and program
> indepent policy which i try to input on the project. PDF being the
> most spred exchange file format is the most suitable solution for me.
tex -> pdf!
> My question is: is it possible to include tools like dvips or pdfTeX
> in this project ? What i need is to link them directly in my
> application or have them as a small command line tool, which will be
> called after generating .tex file, either way is okay,
simple, as soon as you have a TeX installation including pdfTeX,
at least for _you_
> but this
> program has to be distributed with the program i'm working on. Meaning
> it can't be required by program, it has to provide it, so the end-user
> will not need to take care of it.
_that_ simplicity is not so easy. Distributing _one_ pdfTeX (binary!)
(and TeX installation) with your program would not be very platform-independant.
However, your program would just do what TeX shells (WinShell for Windows,
e.g.) do. So just look at some of them to see what you have to do.
"WinShell for Windows" tells you that TeX shells are "platform-independant"
to a limited extent (in general). Now, that WinShell (which I know best)
is based on installing a TeX system (e.g., MiKTeX for Windows) first and then,
in installing the shell, provide it with the command lines, paths, ...
appropriate for that TeX system. Your program would need just an
installation procedure like this. This is not a real problem, is business as usual,
I just wanted to tell you that you were dreaming.
Or you would have to distribute TeX installations, one for each platform ...!?
> The program is going to be open source, licenced (most probably) under
> GNU/GPL v3 and it's going to be written in C++.
... license problems (maybe there are only commercial TeX installations for
certain platforms [Apple MacIntosh!? "Textures"]), and you can't really be
sure that they suffice, depending on which version of a platform the end-user
has, or even on his hardware. You also would have to account for a latex.fmt
or so whose versions can differ much, e.g.: differing sizes of certain memory
regions which may result in "TeX capacity exceeded" with your program.
Your program might need to include a procedure to generate an .fmt
that is appropriate for the requirements of your program.
Two extreme alternatives. Note, I have never attended a course on
programming, TeX is the only programming language which I can produce
something of use with. I just have been thinking on certain things I have
mused about recent months and studied CTAN for.
1. At least in theory, you can do anything with TeX macros that you can
do with any other programming language, see
(a BASIC interpreter, e.g. I see there it is said about c2latex it could
translate C Code into LaTeX code, which I don't believe after reading
descriptions of c2latex elsewhere.) What you find there seems to be
only something like fun or sports so far; I would like to know whether,
e.g., _you_ could implement your program by TeX macros instead of C,
and how long the end-user would have to wait for the the end of one
TeX run, as compared with a binary implementation of your program.
One very important merit of this approach would be that you could
rely on TeX's impressive portability. Your "program" could be run
wherever there is a TeX installation, without any C compiler.
This idea indeed gave rise to the docstrip TeX package which is standard
for installing LaTeX packages and typeset their documentation;
and thus it is an example of a really very _useful_ TeX package replacing
some binary installation program.
2. May be you could hardwire a TeX installation in your C code!?
E.g., port the pdfTeX source into your code, moreover font informations
and TeX macro packages!? If you could, you would perhaps become
around half as famous as Donald Knuth and/or very rich ... ;-)
Namely, building a TeX installation has long been an adventure --
you could read mails like "I updated my ... installation, and now
_nothing_ works". (MiKTeX 2.7 seems to be very reliable and
More information about the texhax