Polymers by polymers.sty (v4.01) of XΥMTEX

Shinsaku Fujita Department of Chemistry and Materials Technology, Kyoto Institute of Technology, Matsugasaki, Sakyoku, Kyoto, 606-8585 Japan

2004/08/30

1 Introduction

1.1 Options for docstrip

option  function
polymers polymers.sty
driver  driver for this dtx file

1.2 Version Information

1 ⟨∗polymers⟩

2 \typeout{XyMTeX for Drawing Chemical Structural Formulas. Version 4.01}
3 \typeout{       -- Released August 30, 2004 by Shinsaku Fujita}
4 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 \def\j@urnalname{polymers}
6 \def\versi@ndate{August 30, 2004}
7 \def\versi@nno{ver4.01}
8 \def\copyrighth@lder{SF} % Shinsaku Fujita
9 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 \typeout{XyMTeX Macro File `\j@urnalname' (\versi@nno) <\versi@ndate>%
11 \space[\copyrighth@lder]}

2 List of commands for polymers.sty

**********************************
* 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

3 Input of basic macros

To assure the compatibility to L^{A}TEX2.09 (the native mode), the commands added by L^{A}TEX 2ε have not been used in the resulting sty files (polymers.sty for the present case). Hence, the combination of \input and \@ifundefined is used to crossload sty files (chemstr.sty etc. for the present case) in place of the \RequirePackage command of L^{A}TEX 2ε.

12 % *************************
13 % * input of basic macros *
14 % *************************
15 \@ifundefined{setsixringv}{\input chemstr.sty\relax}{}
16 \@ifundefined{Westbond}{\input aliphat.sty\relax}{}
17 \@ifundefined{bzdrv}{\input carom.sty\relax}{}
18 \unitlength=0.1pt
19 % ****************************************************
20 % * For separating an augument list to each argument *
21 % ****************************************************

22 %

23 \def\@forsemicol#1:=#2\do#3{%
24 %% \edef\@fortmp{#2}\ifx\@fortmp\@empty%
25 \expandafter\def\expandafter\@fortmp\expandafter{#2}%
26 \ifx\@fortmp\@empty%
27  \else%
28  \expandafter\@forl@@p#2;\@nil;\@nil\@@#1{#3}\fi}

4 Delimeters for polymer units

4.1 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.

4.1.1 Parentheses

\leftPMdelim
\leftpmdelim
29 % ********************************
30 % * Delimeters for polymer units *
31 % ********************************
32 \def\leftPMdelim#1{$\mathstrut #1$}
33 \def\leftpmdelim{\leftPMdelim{\biggm(}}
\rightPMdelim
\rightpmdelim
34 \def\rightPMdelim#1#2{%
35 $\mathstrut #1_{\mkern-5mu #2}$}
36 \def\rightpmdelim#1{\rightPMdelim{\biggm)}{#1}}

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.

\leftPolymer
\leftpolymer
37 \def\leftPolymer#1#2{%
38 \begin{sfpicture}(0,0)(0,0)
39 \putlatom{0}{0}{#2}
40 \putlatom{120}{0}{$#1$}
41 \end{sfpicture}}
42 \def\leftpolymer#1{\leftPolymer{\biggm(}{#1}}

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.

\Rightpolymer
\rightpolymer
43 \def\rightPolymer#1#2#3{%
44 \begin{sfpicture}(0,0)(0,0)
45 \putratom{0}{0}{#2}
46 \putratom{-150}{0}{%
47 % $\mathstrut#1_{\mkern-3mu \mbox{\scriptsize\rm #3}}$}
48 $\mathstrut#1_{\mkern-2mu #3}$}
49 \end{sfpicture}}
50 \def\rightpolymer#1#2{\rightPolymer{\biggm)}{#1}{#2}}

4.1.2 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.

\leftsqrPolymer
\leftSqrpolymer
51 \def\leftsqrPolymer#1#2{%
52 \begin{sfpicture}(0,0)(0,0)
53 \putlatom{0}{0}{#2}
54 \putlatom{120}{0}{$#1$}
55 \end{sfpicture}}
56 \def\leftSqrpolymer#1{\leftsqrPolymer{\Biggm[}{#1}}

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.

\rightsqrPolymer
\rightSqrpolymer
57 \def\rightsqrPolymer#1#2#3{%
58 \begin{sfpicture}(0,0)(0,0)
59 \putratom{0}{0}{#2}
60 \putratom{-150}{0}{%
61 % $\mathstrut #1_{\mbox{\scriptsize\rm #3}}$}
62 $\mathstrut #1_{#3}$}
63 \end{sfpicture}}
64 \def\rightSqrpolymer#1#2{\rightsqrPolymer{\Biggm]}{#1}{#2}}

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.

\lsqrdelimiter
\leftsqrpolymer
65 \def\lsqrdelimiter#1{%
66 \hbox{\vrule \@width\fboxrule
67 $\vcenter to#1{%
68 \hrule \@height\fboxrule \@width\fboxsep
69 \vfill
70 \hrule \@height\fboxrule \@width\fboxsep}$}}
71 \def\leftsqrpolymer#1{%
72 \leftsqrPolymer{\lsqrdelimiter{300\unitlength}}{#1}}

The command \rsqrdelimiter is used to define the command \rightsqrpolymer, which typesets a right bracket of thin line width.

\rsqrdelimiter
\rightsqrpolymer
73 \def\rsqrdelimiter#1{%
74 \hbox{$\vcenter to#1{%

75 \hrule \@height\fboxrule \@width\fboxsep \vfill
76 \hrule \@height\fboxrule \@width\fboxsep}$\kern-\fboxrule
77 \vrule \@width\fboxrule\kern2pt}}
78 \def\rightsqrpolymer#1#2{%
79 \rightsqrPolymer{\rsqrdelimiter{300\unitlength}}{#1}{#2}}

4.2 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.

\@sqrpolymer
\sqrpolymer
\Sqrpolymer

80 \long\def\@sqrpolymer#1#2#3{%
81 \begingroup \fboxrule=#1
82 \leavevmode\setbox\@tempboxa\hbox{#2}\@tempdima\fboxrule
83  \advance\@tempdima \fboxsep \advance\@tempdima \dp\@tempboxa
84 \@tempdimb=\wd\@tempboxa
85 \advance\@tempdimb by \fboxsep
86 \advance\@tempdimb by \fboxsep
87 \advance\@tempdimb by \fboxrule
88 \advance\@tempdimb by \fboxrule
89 \hbox{\lower \@tempdima\hbox
90 {\vbox{
91 \hbox to\@tempdimb{%
92 \vrule \@height \fboxrule \@width\fboxsep\hfill
93 \vrule \@height \fboxrule \@width\fboxsep}
94 \nointerlineskip
95  \hbox{\vrule \@width \fboxrule \hskip\fboxsep
96  \vbox{\vskip\fboxsep \copy\@tempboxa\vskip\fboxsep}\hskip
97  \fboxsep\vrule \@width \fboxrule}
98 \nointerlineskip
99 \hbox to\@tempdimb{%
100 \vrule \@height \fboxrule \@width\fboxsep\hfill
101 \vrule \@height \fboxrule \@width\fboxsep}}}}%
102 \kern2pt\lower\@tempdima\hbox{\scriptsize$#3$}\endgroup}
103 \long\def\sqrpolymer#1#2{\@sqrpolymer{0.4pt}{#1}{#2}}
104 \long\def\Sqrpolymer#1#2{\@sqrpolymer{1pt}{#1}{#2}}

The command \mpolymer typesets a pair of parentheses that surrounds a polymer unit after measuring the height of the unit.

\mpolymer
105 \long\def\mpolymer#1#2{%
106 \leavevmode\setbox\@tempboxa\hbox{#1}\@tempdima\fboxrule
107 \advance\@tempdima \fboxsep \advance\@tempdima \dp\@tempboxa
108 \hbox{\lower \@tempdima\hbox{\vbox{\hbox{\hskip\fboxsep%
109 $\left(\vcenter{\vskip\fboxsep \copy\@tempboxa\vskip\fboxsep}%
110 \right)_{#2}$}}}}}

5 Commands for drawing polymers

5.1 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.

\WestPbond \EastPbond \sbond
111 % **********************
112 % * Bonds for polymers *
113 % **********************
114 \def\WestPbond{%
115 \begin{sfpicture}(100,100)(0,0)
116 \Put@Direct(-100,0){\Westbond}
117 \Put@Line(-60,0)(-1,0){90}
118 \end{sfpicture}}
119 \def\EastPbond{%
120 \begin{sfpicture}(100,100)(0,0)
121 \Put@Direct(100,0){\Eastbond}
122 \Put@Line(60,0)(1,0){90}
123 \end{sfpicture}}
124 \def\sbond{%
125 \begin{sfpicture}(160,0)(0,0)
126 \Put@Line(0,33)(1,0){160}
127 \end{sfpicture}}

5.2 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.

  ********************
  * polyethylene unit*
  ********************
  The following numbering is adopted in this macro.
             |   1      6   |
             |              |
             |   |      |   |
         2 ---- (1) -- (2) ---- 5
             |   |  (0) |   |
             |              |
             |   3      4   |0

The command \polyethylene has arguments, CALIST and SUBSLIST, as well as an optional argument AUXLIST.

    \polyethylene[AUXLIST]{CALIST}{SUBSLIST}

The optional argument AUXLIST is used for typesetting auxiliary symbols on central atoms.

      AUXLIST =
        {n+}  :  + charge (or another one chararacter) on the center

The argument CALIST is used for indicating center atoms.

      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==)

The argument SUBSLIST is used for indicating substituents.

      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

\if@centbondsw
\if@centatswi
\if@centatswii

128 \newif\if@centbondsw \@centbondswfalse
129 \newif\if@centatswi \@centatswifalse
130 \newif\if@centatswii \@centatswiifalse
\polyethylene
\@polyethylene
131 \def\polyethylene{\@ifnextchar[{\@polyethylene}{\@polyethylene[]}}
132 \def\@polyethylene[#1]#2#3{%
133 \begin{sfpicture}(1100,600)(-400,-300)%
134 \OrigptOutput(400,300){polyethylene}%
135 % ************
136 % * aux list *
137 % ************
138 \def\@@@temp{#1}
139 \ifx\@@@temp\empty\else
140 \@tfor\member:=#1\do{%
141 \expandafter\twoch@@r\member{}{}%
142 \ifcase\@@tmpa
143  \or \relax \putratom{47}{50}{\scriptsize\@@tmpb}%
144  \or \relax \putratom{347}{50}{\scriptsize\@@tmpb}%
145 \fi}\fi
146 % *****************
147 % * central atoms *
148 % *****************

149 \@forsemicol\member:=#2\do{%
150 \ifx\member\empty\else
151 \expandafter\@m@mb@r\member;\relax%
152 \expandafter\threech@r\@membera{}{}%
153 \ifcase\@tmpa \global\@centbondswtrue \Put@Direct(20,0){\Eastbond}%
154 \or \global\@centatswitrue \putlratom{-40}{-33}{\@memberb}%
155 \or \global\@centatswiitrue \putlratom{260}{-33}{\@memberb}%
156 \fi\fi}%
157 \if@centatswi \else \putlratom{-40}{-33}{C}\fi
158 \if@centatswii \else \putlratom{260}{-33}{C}\fi
159 \if@centbondsw \else \Put@Line(70,0)(1,0){160}\fi
160 \global\@centbondswfalse
161 \global\@centatswifalse
162 \global\@centatswiifalse
163 % ****************
164 % * Substituents *
165 % ****************
166 \gdef\numrepeated{x}
167 \@forsemicol\member:=#3\do{%
168 \ifx\member\empty\else
169 \expandafter\@m@mb@r\member;\relax%
170 \expandafter\threech@r\@membera{}{}%
171 \ifcase\@tmpa \gdef\numrepeated{\@memberb}%
172 \or\Put@Direct(0,0){\Northbond}%
173 \or\Put@Direct(0,0){\WestPbond}%
174 \or\Put@Direct(0,0){\Southbond}%
175 \or\Put@Direct(300,0){\Southbond}%
176 \or\Put@Direct(300,0){\EastPbond}%
177 \or\Put@Direct(300,0){\Northbond}%
178 \fi\fi}%end of ifcase
179 % **************
180 % * Delimeters *
181 % **************
182 \Put@Direct(-200,-33){\leftpmdelim}
183 \Put@Direct(400,-33){\rightpmdelim{\numrepeated}}
184 \end{sfpicture}}%end of macro polyethylene

5.3 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.

  ********************
  * polystyrene unit *
  ********************
             |   1      6   |
             |              |
             |   |      |   |
         2 ---- (1) -- (2) ---- 5
             |   |  (0) |   |

 |          |   |
 |   3      |   |0
           / `
        6 |    | 2
          |    |
        5 `   / 3
            `
             4

The command \polyethylene has arguments, CALIST, SUBSLIST and PHSUBSLIST,

as well as an optional argument AUXLIST.

\polystyrene[AUXLIST]{CALIST}{SUBSLIST}{PHSUBSLIST}

The optional argument AUXLIST is used for typesetting auxiliary symbols on central atoms.

AUXLIST =
{n+}  :  + charge (or another one chararacter) on the center

The argument CALIST is used for indicating center atoms.

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==)

The argument SUBSLIST is used for indicating substituents on the polymer chain.

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

The argument PHSUBSLIST is used for indicating substituents on the phenyl group.

PHSUBSLIST: list of phenyl substituents
for n = 2 to 6
n or nS    :  single bond at n-atom

\polyethylene
\@polyethylene
185 \def\polystyrene{\@ifnextchar[{\@polystyrene}{\@polystyrene[]}}
186 \def\@polystyrene[#1]#2#3#4{%
187 \begin{sfpicture}(1100,1200)(0,-640)%
188 \OrigptOutput(0,640){polystyrene}%
189 \begingroup \origptfalse
190 \Put@Direct(0,0){\polyethylene[#1]{#2}{#3}}%
191 \Put@Line(700,0)(0,1){240}%
192 \Put@Direct(300,-646){\bzdrv{#4}}%
193 \endgroup
194 \end{sfpicture}}%end of macro polystyrene

195 ⟨/polymers⟩