User:Rkundalini~enwiki/PPCHTeX
Wikisophia chemistry rendering
[edit]Regarding the discussion on Wikipedia_talk:WikiProject_Drugs, here are some examples. As you can see PPCHTeX is fine when rendered well by WikiTeX.
Here is a structure rendered using the notes below, with ugly aliasing:
Here it is using WikiTex:
Here it is without forcing sans serif, in WikiTeX
Old PPCHTex Notes
[edit]The following notes were here for use while wikisophia was down; it is now back! I'll keep this for a while anyways
While http://wikisophia.org is down, the following might be useful for people who want to continue using PPCHTeX to make pngs for wikipedia. Here is what I did, quick and very dirty:
- Download PPCHTeX from http://www.pragma-ade.com/ppchtex.htm
- Scratch my head at the very confusing documentation, give up on a proper installation and just try to run latex on a file containing the chemical. Here is an example (LaTeX2e) with the extra guff required:
\documentclass[a4paper]{article} \usepackage{m-pictex} \usepackage{m-ch-en} \usepackage{graphics} \pagestyle{empty} \begin{document} \resizebox{0.5\hsize}{!}{ \startchemical[size=big] \chemical[SIX,B,EB135] \chemical[SIX,MOV1,S6,B1,EB1,+SB2,-SB3,Z3,SR3,RZ3][\sf N,\sf H] \chemical[SIX,MOV1,B56] \chemical[SIX,MOV1,+SB5,Z6][\SL{\sf NH_2}] \stopchemical } \end{document}
- Try to run latex on the file, and each time you get an error that a file can't be found, copy the required file into the current directory. You will either find it in some strange subdirectory in the strucure that expands from the zip file you downloaded, or not. If not, find it with a google search instead.
- Once that works, you will have a dvi file. Using ImageMagick, convert it to png format, including antialiasing, automatic cropping, and transparent background:
convert +antialias $1.dvi -crop 0x0 -transparent "#FFFFFF" $1.png
(where $1.dvi denotes your dvi file)
The result for the above input should look like this:
There you have it. The 0.5 argument to resizebox is a kludge to get approximately the right size of image. Possibly an argument could be given to convert instead to get a consistent image size. One day web browsers will properly support SVG format and we could avoid silly raster formats like png altogether.
Here is a handy script to convert it, print the full path of the file to upload, and text to paste into the image description, and display the image:
#!/bin/csh latex $1.tex convert +antialias $1.dvi -crop 0x0 -transparent "#FFFFFF" $1.png echo `pwd`/$1.png echo "[[PPCHTeX]]" source: awk 'BEGIN{i=0;}{if (match($0,"startchemical")!=0) i=1; if (i) printf " %s\n", $0; if (match($0,"stopchemical")!=0) i=0;}' < $1.tex echo "{{msg:PD}}" display $1.png