% \iffalse meta-comment
%% File: polymers.dtx
%
%  Copyright 1996, 1998, 2001, 2002, 2004. 2010 by Shinsaku Fujita
%
%  This file is part of XyMTeX system.
%  -------------------------------------
%
% This file is a part of the macro package ``XyMTeX'' which has been 
% designed for typesetting chemical structural formulas.
%
% This file is to be contained in the ``xymtex'' directory which is 
% an input directory for TeX. It is a LaTeX optional style file and 
% should be used only within LaTeX, because several macros of the file 
% are based on LaTeX commands. 
%
% For the review of XyMTeX, see
%  (1)  Shinsaku Fujita, ``Typesetting structural formulas with the text
%    formatter TeX/LaTeX'', Computers and Chemistry, in press.    
% The following book deals with an application of TeX/LaTeX to 
% preparation of manuscripts of chemical fields:
%  (2)  Shinsaku Fujita, ``LaTeX for Chemists and Biochemists'' 
%    Tokyo Kagaku Dozin, Tokyo (1993) [in Japanese].  
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'. 
% The Current Maintainer of this work is Shinsaku Fujita.
%
% This work consists of the files polymers.dtx and polymers.ins
% and the derived file polymers.sty.
%
% Please report any bugs, comments, suggestions, etc. to:
%   Shinsaku Fujita, 
%   Shonan Institute of Chemoinformatics and Mathematical Chemistry
%   Kaneko 479-7 Ooimachi, Ashigara-Kami-Gun, Kanagawa 250-0019 Japan
%  (old address)
%   Ashigara Research Laboratories, Fuji Photo Film Co., Ltd., 
%   Minami-Ashigara, Kanagawa-ken, 250-01, Japan.
%  (old address)
%   Department of Chemistry and Materials Technology, 
%   Kyoto Institute of Technology, \\
%   Matsugasaki, Sakyoku, Kyoto, 606 Japan
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{August 16, 1996}
% \def\versi@nno{ver1.00}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{October 31, 1998}
% \def\versi@nno{ver1.02}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{December 25, 1998}
% \def\versi@nno{ver2.00}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{June 20, 2001}
% \def\versi@nno{ver2.01}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{April 30, 2002}
% \def\versi@nno{ver3.00}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{May 30, 2002}
% \def\versi@nno{ver4.00}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \def\j@urnalname{polymers}
% \def\versi@ndate{August 30, 2004}
% \def\versi@nno{ver4.01}
% \def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \fi
%
% \CheckSum{480}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \setcounter{StandardModuleDepth}{1}
%
% \StopEventually{}
% \MakeShortVerb{\|}
%
% \iffalse
% \changes{v1.00}{1996/07/07}{first edition for LaTeX2e}
% \changes{v1.02}{1998/10/31}{revised edition for LaTeX2e}
% \changes{v2.00}{1998/12/25}{enhanced edition for LaTeX2e}
% \changes{v2.01}{2001/06/20}{Size reduction and Clip information}
% \changes{v3.00}{2002/04/30}{sfpicture environment, etc.}
% \changes{v4.00}{2002/05/30}{PostScript output and ShiftPicEnv}
% \changes{v4.01}{2004/08/30}{Minor additions}
% \changes{v5.00}{2010/10/01}{for bond coloring and the LaTeX Project Public License}
% \fi
%
% \iffalse
%<*driver>
\NeedsTeXFormat{pLaTeX2e}
% \fi
\ProvidesFile{polymers.dtx}[2010/10/01 v5.00 XyMTeX{} package file]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{polymers.dtx}
%
% %%XyMTeX Logo: Definition 2%%%
\def\UPSILON{\char'7}
\def\XyM{X\kern-.30em\smash{%
\raise.50ex\hbox{\UPSILON}}\kern-.30em{M}}
\def\XyMTeX{\XyM\kern-.1em\TeX}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Polymers by {\sffamily polymers.sty} 
(\fileversion) of \XyMTeX{}}
\author{Shinsaku Fujita \\ 
Shonan Institute of Chemoinformatics and Mathematical Chemistry, \\
Kaneko 479-7 Ooimachi, Ashigara-Kami-Gun, Kanagawa 250-0019 Japan
% % (old address)
% %Department of Chemistry and Materials Technology, \\
% %Kyoto Institute of Technology, \\
% %Matsugasaki, Sakyoku, Kyoto, 606-8585 Japan
% %% (old address)
% %% Ashigara Research Laboratories, 
% %% Fuji Photo Film Co., Ltd., \\ 
% %% Minami-Ashigara, Kanagawa, 250-01 Japan
}
\date{\filedate}
%
\begin{document}
   \maketitle
   \DocInput{polymers.dtx}
\end{document}
%</driver>
% \fi
%
% \section{Introduction}\label{polymers:intro}
%
% \subsection{Options for {\sffamily docstrip}}
%
% \DeleteShortVerb{\|}
% \begin{center}
% \begin{tabular}{|l|l|}
% \hline
% \emph{option} & \emph{function}\\ \hline
% polymers & polymers.sty \\
% driver & driver for this dtx file \\
% \hline
% \end{tabular}
% \end{center}
% \MakeShortVerb{\|}
%
% \subsection{Version Information}
%
%    \begin{macrocode}
%<*polymers>
\typeout{XyMTeX for Drawing Chemical Structural Formulas. Version 5.00}
\typeout{       -- Released October 01, 2010 by Shinsaku Fujita}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\j@urnalname{polymers}
\def\versi@ndate{October 01, 2010}
\def\versi@nno{ver5.00}
\def\copyrighth@lder{SF} % Shinsaku Fujita
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\typeout{XyMTeX Macro File `\j@urnalname' (\versi@nno) <\versi@ndate>%
\space[\copyrighth@lder]}
%    \end{macrocode}
%
% \section{List of commands for polymers.sty}
%
% \begin{verbatim}
% **********************************
% * polymers.sty: list of commands * 
% **********************************
%
%  <Delimeters for polymer units>
%
%    \leftPMdelim      \rightPMdelim 
%    \leftpmdelim      \rightpmdelim
%
%   \leftPolymer       \leftpolymer
%   \rightPolymer      \rightpolymer
%
%   \leftsqrPolymer    \leftSqrpolymer
%   \lsqrdelimiter     \leftsqrpolymer
%
%   \rightsqrPolymer   \rightSqrpolymer
%   \rsqrdelimiter     \rightsqrpolymer
%
%   \@sqrpolymer
%   \sqrpolymer        \Sqrpolymer
%   \mpolymer
%
%  <Bonds for polymers>
%
%   \WestPbond         \EastPbond
%   \sbond
%
%  <Polymers>
%
%   \polyethylene      \@polyethylene
%   \polystyrene       \@polystyrene
%
% \end{verbatim}
%
% \section{Input of basic macros}
%
% To assure the compatibility to \LaTeX{}2.09 (the native mode), 
% the commands added by \LaTeXe{} have not been used in the resulting sty 
% files ({\sf polymers.sty} for the present case).  Hence, the combination 
% of |\input| and |\@ifundefined| is used to crossload sty 
% files ({\sf chemstr.sty} etc. for the present case) in place of the 
% |\RequirePackage| command of \LaTeXe{}. 
%
%    \begin{macrocode}
% *************************
% * input of basic macros *
% *************************
\@ifundefined{setsixringv}{\input chemstr.sty\relax}{}
\@ifundefined{Westbond}{\input aliphat.sty\relax}{}
\@ifundefined{bzdrv}{\input carom.sty\relax}{}
\unitlength=0.1pt
%    \end{macrocode}
%
%    \begin{macrocode}
% ****************************************************
% * For separating an augument list to each argument *
% ****************************************************
%
\def\@forsemicol#1:=#2\do#3{%
%% \edef\@fortmp{#2}\ifx\@fortmp\@empty%
  \expandafter\def\expandafter\@fortmp\expandafter{#2}%
  \ifx\@fortmp\@empty%
    \else%
    \expandafter\@forl@@p#2;\@nil;\@nil\@@#1{#3}\fi}
%    \end{macrocode}
%
% \section{Delimeters for polymer units}
%
% \subsection{Right and left delimeters}
%
% A polymer structure has a unit surrounded by 
% parentheses or other delimeters. For drawing a 
% parenthesis as the part of a substituent, 
% the following commands are prepared. 
% 
% \subsubsection{Parentheses}
%
% \begin{macro}{\leftPMdelim}
% \begin{macro}{\leftpmdelim}
%    \begin{macrocode}
% ********************************
% * Delimeters for polymer units *
% ********************************
\def\leftPMdelim#1{$\mathstrut #1$}
\def\leftpmdelim{\leftPMdelim{\biggm(}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rightPMdelim}
% \begin{macro}{\rightpmdelim}
%    \begin{macrocode}
\def\rightPMdelim#1#2{%
 $\mathstrut #1_{\mkern-5mu #2}$}
\def\rightpmdelim#1{\rightPMdelim{\biggm)}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The command |\leftpolymer| typesets the left parenthesis of 
% a polymer unit. 
% The command |\leftPolymer| is the inner commend of |\leftpolymer|, 
% where a delimeter can be selected as an argument. 
%
% \begin{macro}{\leftPolymer}
% \begin{macro}{\leftpolymer}
%    \begin{macrocode}
\def\leftPolymer#1#2{%
\begin{sfpicture}(0,0)(0,0)
\putlatom{0}{0}{#2}
\putlatom{120}{0}{$#1$}
\end{sfpicture}}
\def\leftpolymer#1{\leftPolymer{\biggm(}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The command |\rightpolymer| typesets the left parenthesis of 
% a polymer unit along with a repeating number as a subscript. 
% The command |\rightPolymer| is the inner commend of |\rightpolymer|, 
% where a delimeter can be selected as an argument. 
%
% \begin{macro}{\Rightpolymer}
% \begin{macro}{\rightpolymer}
%    \begin{macrocode}
\def\rightPolymer#1#2#3{%
\begin{sfpicture}(0,0)(0,0)
\putratom{0}{0}{#2}
\putratom{-150}{0}{%
% $\mathstrut#1_{\mkern-3mu \mbox{\scriptsize\rm #3}}$}
 $\mathstrut#1_{\mkern-2mu #3}$}
\end{sfpicture}}
\def\rightpolymer#1#2{\rightPolymer{\biggm)}{#1}{#2}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Brackets}
%
% The command |\leftSqrpolymer| typesets the left bracket of 
% a polymer unit. 
% The command |\leftsqrPolymer| is the inner commend of |\leftSqrpolymer|, 
% where a delimeter can be selected as an argument. 
% The bracket selected by the command |\leftSqrpolymer| is 
% a \TeX{} big mathematical symbol, 
% the line of which is 
% boldfaced. 
%
% \begin{macro}{\leftsqrPolymer}
% \begin{macro}{\leftSqrpolymer}
%    \begin{macrocode}
\def\leftsqrPolymer#1#2{%
\begin{sfpicture}(0,0)(0,0)
\putlatom{0}{0}{#2}
\putlatom{120}{0}{$#1$}
\end{sfpicture}}
\def\leftSqrpolymer#1{\leftsqrPolymer{\Biggm[}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The command |\rightSqrpolymer| typesets the right bracket of 
% a polymer unit. 
% The command |\rightsqrPolymer| is the inner commend of |\rightSqrpolymer|, 
% where a delimeter can be selected as an argument. 
% The bracket selected by the command |\rightSqrpolymer| is 
% a \TeX{} big mathematical symbol, 
% the line of which is boldfaced. 
%
% \begin{macro}{\rightsqrPolymer}
% \begin{macro}{\rightSqrpolymer}
%    \begin{macrocode}
\def\rightsqrPolymer#1#2#3{%
\begin{sfpicture}(0,0)(0,0)
\putratom{0}{0}{#2}
\putratom{-150}{0}{%
% $\mathstrut #1_{\mbox{\scriptsize\rm #3}}$}
 $\mathstrut #1_{#3}$}
\end{sfpicture}}
\def\rightSqrpolymer#1#2{\rightsqrPolymer{\Biggm]}{#1}{#2}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% For drawing polymer brackets of thin line width, 
% we prepare the command |\lsqrdelimiter|.  The height of 
% the bracket can be designated by the argument of this 
% command.  The command 
% is used to define the command |\leftsqrpolymer|. 
% This command typesets a left bracket of thin line width. 
%
% \begin{macro}{\lsqrdelimiter}
% \begin{macro}{\leftsqrpolymer}
%    \begin{macrocode}
\def\lsqrdelimiter#1{%
\hbox{\vrule \@width\fboxrule
$\vcenter to#1{%
\hrule \@height\fboxrule \@width\fboxsep
\vfill
\hrule \@height\fboxrule \@width\fboxsep}$}}
\def\leftsqrpolymer#1{%
 \leftsqrPolymer{\lsqrdelimiter{300\unitlength}}{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The command |\rsqrdelimiter| is 
% used to define the command |\rightsqrpolymer|, which 
% typesets a right bracket of thin line width. 
%
% \begin{macro}{\rsqrdelimiter}
% \begin{macro}{\rightsqrpolymer}
%    \begin{macrocode}
\def\rsqrdelimiter#1{%
\hbox{$\vcenter to#1{%
\hrule \@height\fboxrule \@width\fboxsep \vfill
\hrule \@height\fboxrule \@width\fboxsep}$\kern-\fboxrule
\vrule \@width\fboxrule\kern2pt}}
\def\rightsqrpolymer#1#2{%
\rightsqrPolymer{\rsqrdelimiter{300\unitlength}}{#1}{#2}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Pairs of delimeters}
%
% The command |\sqrpolymer| typesets a pair of thin-line brackets that 
% surrounds a polymer unit after measuring the height of 
% the unit. On the other hand, 
% the command |\Sqrpolymer| typesets a pair of thick-line brackets. 
% Both of the commands are based on the inner macro |\@sqrpolymer|, 
% in which a line width is designated by means of an argument. 
%
% \begin{macro}{\@sqrpolymer}
% \begin{macro}{\sqrpolymer}
% \begin{macro}{\Sqrpolymer}
%    \begin{macrocode}
\long\def\@sqrpolymer#1#2#3{%
\begingroup \fboxrule=#1
 \leavevmode\setbox\@tempboxa\hbox{#2}\@tempdima\fboxrule
    \advance\@tempdima \fboxsep \advance\@tempdima \dp\@tempboxa
 \@tempdimb=\wd\@tempboxa
 \advance\@tempdimb by \fboxsep
 \advance\@tempdimb by \fboxsep
 \advance\@tempdimb by \fboxrule
 \advance\@tempdimb by \fboxrule
   \hbox{\lower \@tempdima\hbox
  {\vbox{
  \hbox to\@tempdimb{%
  \vrule \@height \fboxrule \@width\fboxsep\hfill
  \vrule \@height \fboxrule \@width\fboxsep}
  \nointerlineskip
          \hbox{\vrule \@width \fboxrule \hskip\fboxsep
          \vbox{\vskip\fboxsep \copy\@tempboxa\vskip\fboxsep}\hskip 
                 \fboxsep\vrule \@width \fboxrule}
  \nointerlineskip
  \hbox to\@tempdimb{%
  \vrule \@height \fboxrule \@width\fboxsep\hfill
  \vrule \@height \fboxrule \@width\fboxsep}}}}%
\kern2pt\lower\@tempdima\hbox{\scriptsize$#3$}\endgroup}
\long\def\sqrpolymer#1#2{\@sqrpolymer{0.4pt}{#1}{#2}}
\long\def\Sqrpolymer#1#2{\@sqrpolymer{1pt}{#1}{#2}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The command |\mpolymer| typesets a pair of parentheses that 
% surrounds a polymer unit after measuring the height of 
% the unit. 
%
% \begin{macro}{\mpolymer}
%    \begin{macrocode}
\long\def\mpolymer#1#2{%
 \leavevmode\setbox\@tempboxa\hbox{#1}\@tempdima\fboxrule
  \advance\@tempdima \fboxsep \advance\@tempdima \dp\@tempboxa
  \hbox{\lower \@tempdima\hbox{\vbox{\hbox{\hskip\fboxsep%
  $\left(\vcenter{\vskip\fboxsep \copy\@tempboxa\vskip\fboxsep}%
  \right)_{#2}$}}}}}
%    \end{macrocode}
% \end{macro}
%
% \section{Commands for drawing polymers}
%
% \subsection{Bonds for polymers}
% 
% The original commands 
% |\Westbond| and |\Eastbond| are changed into 
% |\WestPbond| and |\EastPbond|, where each bond is lengthened 
% for making a space for drawing delimiters.  
%
% \begin{macro}{\WestPbond}
% \begin{macro}{\EastPbond}
% \begin{macro}{\sbond}
%    \begin{macrocode}
% **********************
% * Bonds for polymers *
% **********************
\def\WestPbond{%
\begin{sfpicture}(100,100)(0,0)%
\Put@Direct(-100,0){\Westbond}%
\Put@Line(-60,0)(-1,0){90}%
\end{sfpicture}}%
\def\EastPbond{%
\begin{sfpicture}(100,100)(0,0)%
\Put@Direct(100,0){\Eastbond}%
\Put@Line(60,0)(1,0){90}%
\end{sfpicture}}%
\def\sbond{%
\begin{sfpicture}(160,0)(0,0)%
\Put@Line(0,33)(1,0){160}%
\end{sfpicture}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Polyethylene unit}
%
% The command |\polyethylene| is used to draw polyethylene derivatives, 
% in which each substituent is designated by the |SUBSLIST|. 
% The following numbering is used in this macro. 
%
% \begin{verbatim}
% ********************
% * polyethylene unit*
% ********************
%
% The following numbering is adopted in this macro. 
%
%            |   1      6   |
%            |              |
%            |   |      |   |
%        2 ---- (1) -- (2) ---- 5
%            |   |  (0) |   |
%            |              |
%            |   3      4   |0
% \end{verbatim}
%
% The command |\polyethylene| has arguments, 
% |CALIST| and |SUBSLIST|, as well as an optional argument |AUXLIST|. 
% \begin{verbatim}
%   \polyethylene[AUXLIST]{CALIST}{SUBSLIST}
% \end{verbatim}
%
% The optional argument |AUXLIST| is used for 
% typesetting auxiliary symbols on central atoms. 
% \begin{verbatim}
%     AUXLIST = 
%
%       {n+}  :  + charge (or another one chararacter) on the center
% \end{verbatim}
%
% The argument |CALIST| is used for indicating center atoms. 
% \begin{verbatim}
%     CALIST:  central atom list
%
%       for 1  :  cetral atom (e.g. 1==C)
%           2  :  cetral atom (e.g. 2==C)
%           0  :  cetral bond (e.g. 0D==)
% \end{verbatim}
%
% The argument |SUBSLIST| is used for indicating  substituents. 
% \begin{verbatim}
%     SUBSLIST: list of substituents
%
%       for n = 1 to 4 
%
%           nT         :  triple bond at n-atom 
%           nD         :  double bond at n-atom 
%           n or nS    :  single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
% \end{verbatim}
%
% \begin{macro}{\if@centbondsw}
% \begin{macro}{\if@centatswi}
% \begin{macro}{\if@centatswii}
%    \begin{macrocode}
\newif\if@centbondsw \@centbondswfalse
\newif\if@centatswi \@centatswifalse
\newif\if@centatswii \@centatswiifalse
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{v5.00}{2010/10/01}{for bond coloring}
% \begin{macro}{\polyethylene}
% \begin{macro}{\@polyethylene}
%    \begin{macrocode}
\def\polyethylene{\@ifnextchar[{\@polyethylene}{\@polyethylene[]}}
\def\@polyethylene[#1]#2#3{%
 \begin{sfpicture}(1100,600)(-400,-300)%
  \OrigptOutput(400,300){polyethylene}%
%    \end{macrocode}
%
%    \begin{macrocode}
% ************
% * aux list *
% ************
\def\@@@temp{#1}%
\ifx\@@@temp\empty\else
\@tfor\member:=#1\do{%
   \expandafter\twoch@@r\member{}{}%
   \ifcase\@@tmpa%
    \or\relax\putratom{47}{50}{\scriptsize\@@tmpb}%
    \or\relax\putratom{347}{50}{\scriptsize\@@tmpb}%
\fi}\fi%
%    \end{macrocode}
%
%    \begin{macrocode}
% *****************
% * central atoms *
% *****************
\@forsemicol\member:=#2\do{%
\ifx\member\empty\else%
\expandafter\@m@mb@r\member;\relax%
   \expandafter\threech@r\@membera{}{}%
   \ifcase\@tmpa \global\@centbondswtrue\Put@Direct(20,0){\Eastbond}%
   \or\global\@centatswitrue\putlratom{-40}{-33}{\@memberb}%
   \or\global\@centatswiitrue\putlratom{260}{-33}{\@memberb}%
\fi\fi}%
\if@centatswi \else\putlratom{-40}{-33}{C}\fi%
\if@centatswii \else\putlratom{260}{-33}{C}\fi%
\if@centbondsw \else\Put@Line(70,0)(1,0){160}\fi%
\global\@centbondswfalse%
\global\@centatswifalse%
\global\@centatswiifalse%
%    \end{macrocode}
%
%    \begin{macrocode}
% ****************
% * Substituents *
% ****************
\gdef\numrepeated{x}%
\@forsemicol\member:=#3\do{%
\ifx\member\empty\else%
\expandafter\@m@mb@r\member;\relax%
\expandafter\threech@r\@membera{}{}%
\ifcase\@tmpa \gdef\numrepeated{\@memberb}%
\or\setBScolor{\Put@Direct(0,0){\Northbond}}%
\or\setBScolor{\Put@Direct(0,0){\WestPbond}}%
\or\setBScolor{\Put@Direct(0,0){\Southbond}}%
\or\setBScolor{\Put@Direct(300,0){\Southbond}}%
\or\setBScolor{\Put@Direct(300,0){\EastPbond}}%
\or\setBScolor{\Put@Direct(300,0){\Northbond}}%
\fi\fi}%end of ifcase
%    \end{macrocode}
%
%    \begin{macrocode}
% **************
% * Delimeters *
% **************
\Put@Direct(-200,-33){\leftpmdelim}%
\Put@Direct(400,-33){\rightpmdelim{\numrepeated}}%
\end{sfpicture}}%end of macro polyethylene
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Polyestyrene unit}
%
% The command |\polyestrene| is used to draw polystyrene derivatives, 
% in which substituents on both the polymer chain and the phenyl group 
% are designated by the |SUBSLIST| and |PHSUBSLIST|, respectively. 
% The following numbering is adopted in this macro. 
% \begin{verbatim}
% ********************
% * polystyrene unit *
% ********************
%
%            |   1      6   |
%            |              |
%            |   |      |   |
%        2 ---- (1) -- (2) ---- 5
%            |   |  (0) |   |
%            |          |   |
%            |   3      |   |0
%                      / `
%                   6 |    | 2
%                     |    |
%                   5 `   / 3
%                       `
%                        4
% \end{verbatim}
%
% The command |\polyethylene| has arguments, 
% |CALIST|, |SUBSLIST| and |PHSUBSLIST|, 
% as well as an optional argument |AUXLIST|. 
% \begin{verbatim}
%   \polystyrene[AUXLIST]{CALIST}{SUBSLIST}{PHSUBSLIST}
% \end{verbatim}
%
% The optional argument |AUXLIST| is used for 
% typesetting auxiliary symbols on central atoms. 
% \begin{verbatim}
%     AUXLIST = 
%
%       {n+}  :  + charge (or another one chararacter) on the center
% \end{verbatim}
%
% The argument |CALIST| is used for indicating center atoms. 
% \begin{verbatim}
%     CALIST:  central atom list
%
%       for 1  :  cetral atom (e.g. 1==C)
%           2  :  cetral atom (e.g. 2==C)
%           0  :  cetral bond (e.g. 0D==)
% \end{verbatim}
%
% The argument |SUBSLIST| is used for indicating  substituents on 
% the polymer chain. 
% \begin{verbatim}
%     SUBSLIST: list of substituents
%
%       for n = 1 to 4 
%
%           nT         :  triple bond at n-atom 
%           nD         :  double bond at n-atom 
%           n or nS    :  single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
% \end{verbatim}
%
% The argument |PHSUBSLIST| is used for indicating  substituents on 
% the phenyl group. 
% \begin{verbatim}
%     PHSUBSLIST: list of phenyl substituents
%
%       for n = 2 to 6
%
%           n or nS    :  single bond at n-atom
% \end{verbatim}
%
% \begin{macro}{\polyethylene}
% \begin{macro}{\@polyethylene}
%    \begin{macrocode}
\def\polystyrene{\@ifnextchar[{\@polystyrene}{\@polystyrene[]}}
\def\@polystyrene[#1]#2#3#4{%
\begin{sfpicture}(1100,1200)(0,-640)%
  \OrigptOutput(0,640){polystyrene}%
\begingroup \origptfalse
\Put@Direct(0,0){\polyethylene[#1]{#2}{#3}}%
\Put@Line(700,0)(0,1){240}%
\Put@Direct(300,-646){\bzdrv{#4}}%
\endgroup
\end{sfpicture}}%end of macro polystyrene
%</polymers>
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \Finale
%
\endinput
