You are not logged in.

#1 2010-05-19 20:55:51

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,078
Website

tex2png - another (La)TeX to PNG converter

Project page: http://xyne.archlinux.ca/projects/tex2png

After fiddling with other converters I ended up writing my own to do what I needed. I currently use this in my backend toolchain on xyne.archlinux.ca to insert formulae automatically.

I know about texvc but I found it to be poorly documented and very annoying to use. tex2png is a relatively simple bash script with a few convenience options that should be easy to tweak if necessary.

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2010-05-19 21:05:57

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 616

Re: tex2png - another (La)TeX to PNG converter

He, this is funky; I recently needed to create a hell lot of png's of single equations and more or less used the approach you took.

Offline

#3 2010-05-19 22:47:31

jt512
Member
Registered: 2009-02-19
Posts: 262

Re: tex2png - another (La)TeX to PNG converter

@xyne: Can you provide an example of how to use the command?  I can't seem to get it to do anything.

Jay

Offline

#4 2010-05-19 22:50:41

kazuo
Member
From: São Paulo/Brazil
Registered: 2008-03-18
Posts: 413
Website

Re: tex2png - another (La)TeX to PNG converter

jt512 wrote:

@xyne: Can you provide an example of how to use the command?  I can't seem to get it to do anything.

Jay

I'm not xyne but 'tex2png -c "$\alpha$"' works for me.

Offline

#5 2010-05-19 23:02:10

jt512
Member
Registered: 2009-02-19
Posts: 262

Re: tex2png - another (La)TeX to PNG converter

kazuo wrote:
jt512 wrote:

@xyne: Can you provide an example of how to use the command?  I can't seem to get it to do anything.

Jay

I'm not xyne but 'tex2png -c "$\alpha$"' works for me.

OK.  Your example works for me, too.  But why doesn't 'tex2png -c "a + b"'?

Offline

#6 2010-05-19 23:34:11

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 616

Re: tex2png - another (La)TeX to PNG converter

jt512 wrote:
kazuo wrote:
jt512 wrote:

@xyne: Can you provide an example of how to use the command?  I can't seem to get it to do anything.

Jay

I'm not xyne but 'tex2png -c "$\alpha$"' works for me.

OK.  Your example works for me, too.  But why doesn't 'tex2png -c "a + b"'?

Because"a+b"isnotmathenvironment.Ithasnomathematicalmeaning(withinLaTeX).Thisishow\usepackage{preview}works.Youwillnottoencludea+beitherininlinemath($$)orinsideamathenvironment().(Youmightwanttoreplaceequationbyequation*ifyoudon'twanttohavenumbering.)

Offline

#7 2010-05-19 23:37:39

jt512
Member
Registered: 2009-02-19
Posts: 262

Re: tex2png - another (La)TeX to PNG converter

OK, so why do I get no output with tex2png -c '"$a+b$"'?

Offline

#8 2010-05-19 23:42:39

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 616

Re: tex2png - another (La)TeX to PNG converter

jt512 wrote:

OK, so why do I get no output with tex2png -c '"$a+b$"'?

I don't know what you are doing, but I do get an output.

(In addition to what I said earlier, the only possible way is to put the equation within inline math ; Xyne uses the textmath options.)

Offline

#9 2010-05-20 00:12:45

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,078
Website

Re: tex2png - another (La)TeX to PNG converter

Use single quotes if you pass the tex string on the command line. If you use double-quotes, bash will try to interpolate "$a" as a variable, e.g. # echo "$a+b$" +b$

You can also use STDIN to pass it tex. Just invoke it "tex2png" then type in what you want. Press ctrl+d to end the input.

That also allows you to pipe in tex. E.g. you can create a plain text file with "$a+b$", save it as "input", then use

tex2png <input

Last edited by Xyne (2010-05-20 00:20:11)

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#10 2010-05-20 04:42:46

jt512
Member
Registered: 2009-02-19
Posts: 262

Re: tex2png - another (La)TeX to PNG converter

Thanks, Xyne.  I think I'll find a lot of use for this utility.

Offline

#11 2010-05-20 06:21:14

cl10k
Member
From: Germany
Registered: 2008-12-24
Posts: 92

Re: tex2png - another (La)TeX to PNG converter

Thanks again Xyne! Haven't tried it yet, but looks promising like always. Good job!

Offline

#12 2010-05-20 14:53:28

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,078
Website

Re: tex2png - another (La)TeX to PNG converter

Stalafin wrote:

(In addition to what I said earlier, the only possible way is to put the equation within inline math ; Xyne uses the textmath options.)

I didn't fully register that bit when I read your post. It only hit me after I hit my own stumbling block while trying to embed plain text.

I don't understand .sty files at all so there might be a much better way to do it, but for now I've implemented a workaround using "\mbox". It seems to handle everything as expected.

I've also added a new option (-i) to specify inline tex. In combination with the aforementioned workaround and the preview package, dvipng's depth and height output should be correct for everything.

Last edited by Xyne (2010-10-30 16:45:03)

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline