
Figure 1. XyMTeX as part of a communication system of chemical documents. The acronym "DVI" means a "device-independent" file produced by a TeX/LaTeX processing.
During the last decade (1990s), on the other hand, desktop publishing (DTP) based on the PostScript language has emerged as an alternative methodology to cover conventional publishing systems and the Internet communication systems. In particular, PDF (Portable Document Format) based on the PostScript has attracted anxious attention since the PDF is capable of bringing a sound method to cover them.
The TeX/LaTeX typesetting system has been influenced by this trend of the DTP. Particularly in treating graphic data [11], the TeX/LaTeX system is now recognized as a programming language to produce PostScript codes in place of TeX-original DVI (device-independent) codes. this usage of the TeX/LaTeX system stems from the \special function, which was originally equipped to accept such graphic data [12]. On the basis of the \special function, versatile tools such as PSTrick [13] have been developed to output PostScript codes. Moreover, tools for translating DVI codes (including the codes due to \special) to PostScript codes and tools for converting the PostScript codes into PDF codes have become easily available.

Figure 2. XyMTeX2PS as an alternative methodology in a communication system of chemical documents
In contrast to the general status of the TeX/LaTeX typesetting system, chemical documentation by TeX/LaTeX is left behind the trend of the DTP, because XyMTeX (up to Version 3.00) has not fully utilized the graphic utilities of PostScript and PDF. Hence, the XyMTeX system should be improved to be compatible with PostScript and PDF, so that the PDF technique will be applied to the two fields of chemical documentation (i.e. printing and Internet communication).
As clarified in the preceding paragraphs, the present article aims at improving the XyMTeX system to be compatible with PostScript and PDF. Thereby, the improved XyMTeX system (XyMTeX2PS) will cover the two fields of chemical documentation (i.e. printing and Internet communication), as shown in Figure 2. A subsidiary aim is to develop more elaborate stereochemical expressions such as wedged bonds, because the improvement permits us to be free from the restriction of the LaTeX picture environment.
\documentclass{article}
\usepackage{xymtex}
\begin{document}
(formula)
%Any code cited in this article
%is inserted here.
\end{document}
\documentclass{article}
\usepackage{xymtexps}
\begin{document}
(formula)
%Any code cited in this article
%is inserted here.
\end{document}
Table 1. Package Files of XyMTeX2PS and Related Files
| package name | included functions |
|---|---|
| XyMTeX Files | |
| chemstr.sty | basic commands for atom- and bond-typesetting |
| hetarom.sty | macros for drawing vertical types of carbocyclic and heterocyclic compounds |
| hetaromh.sty | macros for drawing horizontal types of carbocyclic and heterocyclic compounds |
| carom.sty | macros for drawing vertical and horizontal types of carbocyclic compounds |
| lowcycle.sty | macros for drawing five-or-less-membered carbocycles. |
| ccycle.sty | macros for drawing bicyclic compounds etc. |
| hcycle.sty | macros for drawing pyranose and furanose derivatives |
| aliphat.sty | macros for drawing aliphatic compounds |
| locant.sty | commands for printing locant numbers |
| polymers.sty | commands for drawing polymers |
| fusering.sty | commands for drawing units for ring fusion |
| methylen.sty | commands for drawing zigzag polymethylene chains |
| sizeredc.sty | commands for size reduction |
| XyMTeX2PS File | |
| xymtx-ps.sty | macros for PostScript printing (XyMTeX2PS, XyMTeX Version 4.02). These macros |
| are substituted for several macros contained in the chemstr package. | |
| XyMTeX Utilities | |
| xymtex.sty | a package for calling all package files except xymtx-ps.sty |
| (no PostScript) | |
| xymtexps.sty | a package for calling all package files |
| (PostScript, i.e. with xymtx-ps.sty) | |
| Related Files | |
| chemist.sty | commands for using `chem' version and chemical environments |
| chmst-ps.sty | macros for PostScript printing. These macros are substituted for several macros |
| contained in chemist package. | |
%Sample:
\def\CompareSample{%
\cyclohexanev{%
1D==O;4SA==CH$_{3}$;4SB==F}
\changeunitlength{0.08pt}
\cyclohexanev{%
1D==O;4SA==CH$_{3}$;4SB==F}
\changeunitlength{0.06pt}
\cyclohexanev{%
1D==O;4SA==CH$_{3}$;4SB==F}
}
%Compare:
\begin{tabular}{l}
PostScript-compatible mode \\
(wedge and hashed dash): \\
\CompareSample \\
\noalign{\vskip10pt}
PostScript-compatible mode \\
(wedge and hashed wedge): \\
\wedgehashedwedge
\CompareSample \\
\noalign{\vskip10pt}
PostScript-compatible mode \\
(dash and hashed dash): \\
\dashhasheddash
\CompareSample \\
\noalign{\vskip10pt}
\TeX/\LaTeX{}-compatible mode: \\
\reducedsizepicture
\CompareSample \\
\end{tabular}

Figure 3. Comparison between PostScript-compatible mode and TeX/LaTeX-compatible mode.
Each row of Figure 3 contains three formulas drawn by the same mode, which are different in size (unit lengths: 0.1pt, 0.08pt, and 0.06pt). As for the PostScript-compatible mode, the switch \wedgehasheddash or a default condition produces a pair of wedged bonds/hashed dash bonds (the first row), the switch \wedgehashedwedge produces a pair of wedged bonds/hashed wedged bonds (the second row), and the switch \dashhasheddash generates a pair of dash bonds/hashed dash bonds (the third row).
By means of the sizeredc package (distributed after Version 3.00), the original LaTeX picture environment can be used by a switching declaration \reducedsizepicture in order to reduce the sizes of formulas, as shown in the bottom row of Figure 3.
According to "Basic Terminology of Stereochemistry" of IUPAC Recommendations 1996 [15], a bond from an atom in the plane of drawing to an atom above the plane (i.e., so-called b-bond) is shown with a bold wedge, which starts from the atom in the plane at the narrow end of the wedge; and a bond below the plane (i.e., so-called a-bond) is shown with a hashed bold dash (short parallel lines). Hence, the combination of wedges and hashed dashes is selected as a default setting for XyMTeX2PS.
\long\gdef\Put@@@Line(#1,#2)(#3,#4)#5{%
\begingroup
%%x-coordinate
\@tempcntXa=0\relax
\ifnum#3>0\relax \@tempcntXa=#5\relax
\else\ifnum#3<0\relax\@tempcntXa=-#5%
\relax\fi\fi
\advance\@tempcntXa by#1\relax
%%y-coordinate
\@tempcntYa=#5\relax
\ifnum#3=0\relax\else
\multiply\@tempcntYa by#4\relax
\multiply\@tempcntYa by10\relax
\divide\@tempcntYa by#3\relax
\divide\@tempcntYa by10\relax\fi
\ifnum\@tempcntYa<0\relax
\ifnum#4>0\relax
\@tempcntYa=-\@tempcntYa\fi
\else
\ifnum\@tempcntYa>0\relax
\ifnum#4<0\relax
\@tempcntYa=-\@tempcntYa\fi\fi
\fi
\advance\@tempcntYa by#2\relax
\if@thicklinesw
\if@wedgesw
\ifmolfront%bold dash bond for skeletal
%bond for pyranose etc.
\psline[linewidth=\thickLineWidth]%
(#1,#2)(\the\@tempcntXa,%
\the\@tempcntYa)%
\else
\if@skbondlist%bold dash bond skeletal
%bond for general cases
\psline[linewidth=\thickLineWidth]%
(#1,#2)(\the\@tempcntXa,%
\the\@tempcntYa)%
\else%wedged bond
\stereo@wedgedimension(#3,#4){10}%
\pspolygon*(#1,#2)%
(\the\@tempcntXb,\the\@tempcntYb)%
(\the\@tempcntXc,\the\@tempcntYc)\fi\fi
\else
\psline[linewidth=\thickLineWidth]%
(#1,#2)(\the\@tempcntXa,%
\the\@tempcntYa)%
\fi
\else
\psline[linewidth=\thinLineWidth]%
(#1,#2)(\the\@tempcntXa,%
\the\@tempcntYa)%
\fi
\@tempcntXa=0\relax \@tempcntYa=0\relax
\endgroup}%end of Put@@@Line
According to this definition, bold dash bonds in a cyclic skeleton (e.g., front bonds of \furanose) are drawn by using the command \psline of PSTrick, while wedged bonds for stereochemistry are drawn as long triangles by using the command \pspolygon of PSTrick. As illustrated in Figure 3, the commands \wedgehashedwedge and \wedgehasheddash set a switching flag \@wedgeswtrue. Thereby, the condition commands \if@wedgesw, \else, and \fi (used in the \Put@@@Line command) divide cases to draw a bold dash bond or a wedged bond. \let\substfont=\normalfont \let\substfontsize=\normalsizeAccording to this specification, the font and its size can be changed by substituting \substfont and \substfontsize as follows:
\purinev{4==OH}
{\let\substfont=\bfseries
\let\substfontsize=\footnotesize
\purinev{4==OH}}
{\let\substfont=\sffamily
\purinev{4==OH}}
\changeunitlength{0.09pt}
\steroidchain[e]{3Su==HO;3Sd==H;8A==H;
9A==H;{{10}B}==\lmoiety{H$_{3}$C};%
{{13}B}==\lmoiety{H$_{3}$C};{{14}B}==H;%
{{17}GA}==H;{{20}SB}==%
\lmoiety{H$_{3}$C};{{20}SA}==H}
where the \lmoiety command is used to change the direction for printing out the methyl substituent. Thereby, we can obtain the following diagram:
\fbox{%
\begin{XyMcompd}
(800,750)(50,0){cpd:1}{a}
\decaheterov{9==N}{4D==O;7B==HO;%
{{10}A}==H;5==Ar}
\end{XyMcompd}
}
\fbox{%
\begin{XyMcompd}
(900,750)(-100,0){cpd:2}{b}
\furanose{1Sa==OH;1Sb==H;2Sb==H;%
2Sa==OH;3Sb==H;3Sa==OH;4Sa==H;%
4Sb==H$_{2}$O$_{3}$POC\rlap{H$_{2}$}}
\end{XyMcompd}
}
draw a fused heterocycle and a-D-ribofuranose-5-phoshporic acid as follows:
\furanose{1Sa==H;2Sb==H;2Sa==OH;3Sb==H;%
3Sa==OH;4Sa==H;4Sb==HOC\rlap{H$_{2}$};%
1Sb==\fiveheterov[bd]{1==N;2==N;4==N}
{1==(yl);3==CONH$_{2}$}}

\changeunitlength{0.09pt}
%\fbox{%
\wedgehashedwedge
\begin{XyMcompd}%
(2100,1800)(200,0){}{}
\let\substfontsize=\small
\pyranose{1Sa==H;2Sb==H;2Sa==OH;%
3Sb==H;3Sa==OH;4Sb==HO;%
4Sa==H;5Sb==H;5Sa==CH$_{3}$;%
1Sb==\ryl(8==O){3==%
\steroid{3==(yl);5A==H;8B==H;9A==H;%
{{10}B}==\lmoiety{OHC};{{14}A}==OH;%
{{13}B}==\lmoiety{H$_{3}$C};%
{{16}B}==OH;%
{{17}B}==\fiveheterov[e]{3==O}%
{4D==O;1==(yl)}}}}
\end{XyMcompd}
%}
The substituent is attached to a steroid skeleton by declaring in the command \steroid. The resulting steroid skeleton is further converted into a substituent by declaring a (yl) function in the command \steroid. The steroidal substituent is attached to a pyranose skeleton. Thereby, the nested code typesets the following formula:
\changeunitlength{0.06pt}
\begin{XyMcompd}%
(3800,1500)(-100,-700){}{}
\tetrahedral{0==C;1==CH$_{3}$;%
2==CH$_{3}$;3==CH$_{3}$;%
4==\tetrahedral{0==CO;2==(yl);%
4==\tetrahedral{0==CH;2==(yl);%
3==\fiveheterovi{1==N;3==N}{1==(yl);%
2D==O;5D==O;4==C$_{2}$H$_{5}$O;%
3==\ryl(3==CH$_{2}$){%
4==\bzdrh{1==(yl)}}};%
4==\tetrahedral{0==CONH;2==(yl);%
4==\bzdrh{1==(yl);2==Cl;%
5==\tetrahedral{0==NHCO;2==(yl);%
4==\tetrahedral{0==CH;2==(yl);%
3==C$_{2}$H$_{5}$;%
4==\ryl(4==O){4==\bzdrh{1==(yl);%
2==C$_{5}$H$_{11}$-$t$;%
4==C$_{5}$H$_{11}$-$t$}%
}}<,,,50>}<,,,50>}}}<,,250,>}}%
\end{XyMcompd}%
in which nine (yl) functions are declared, typesets the following structure:
\changeunitlength{0.09pt}
\wedgehashedwedge
\nonaheterovi[di]{%
5s==\cyclopropanev{2==(yl)}}%
{2SB==CH$_{3}$;2SA==CH$_{2}$OH;%
3B==OH;4==CH$_{3}$;6SB==CH$_{3}$;%
6SA==HO;7D==O}

\changeunitlength{0.09pt}
\wedgehashedwedge
\begin{XyMcompd}%
(2100,600)(-800,100){}{}
\fourhetero[%
{b\fivefusevi{1==S;4==\null}%
{2Sa==CH$_{3}$;2Sb==CH$_{3}$;%
3A==COOH}{d}}]%
{2==N}{1D==O;3FA==H;4GA==H;4Su==%
\lyl(4==OCH$_{2}$CONH)%
{4==\bzdrh{4==(yl)}}}
\end{XyMcompd}

\begin{center}
\changeunitlength{0.09pt}
\begin{XyMcompd}(500,700)(0,-200){}{}
\tetrahedral{0==C;3A==\bzdrv{1==(yl)};%
4B==OH;2B==H;1A==CH$_{3}$}
\end{XyMcompd}\qquad
\begin{XyMcompd}(500,700)(0,-200){}{}
\utetrahedralS{0==C;1==\bzdrv{1==(yl)};%
3A==H;4B==HO;2==CH$_{3}$}
\end{XyMcompd}\qquad
\begin{XyMcompd}(500,700)(50,-200){}{}
\UtetrahedralS{0==C;1==\bzdrv{1==(yl)};%
3A==OH;4B==H;2==CH$_{3}$}
\end{XyMcompd}
\end{center}

\begin{center}
\changeunitlength{0.08pt}
\begin{XyMcompd}(600,1000)(0,-500){}{}
\tetrahedral{0==C;1==CHO;%
2==H;4==OH;3==%
\tetrahedral{0==C;1==(yl);%
2==HO;4==H;3==%
\tetrahedral{0==C;1==(yl);%
2==H;4==OH;3==%
\tetrahedral{0==C;1==(yl);%
2==H;4==OH;3==CH$_{2}$OH}}}}
\end{XyMcompd}
\qquad
\begin{XyMcompd}(600,1000)(0,-500){}{}
\tetrahedral{0==C;1A==CHO;%
2B==H;4B==OH;3A==%
\tetrahedral{0==C;1==(yl);%
2B==HO;4B==H;3A==%
\tetrahedral{0==C;1==(yl);%
2B==H;4B==OH;3A==%
\tetrahedral{0==C;1==(yl);%
2B==H;4B==OH;3A==CH$_{2}$OH}}}}
\end{XyMcompd}
\end{center}
typeset the Fischer projection of \textsc{d}-glucose and its wedge-form representation as follows: 
\ltetrahedralS{0==C;1==\rtetrahedralS{%
1==(yl);0==C;2==CH$_{3}$;3A==Br;4B==H};%
2==CH$_{3}$;3A==Br;4B==H}
\qquad
\ltetrahedralS{0==C;1==\RtetrahedralS{%
1==(yl);0==C;2==CH$_{3}$;3A==H;4B==Br};%
2==CH$_{3}$;3A==Br;4B==H}
which generate the following formulas:
{\let\substfontsize=\small
\begin{chemeqnarray}
HO^{-} & + &
\raisebox{-28pt}{%
\ltetrahedralS{0==C;1==Cl;%
2==C$_{3}$H$_{7}$;%
3A==CH$_{3}$;4B==C$_{2}$H$_{5}$}}
\reactrarrow{0pt}{1cm}{}{} \qquad
\raisebox{-28pt}{%
\dtrigpyramid[{0{~~$\delta+$}}]%
{0==C;4A==HO$^{\delta-}$;%
5A==Cl$^{\delta-}$;%
1==C$_{3}$H$_{7}$;%
2A==CH$_{3}$;%
3B==C$_{2}$H$_{5}$}} \nonumber \\
&& \qquad\reactrarrow{0pt}{1cm}{}{}
\qquad
\raisebox{-28pt}{%
\rtetrahedralS{0==C;1==HO;%
2==C$_{3}$H$_{7}$;%
3A==CH$_{3}$;4B==C$_{2}$H$_{5}$}}
+ Cl^{-}
\label{eq:1}
\end{chemeqnarray}
}

\makeatletter
\def\myfuranose{\@ifnextchar[%
{\@myfuranose}{\@myfuranose[]}}
\def\@myfuranose[#1]#2{%
\fivesugarh[#1]{5==O;%
1s==\WedgeAsSubst(0,0)(-3,-5){120};%
4s==\WedgeAsSubst(0,0)(3,-5){120};%
3s==\psline[linewidth=2.8pt,%
linestyle=solid,linecolor=black]%
(-17,0)(307,0)}{#2}[abc]}
\makeatother
Thereby, the formula of ribavirin can be typeset by writing a more simplified code:
\myfuranose{1Sa==H;2Sb==H;2Sa==OH;%
3Sb==H;3Sa==OH;4Sa==H;%
4Sb==HOC\rlap{H$_{2}$};
1Sb==\fiveheterov[bd]{1==N;2==N;4==N}%
{1==(yl);3==CONH$_{2}$}}

\begin{center}
\changeunitlength{0.05pt}
\begin{XyMcompd}%
(4000,1600)(-200,-100){}{}
\bzdrv{1==OH;5==C$_{16}$H$_{33}$O;%
4==\tetrahedral{1==(yl);0==C;%
4==CH$_{3}$;2==CH$_{3}$;3==CH$_{3}$};%
2==\ryl(5==NHSO$_{2}$){%
4==\bzdrh{1==(yl);%
2==OCH$_{2}$CH$_{2}$OCH$_{3}$;
5==\ryl(3==NHSO$_{2}$){%
4==\bzdrh{1==(yl);
3==\ryl(5==SO$_{2}$N\rlap{H}){%
0==\naphdrv{5==(yl);1==OH;%
4==\ryl(0==N\dbond N){%
4==\bzdrh{1==(yl);2==SO$_{2}$CH$_{3}$;%
4==NO$_{2}$}}}}}}}}}
\end{XyMcompd} \\
\end{center}

This work was supported in part by the Japan Society for the Promotion of Science: Grant-in-Aid for Scientific Research B(2) (No. 14380178, 2002-2004).