I did manage to implement with a basic module a cycle of 'take user input' => write to a foo.tex then tex=> dvi and dvi=>ps and ghostscript ps=>png and return the img tag and source to the page, and I got tikz images on the fly. With the latex package 'preview' I really got good results (images cropped just right). I am wondering about that can we make it with drutex_render. Can I change shell commands in 'custom format' to my will (I couldn't). Or can I implement it as a submodule?
I don't know if the module should support graphic content, after all it's for math and doing its job. But tikz afaik is really cool and popular among latex users.

Comments

oz_an’s picture

Since no one answered, maybe it was obvious but not to me.
I hacked the module's original shell commands in the drutex_render. I changed original dvipng to my wish. Everything is OK in the local. In the shared hosting I had to change some settings according to the installed software. But I'm drawing perfect and completely transparent pngs of function graphs right into the page, it is fantastic!. No more repetitive image edits and uploads if I don't like st in my img.

Everything should be in accord though, gs version, produced ps version etc.. So it is very hard for a shared.

Melkor’s picture

Could you please share your code for tikz support? Or at least provide some instructions how to do that. I can prepare a patch.
Also it will be great to have support for eepic and pgf packages.

This feature has to be the part of drutex.

Melkor’s picture

I think, I got the process for tikz:
1. TeX code with PGF/Tikz (e.g. http://www.texample.net/tikz/examples/pgfplots/) tikz.tex
2. (compiling to dvi) latex tikz.tex
3. (dvi->ps) dvips tikz.dvi
4. (ps->png) gs -dNOPAUSE -sDEVICE=png256 -sOutputFile=tikz.png -q -dBATCH tikz.ps

TeXLive 2010 (latest)

so custom script should look something like that

PATH=/usr/local/texlive/2010/bin/x86_64-linux:$PATH && export PATH && cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:" latex -interaction=batchmode [HASH].tex
dvips -o [TMP_DIR]/[HASH].ps [TMP_DIR]/[HASH].dvi
gs -dNOPAUSE -sDEVICE=png16m -sOutputFile=[IMG_FILE] -q -dBATCH [TMP_DIR]/[HASH].ps
Melkor’s picture

One more question.

I am receiving ! LaTeX Error: File `tikz.sty' not found. error with \usepackage{tikz}.

What may be the issue? TeXLIve is properly installed and tikz.sty is present in the system and everything runs perfect under my account.

Melkor’s picture

This issue is solved. The problem was that executing command does not know where texlive is located.
So, I added PATH export to latex line.

PATH=/usr/local/texlive/2010/bin/x86_64-linux:$PATH && export PATH && cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:" latex -interaction=batchmode [HASH].tex

where /usr/local/texlive/2010/bin/x86_64-linux is actually the path to your TeX bin directory.

anernest’s picture

Did you have to make any mods to the drutex_render.inc file to get this working? I'm able to render tikz at the command line, but not within drupal. I't look like the tikz code is being stripped out because all I get is the plain text returned?

oz_an’s picture

Did you wrap it a tex tag. Is your input filter drutex and no other input filter touches before it?

anernest’s picture

Thanks, oz_an, it looks like that may be part of the problem. I'm using tags (I'm assuming that this triggers a different tex template that I have not modd'ed yet.

oz_an’s picture

I'm using just the plain <tex> </tex> tags and I used to put a % character at the end of every line of my tikz code because basic html filters add <br> to the end of the lines so latex syntax errors occur.

oz_an’s picture

I did encounter a lot of difficulty cropping the whitespace around the image when implementing it again. My final config is this in case it helps someone:
my teplate.tex preamble

\documentclass{article}

% good math support
\usepackage{amsmath, amsfonts, amssymb}
% UTF-8 support
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,plotmarks,decorations.pathreplacing,patterns,backgrounds,fadings}%

\usepackage[active,tightpage,displaymath]{preview}
\PreviewEnvironment{tikzpicture}

my custom conversion method:

cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:" /path/to/mylatex/pdflatex -interaction=batchmode [HASH].tex
 convert -density [DPI] -trim -transparent "#FFFFFF" [TMP_DIR]/[HASH].pdf [IMG_FILE]

I'm using drutex 7.x-1.x-dev
drupal 7.8
My latex is texlive 2011

Codenext’s picture

Issue summary: View changes

@oz_an can you please explain step by step, how to use this in drupal 7 site. Very Thanks.