Lewis Structures by lewisstruc.sty (v1.00) of XΥMTEX

Shinsaku Fujita

Shonan Institute of Chemoinformatics and Mathematical Chemistry Kanagawa, 258-0019 Japan

2009/11/03

1 Introduction

1.1 Options for docstrip

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

1.2 Version Information

1 ⟨∗lewisstruc⟩

2 \typeout{Part of XyMTeX for Drawing Chemical Structural Formulas. Version 4.05}
3 \typeout{       -- Released November 03, 2009 by Shinsaku Fujita}
4 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 \def\j@urnalname{lewisstruc}
6 \def\versi@ndate{November 03, 2009}
7 \def\versi@nno{ver1.00}
8 \def\copyrighth@lder{SF} % Shinsaku Fujita
9 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 \typeout{XyMTeX Macro File `\j@urnalname' (\versi@nno) <\versi@ndate>%
11 \space[\copyrighth@lder]}

The definition of the macro \LewisTetrahedralA uses the command \tetrahedral defined in the aliphat package of the XΥMTEX system.

12 \RequirePackage{aliphat}
13 %\@ifundefined{tetrahedral}{\input aliphat.sty\relax}{}

2 Basic Macros

2.1 Lone Pairs

\dotnodimension A basic command \dotnodimension is used to draw a dot (an electron).

14 \def\dotnodimension{\smash{\hbox to0pt{\hss.\hss}}}

\verticalpair The command \verticalpair is used to draw a vertical lone pair.

\horizontalpair The command \horizontalpair is used to draw a vertical lone pair.

15 \def\verticalpair{\vbox{%
16 \dotnodimension
17 \nointerlineskip
18 \kern0.3em
19 \dotnodimension}}
20 \def\horizontalpair{%
21 \hbox{\dotnodimension\kern0.3em\dotnodimension}}

\nwlonepair The command \nwlonepair is used to draw a lone pair located at the northwest position.

\selonepair The command \selonepair is used to draw a lone pair at the southest posistion.

\swlonepair The command \swlonepair is used to draw a lone pair at the southwest position.

\nelonepair The command \nelonepair is used to draw a lone pair at the northeast position.

22 \def\nwlonepair{%
23 \vtop{\hbox to0.21em{\hss\dotnodimension}%
24 \nointerlineskip
25 \kern0.21em
26 \hbox to0.21em{\dotnodimension\hss}%
27 }}
28 \def\selonepair{%
29 \vbox{\hbox to0.21em{\hss\dotnodimension}%
30 \nointerlineskip
31 \kern0.21em
32 \hbox to0.21em{\dotnodimension\hss}%
33 }}
34 \def\swlonepair{%
35 \vbox{\hbox to0.21em{\dotnodimension\hss}%
36 \nointerlineskip
37 \kern0.21em
38 \hbox to0.21em{\hss\dotnodimension}%
39 }}
40 \def\nelonepair{%
41 \vtop{\hbox to0.21em{\dotnodimension\hss}%
42 \nointerlineskip
43 \kern0.21em
44 \hbox to0.21em{\hss\dotnodimension}%
45 }}

\LewisSbond The command \LewisSbond is used to draw a vertical lone pair used in a horizontal position. For example, H\LewisSbond H outputs H:H for representing a hydrogen molecule.

46 \def\LewisSbond{\raise0.12em\hbox to0.25em{\hss\verticalpair\hss}}

\overpair The command \overpair is used to draw a horizontal lone pair at the head of an atom specified by its argument.

\underpair The command \underpair is used to draw a horizontal lone pair under an atom specified by its argument.

47 \def\overpair#1{\leavevmode\setbox0=\hbox{#1}%
48 \vbox{\hbox to\wd0{\hss\horizontalpair\hss}%

49 \nointerlineskip\kern0.08em
50 \box0}}
51 \def\underpair#1{\leavevmode\setbox0=\hbox{#1}%
52 \dimen0=\wd0
53 \vbox to\ht0{\box0
54 \nointerlineskip
55 %\hbox{\vbox to0pt{\kern0.18em
56 \hbox{\vbox to0pt{\kern0.2em
57 \hbox to\dimen0{\hss\horizontalpair\hss}\vss}}%
58 }}

2.2 Atoms Linked by a Lewis Bond

An atom (OverAtom) which is attached to the top of an atom (BaseAtom) through a Lewis bond is drawn by the following \overpairover command.

 \overpairover{BaseAtom}{OverAtom}

\overpairover
59 \def\overpairover#1#2{\leavevmode\setbox0=\hbox{#1}%
60 \edef\temp@@a{#2}%
61 \dimen0=\wd0%
62 \ifx\temp@@a\empty\box0\else%
63 \vbox{%
64 \hbox to\dimen0{\hss#2\hss}%
65 \nointerlineskip\kern0.2em
66 \hbox to\dimen0{\hss\horizontalpair\hss}%
67 \nointerlineskip\kern0.08em
68 \hbox{\box0}}\fi}

An atom (UnderAtom) which is attached to the bottom of an atom (BaseAtom) through a Lewis bond is drawn by the following \overpairover command.

 \underpairunder{BaseAtom}{UnderAtom}

\underpairunder
69 \def\underpairunder#1#2{\leavevmode\setbox0=\hbox{#1}%
70 \edef\temp@@a{#2}%
71 \dimen0=\wd0\dimen1=\ht0
72 \ifx\temp@@a\empty\box0\else%
73 \vbox to\dimen1{\hbox{\box0}%
74 \nointerlineskip
75 \hbox{\vbox to0pt{\kern0.18em
76 \hbox to\dimen0{\hss\horizontalpair\hss}%
77 \nointerlineskip\kern0.08em
78 \hbox to\dimen0{\hss#2\hss}%
79 \vss}}%
80 }\fi}

An atom (NWAtom) which is attached to the northwest of an atom (BaseAtom) through a Lewis bond is drawn by the following \leftlonepairover command.

 \leftlonepairover{BaseAtom}{NWAtom}

\leftlonepairover
81 \def\leftlonepairover#1#2{\leavevmode%
82 \edef\temp@@{#2}%
83 \ifx\temp@@\empty#1\else
84 \hbox to0pt{\hss\raise0.9em\hbox{#2}\kern-0.05em\raise0.8em\hbox{\nwlonepair}\kern-0.1em}#1\fi}

An atom (NEAtom) which is attached to the northeast of an atom (BaseAtom) through a Lewis bond is drawn by the following \rightlonepairover command.

 \rightlonepairover{BaseAtom}{NEAtom}

\rightlonepairover
85 \def\rightlonepairover#1#2{\leavevmode%
86 #1%
87 \edef\temp@@{#2}%
88 \ifx\temp@@\empty\else
89 \hbox to0pt{\kern-0.1em\raise0.8em\hbox{\nelonepair}\kern-0.05em%
90 \raise0.9em\hbox{#2}\hss}\fi}

An atom (SWAtom) which is attached to the southwest of an atom (BaseAtom) through a Lewis bond is drawn by the following \leftlonepairunder command.

 \leftlonepairunder{BaseAtom}{NEAtom}

\leftlonepairunder
91 \def\leftlonepairunder#1#2{\leavevmode%
92 \edef\temp@@{#2}%
93 \ifx\temp@@\empty#1\else
94 \hbox to0pt{\hss\lower0.9em\hbox{#2}\kern-0.05em%
95 \lower0.2em\hbox{\swlonepair}\kern-0.1em}#1\fi}

An atom (SEAtom) which is attached to the southeast of an atom (BaseAtom) through a Lewis bond is drawn by the following \rightlonepairunder command.

 \rightlonepairunder{BaseAtom}{SEAtom}

\rightlonepairunder
96 \def\rightlonepairunder#1#2{\leavevmode%
97 #1%
98 \edef\temp@@{#2}%
99 \ifx\temp@@\empty\else
100 \hbox to0pt{\kern-0.1em\lower0.2em\hbox{\selonepair}\kern-0.05em%
101 \lower0.9em\hbox{#2}\hss}\fi}

Atoms (W, X, Y, and Z) which are attached to a central atom (A) through Lewis bonds are drawn by the following \LewistetrahedralA command.

 \LewistetrahedralA{0==A;1==W;2==X;3==Y;4==Z}

               W
               :
         4 Z : A : X 2
               :
               Y
               3

Each of the atoms can be omitted.

\LewistetrahedralA
102 \def\LewistetrahedralA#1{\begingroup%
103 \let\temp@a=\empty%
104 \let\temp@b=\empty%
105 \let\temp@c=\empty%
106 \let\temp@d=\empty%
107 \let\temp@e=\empty%
108 \@forsemicol\member:=#1\do{%
109 \ifx\member\empty\else
110 \expandafter\@m@mb@r\member;\relax%
111 \expandafter\threech@r\@membera{}{}%
112 \ifx\@memberb\@yl\else
113 \ifcase\@tmpa \edef\temp@a{\@memberb}%central atom
114 \or\edef\temp@b{\@memberb}%
115 \or\edef\temp@c{\@memberb}%
116 \or\edef\temp@d{\@memberb}%
117 \or\edef\temp@e{\@memberb}%
118 \fi%end of ifcase
119 \fi\fi

120 }%

121 \leavevmode%
122 \ifx\temp@e\empty
123 \ifx\temp@c\empty
124 \underpairunder{\overpairover{\temp@a}{\temp@b}}{\temp@d}%
125 \else%c not empty
126 \underpairunder{\overpairover{\temp@a}{\temp@b}}{\temp@d}%
127 \LewisSbond\temp@c
128 \fi
129 \else%e not empty
130 \ifx\temp@c\empty
131 \temp@e\LewisSbond\underpairunder{\overpairover{\temp@a}{\temp@b}}{\temp@d}%
132 \else
133 \temp@e\LewisSbond\underpairunder{\overpairover{\temp@a}{\temp@b}}{\temp@d}%
134 \LewisSbond\temp@c
135 \fi\fi
136 \endgroup

137 }

Atoms (W, X, Y, and Z) which are attached to a central atom (A) through Lewis bonds are drawn by the following \LewistetrahedralB command.

  \LewistetrahedralB{0==A;1==W;2==X;3==Y;4==Z}

       4  Z         W  1
            :     :
               A
            :     :
       3  Y         X  2

Each of the atoms can be omitted.

\LewistetrahedralB
138 \def\LewistetrahedralB#1{\begingroup%
139 \let\temp@a=\empty%
140 \let\temp@b=\empty%
141 \let\temp@c=\empty%
142 \let\temp@d=\empty%
143 \let\temp@e=\empty%
144 \@forsemicol\member:=#1\do{%
145 \ifx\member\empty\else
146 \expandafter\@m@mb@r\member;\relax%
147 \expandafter\threech@r\@membera{}{}%
148 \ifx\@memberb\@yl\else
149 \ifcase\@tmpa \edef\temp@a{\@memberb}%central atom
150 \or\edef\temp@b{\@memberb}%
151 \or\edef\temp@c{\@memberb}%
152 \or\edef\temp@d{\@memberb}%
153 \or\edef\temp@e{\@memberb}%
154 \fi%end of ifcase
155 \fi\fi

156 }%

157 \leavevmode%
158 \rightlonepairover{%
159 \leftlonepairover{\leftlonepairunder{%
160 \rightlonepairunder{\temp@a}{\temp@c}}{\temp@d}}{\temp@e}}{\temp@b}%
161 \endgroup}

2.3 Lone Pairs around an Atom

Four lone pairs which are attached to a central atom (A) are drawn by the following \lonepairAitoiv command, where each of the top four argumets takes 0 (absence) or 1 (presence) for representing the absence or presece of a lone pair. The larst argument represents the central atom.

  \lonepairAitoiv{0 or 1}{0 or 1}{0 or 1}{0 or 1}{A}

               1
               :
         4   : A :  2
               :
               3

\lonepairAitoiv
162 \def\lonepairAitoiv#1#2#3#4#5{\leavevmode
163 \begingroup\setbox0=\hbox{#5}%
164 \dimen0=\ht0
165 \dimen1=1.22\wd0%
166 \setbox1=\hbox to\wd0{\hss%
167 \smash{%\raise0.01em
168 \hbox to\wd0{\hss%
169 \ifnum#4=0\relax
170 \phantom{\lower0.05em\hbox to0pt{\hss\vbox to\dimen0{\vss\verticalpair\vss}}}%
171 \else
172 \lower0.05em\hbox to0pt{\hss\vbox to\dimen0{\vss\verticalpair\vss}}%
173 \fi%
174 \lower0.2em\hbox{\vbox{\ifnum#1=0\relax
175 \phantom{\hbox to\dimen1{\hss\horizontalpair\hss}}%
176 \else
177 \hbox to\dimen1{\hss\horizontalpair\hss}\fi%
178 \nointerlineskip
179 \kern0.08em
180 \hbox to\dimen1{\hss#5\hss}%
181 \nointerlineskip
182 \kern0.2em
183 \ifnum#3=0\relax
184 \phantom{\hbox to\dimen1{\hss\horizontalpair\hss}}%
185 \else
186 \hbox to\dimen1{\hss\horizontalpair\hss}%
187 \fi
188 }}%
189 \ifnum#2=0\relax
190 \phantom{\lower0.05em\hbox to0pt{\vbox to\dimen0{\vss\verticalpair\vss}\hss}}%
191 \else
192 \lower0.05em\hbox to0pt{\vbox to\dimen0{\vss\verticalpair\vss}\hss}\fi%
193 \hss}}\hss}%
194 \wd1=\wd0 \ht1=\ht0\box1\endgroup}

A common code for transforming a command to another command is defined

 as the command \fromfourobjects
\fromfourobjects
195 \def\fromfourobjects#1#2{%
196 \ifnum#1=1234\relax
197 \TEMP@Command{1}{1}{1}{1}{#2}%
198 \else\ifnum#1=123\relax
199 \TEMP@Command{1}{1}{1}{0}{#2}%
200 \else\ifnum#1=124\relax
201 \TEMP@Command{1}{1}{0}{1}{#2}%
202 \else\ifnum#1=134\relax
203 \TEMP@Command{1}{0}{1}{1}{#2}%
204 \else\ifnum#1=234\relax
205 \TEMP@Command{0}{1}{1}{1}{#2}%
206 \else\ifnum#1=12\relax
207 \TEMP@Command{1}{1}{0}{0}{#2}%
208 \else\ifnum#1=13\relax
209 \TEMP@Command{1}{0}{1}{0}{#2}%

210 \else\ifnum#1=14\relax
211 \TEMP@Command{1}{0}{0}{1}{#2}%
212 \else\ifnum#1=23\relax
213 \TEMP@Command{0}{1}{1}{0}{#2}%
214 \else\ifnum#1=24\relax
215 \TEMP@Command{0}{1}{0}{1}{#2}%
216 \else\ifnum#1=34\relax
217 \TEMP@Command{0}{0}{1}{1}{#2}%
218 \else\ifnum#1=1\relax
219 \TEMP@Command{1}{0}{0}{0}{#2}%
220 \else\ifnum#1=2\relax
221 \TEMP@Command{0}{1}{0}{0}{#2}%
222 \else\ifnum#1=3\relax
223 \TEMP@Command{0}{0}{1}{0}{#2}%
224 \else\ifnum#1=4\relax
225 \TEMP@Command{0}{0}{0}{1}{#2}%
226 \else
227 \TEMP@Command{1}{1}{1}{1}{#2}%
228 \fi\fi\fi\fi\fi
229 \fi\fi\fi\fi\fi
230 \fi\fi\fi\fi\fi}

The command \lonepairAitoiv is converted into the command \lonepairA, where four lone pairs are specified by a set of numbers 1234, 234, etc as an optional argument. The main argument specifies a central atom.

  \lonepairA[1234, etc.]{A}

               1
               :
         4   : A :  2
               :
               3

\lonepairA
231 \def\lonepairA{\@ifnextchar[{\l@nepairA}{\l@nepairA[1234]}}
232 \def\l@nepairA[#1]#2{\leavevmode%
233 \begingroup\let\TEMP@Command=\lonepairAitoiv%
234 \fromfourobjects{#1}{#2}\endgroup}

Four unpaired electron which are attached to a central atom (A) are drawn by the following \tetraradical command, where each of the top four argumets takes 0 (absence) or 1 (presence) for representing the absence or presece of an unpaired electron. The larst argument represents the central atom.

  \tetraradical{0 or 1}{0 or 1}{0 or 1}{0 or 1}{A}

               1
               .
         4   . A .  2
               .
               3

\chemradical
\tetraradical
235 \def\chemradical{\hbox to0pt{\hss.\hss}}
236 \def\tetraradical#1#2#3#4#5{\leavevmode\setbox0=\hbox{#5}%
237 \dimen0=\ht0
238 \dimen1=1.22\wd0%
239 \setbox1=\hbox to\wd0{\hss%
240 \smash{%\raise0.01em
241 \hbox to\wd0{\hss%
242 \ifnum#4=0\relax
243 \phantom{\raise0.02em\hbox to0pt{\hss\vbox to\dimen0{\vss\chemradical\vss}}}%
244 \else
245 \raise0.02em\hbox to0pt{\hss\vbox to\dimen0{\vss\chemradical\vss}}%
246 \fi%
247 %\kern0pt
248 \lower0.22em\hbox{\vbox{%
249 \ifnum#1=0\relax
250 \phantom{\hbox to\dimen1{\hss\chemradical\hss}}%
251 \else
252 \hbox to\dimen1{\hss\chemradical\hss}\fi%
253 \nointerlineskip
254 \kern0.08em
255 \hbox to\dimen1{\hss#5\hss}%
256 \nointerlineskip
257 %\kern0.2em
258 \kern0.12em
259 \ifnum#3=0\relax
260 \phantom{\hbox to\dimen1{\hss\chemradical\hss}}%
261 \else
262 \hbox to\dimen1{\hss\chemradical\hss}%
263 \fi
264 }}%
265 %\kern0pt
266 \ifnum#2=0\relax
267 \phantom{\raise0.02em\hbox to0pt{\vbox to\dimen0{\vss\chemradical\vss}\hss}}%
268 \else
269 \raise0.02em\hbox to0pt{\vbox to\dimen0{\vss\chemradical\vss}\hss}\fi%
270 \hss}}\hss}%
271 \wd1=\wd0 \ht1=\ht0\box1}

The command \tetraradical is converted into the command \chemradicalA, where four unpaired electrons are specified by a set of numbers 1234, 234, etc. as an optional argument. The main argument specifies a central atom.

  \chemradicalA[1234, etc.]{A}

               1
               .
         4   . A .  2
               .
               3

\chemradicalA

272 \def\chemradicalA{\@ifnextchar[{\chemr@dicalA}{\chemr@dicalA[1234]}}
273 \def\chemr@dicalA[#1]#2{\leavevmode
274 \begingroup\let\TEMP@Command=\tetraradical%
275 \fromfourobjects{#1}{#2}\endgroup}

Four lone pairs which are attached to a central atom (A) in another mode are drawn by the following \lonepairBitoiv command, where each of the top four argumets takes 0 (absence) or 1 (presence) for representing the absence or presece of a lone pair. The larst argument represents the central atom.

  \lonepairBitoiv{0 or 1}{0 or 1}{0 or 1}{0 or 1}{A}

          4       1
            :   :
              A
            :   :
          3       2

\lonepairBitoiv
276 \def\lonepairBitoiv#1#2#3#4#5{\begingroup\setbox0=\hbox{#5}%
277 \dimen0=\ht0 \dimen1=1.22\wd0%
278 \setbox1=\hbox to\wd0{\hss%
279 \smash{\lower0.04em\hbox to0pt{%
280 \hss\vbox to\dimen0{\vss%
281 \ifnum#4=0\relax \phantom{\nwlonepair}\else
282 \nwlonepair\fi%
283 \nointerlineskip
284 \kern0.45em
285 \ifnum#3=0\relax \phantom{\swlonepair}\else
286 \swlonepair\fi
287 \vss}\kern-0.2em}%
288 \hbox to\dimen1{\hss#5\hss}%
289 \lower0.04em\hbox to0pt{\kern-0.22em%
290 \vbox to\dimen0{\vss%
291 \ifnum#1=0\relax \phantom{\nelonepair}\else
292 \nelonepair\fi%
293 \nointerlineskip
294 \kern0.45em
295 \ifnum#2=0\relax \phantom{\selonepair}\else
296 \selonepair\fi\vss}\hss}%
297 }\hss}%
298 \ht1=\ht0\box1\endgroup}

The command \lonepairBitoiv is converted into the command \lonepairB, where four lone pairs are specified by a set of numbers 1234, 234, etc as an optional argument. The main argument specifies a central atom.

  \lonepairB[1234, etc.]{A}

          4       1
            :   :

              A
            :   :
          3       2

\lonepairB
299 \def\lonepairB{\@ifnextchar[{\l@nepairB}{\l@nepairB[1234]}}
300 \def\l@nepairB[#1]#2{\leavevmode%
301 \begingroup\let\TEMP@Command=\lonepairBitoiv%
302 \fromfourobjects{#1}{#2}\endgroup}

Four unpaired electron which are attached to a central atom (A) in an alternative mode are drawn by the following \tetraradicalB command, where each of the top four argumets takes 0 (absence) or 1 (presence) for representing the absence or presece of an unpaired electron. The larst argument represents the central atom.

  \tetraradicalB{0 or 1}{0 or 1}{0 or 1}{0 or 1}{A}

           4       1
             .   .
               A
             .   .
           3       2

\tetraradicalB
303 \def\tetraradicalB#1#2#3#4#5{\setbox0=\hbox{#5}%
304 \dimen0=\ht0 \dimen1=1.22\wd0%
305 \setbox1=\hbox to\wd0{\hss%
306 \smash{\lower0.009em\hbox to0pt{%
307 \hss\vbox to\dimen0{\vss%
308 \ifnum#4=0\relax \phantom{\chemradical}\else
309 \chemradical\fi%
310 \nointerlineskip
311 \kern0.7em
312 \ifnum#3=0\relax \phantom{\chemradical}\else
313 \chemradical\fi
314 \vss}\kern-0.05em}%
315 \hbox to\dimen1{\hss#5\hss}%
316 \lower0.009em\hbox to0pt{\kern-0.05em%
317 \vbox to\dimen0{\vss%
318 \ifnum#1=0\relax \phantom{\chemradical}\else
319 \chemradical\fi%
320 \nointerlineskip
321 \kern0.7em
322 \ifnum#2=0\relax \phantom{\chemradical}\else
323 \chemradical\fi\vss}\hss}%
324 }\hss}%
325 \ht1=\ht0\box1}

The command \tetraradicalB is converted into the command \chemradicalB, where four unpaired electrons are specified by a set of numbers 1234, 234, etc. as an optional argument. The main argument specifies a central atom.

  \chemradicalB[1234, etc.]{A}

           4       1
             .   .
               A
             .   .
           3       2

\chemradicalA
326 \def\chemradicalB{\@ifnextchar[{\chemr@dicalB}{\chemr@dicalB[1234]}}
327 \def\chemr@dicalB[#1]#2{\leavevmode
328 \begingroup\let\TEMP@Command=\tetraradicalB%
329 \fromfourobjects{#1}{#2}\endgroup}

3 Macros for Nested Structures

 The macro \LewisTetrahedralA is defined as an extension of \LewistetrahedralA,

where it supports a nestec structures. As a basic function of \LewisTetrahedralA, atoms (W, X, Y, and Z) which are attached to a central atom (A) through Lewis bonds are drawn by the following \LewisTetrahedralA command.

  \LewisTetrahedralA{0==A;1==W;2==X;3==Y;4==Z}

               1
               W
               :
         4 Z : A : X 2
               :
               Y
               3

Each of the atoms can be omitted. The argument of of the macro \LewisTetrahedralA can accommodate a so-called (yl)-function, which can draw a nested structure.

\LewisTetrahedralA This macro is based on the definition of the macro \tetrahedral defined in the aliphat package.

330 \def\LewisTetrahedralA{%
331 \@ifnextchar[{\@LewisTetrahedralA[r}{\@LewisTetrahedralA[r]}}
332 \def\@LewisTetrahedralA#1]#2{%
333 \@ifnextchar<{\@@LewisTetrahedralA#1]{#2}}{\@@LewisTetrahedralA#1]{#2}<,,,>}}
334 \def\@@LewisTetrahedralA#1]#2<#3,#4,#5,#6>{%
335 \begingroup
336 \let\Northbond=\Northlonepair
337 \let\Southbond=\Southlonepair
338 \let\Eastbond=\Eastlonepair
339 \let\Westbond=\Westlonepair
340 \let\yltetrahedralposition=\ylLewisTetrahedralAposition
341 \@@tetrahedral#1]#2<#3,#4,#5,#6>%

342 \endgroup
343 \West@bondfalse
344 \East@bondfalse
345 }%end of macro LewisTetrahedralA

Note that the innermacros \Northbond etc. used in the definition of \tetrahedral are replaced by \Northlonepair etc.

\Northlonepair
346 \def\Northlonepair{%
347 \@ifnextchar[{\N@rthlonepair}{\N@rthlonepair[]}}
348 \def\N@rthlonepair[#1]{%
349 \if\@tmpb D\relax%
350  \put(0,60){\hbox to0pt{\hss\horizontalpair\hss}}%
351  \put(0,90){\hbox to0pt{\hss\horizontalpair\hss}}%
352  \putlratom{-40}{120}{\@memberb}%==1 upper substituent
353 \else\if\@tmpb T\relax%
354  \put(0,60){\hbox to0pt{\hss\horizontalpair\hss}}%
355  \put(0,90){\hbox to0pt{\hss\horizontalpair\hss}}%
356  \put(0,120){\hbox to0pt{\hss\horizontalpair\hss}}%
357  \putlratom{-40}{150}{\@memberb}%==1 upper substituent
358 \else\if\@tmpb N\relax%normal single bond
359  \Put@Line(0,52)(0,1){110}%
360  \putlratom{-40}{171}{\@memberb}%==1 upper substituent
361 \else
362  \put(0,60){\hbox to0pt{\hss\horizontalpair\hss}}%
363  \putlratom{-40}{90}{\@memberb}%==1 upper substituent
364 \fi\fi\fi%

365 }

\Southlonepair
366 \def\Southlonepair{%
367 \@ifnextchar[{\S@uthlonepair}{\S@uthlonepair[]}}
368 \def\S@uthlonepair[#1]{%
369 \if\@tmpb D\relax%
370  \put(0,-60){\hbox to0pt{\hss\horizontalpair\hss}}%
371  \put(0,-90){\hbox to0pt{\hss\horizontalpair\hss}}%
372  \putlratom{-40}{-180}{\@memberb}%==3 down substituent
373 \else\if\@tmpb T\relax%
374  \put(0,-60){\hbox to0pt{\hss\horizontalpair\hss}}%
375  \put(0,-90){\hbox to0pt{\hss\horizontalpair\hss}}%
376  \put(0,-120){\hbox to0pt{\hss\horizontalpair\hss}}%
377  \putlratom{-40}{-210}{\@memberb}%==3 down substituent
378 \else\if\@tmpb N\relax%normal single bond
379  \Put@Line(0,-48)(0,-1){110}%
380  \putlratom{-40}{-250}{\@memberb}%==1 upper substituent
381 \else
382  \put(0,-60){\hbox to0pt{\hss\horizontalpair\hss}}%
383  \putlratom{-40}{-150}{\@memberb}%==3 down substituent
384 \fi\fi\fi%

385 }

\Eastlonepair
386 \def\Eastlonepair{%

387 \@ifnextchar[{\E@stlonepair}{\E@stlonepair[]}}
388 \def\E@stlonepair[#1]{%
389 \if\@tmpb D\relax%
390  \put(60,-18){\hbox to0pt{\hss\verticalpair\hss}}%
391  \put(90,-18){\hbox to0pt{\hss\verticalpair\hss}}%
392  \putratom{120}{-33}{\@memberb}%==3 down substituent
393 \else\if\@tmpb T\relax%
394  \put(60,-18){\hbox to0pt{\hss\verticalpair\hss}}%
395  \put(90,-18){\hbox to0pt{\hss\verticalpair\hss}}%
396  \put(120,-18){\hbox to0pt{\hss\verticalpair\hss}}%
397  \putratom{150}{-33}{\@memberb}%==3 down substituent
398 \else\if\@tmpb N\relax%normal single bond
399  \Put@Line(50,0)(1,0){140}%
400  \putratom{190}{-33}{\@memberb}%==1 upper substituent
401 \else
402  \put(60,-18){\hbox to0pt{\hss\verticalpair\hss}}%
403  \putratom{90}{-33}{\@memberb}%==3 down substituent
404 \fi\fi\fi%

405 }

\Westlonepair
406 \def\Westlonepair{%
407 \@ifnextchar[{\W@stlonepair}{\W@stlonepair[]}}
408 \def\W@stlonepair[#1]{%
409 \if\@tmpb D\relax%
410  \put(-65,-18){\hbox to0pt{\hss\verticalpair\hss}}%
411  \put(-95,-18){\hbox to0pt{\hss\verticalpair\hss}}%
412  \putlatom{-120}{-33}{\@memberb}%==3 down substituent
413 \else\if\@tmpb T\relax%
414  \put(-65,-18){\hbox to0pt{\hss\verticalpair\hss}}%
415  \put(-95,-18){\hbox to0pt{\hss\verticalpair\hss}}%
416  \put(-125,-18){\hbox to0pt{\hss\verticalpair\hss}}%
417  \putlatom{-150}{-33}{\@memberb}%==3 down substituent
418 \else\if\@tmpb N\relax%normal single bond
419  \Put@Line(-50,0)(-1,0){140}%
420  \putlatom{-190}{-33}{\@memberb}%==1 upper substituent
421 \else
422  \put(-65,-18){\hbox to0pt{\hss\verticalpair\hss}}%
423  \putlatom{-90}{-33}{\@memberb}%==3 down substituent
424 \fi\fi\fi%

425 }

The macro \LewisTetrahedralA supports a (yl)-function, which is based on the x,y-adjustment due to the \ylLewisTetrahedralAposition, which is defined in a similar way to \yltetrahedralposition used in the definition of the macro \tetrahedral. The original values are left as commented lines in order to compare with the aliphat package of the XΥMTEX system.

\ylLewisTetrahedralAposition
426 \def\ylLewisTetrahedralAposition#1{%
427 \@@ylswfalse%%%\@reset@ylsw
428 \West@bondfalse
429 \East@bondfalse
430 \@forsemicol\member:=#1\do{%

431 \if@@ylsw\else
432 \ifx\member\empty\else
433 \expandafter\@m@mb@r\member;\relax
434 \expandafter\threech@r\@membera{}{}\relax
435 \ifx\@memberb\@yl\relax\@@ylswtrue\else\@@ylswfalse\fi
436 \if@@ylsw%
437 \ifcase\@tmpa%
438 \or%1
439 \ifno@centeratom%
440 \gdef\@ylii{0}\gdef\@yli{0}\global\@ylswtrue%N subst. on 1
441 \else%
442 %   \gdef\@ylii{0}\gdef\@yli{-52}\global\@ylswtrue%N subst. on 1
443 \gdef\@ylii{45}\gdef\@yli{33}\global\@ylswtrue%N subst. on 1
444 \fi%
445 \or%2
446 \ifno@centeratom%
447  \gdef\@ylii{0}\gdef\@yli{0}\global\@ylswtrue%
448 \else%
449 %    \gdef\@ylii{52}\gdef\@yli{0}\global\@ylswtrue%
450  \gdef\@ylii{40}\gdef\@yli{30}\global\@ylswtrue%
451 \fi%
452 \East@bondtrue%W subst. on 1
453 \or%3
454 \ifno@centeratom%
455 \gdef\@ylii{0}\gdef\@yli{0}\global\@ylswtrue%S subst. on 1
456 \else%
457 %   \gdef\@ylii{0}\gdef\@yli{52}\global\@ylswtrue%S subst. on 1
458 \gdef\@ylii{35}\gdef\@yli{40}\global\@ylswtrue%S subst. on 1
459 \fi%
460 \or%4
461 \ifno@centeratom%
462 \gdef\@ylii{-72}\gdef\@yli{0}\global\@ylswtrue%??????
463 \else%
464 %   \gdef\@ylii{-52}\gdef\@yli{0}\global\@ylswtrue%
465 \gdef\@ylii{-40}\gdef\@yli{32}\global\@ylswtrue%
466 \fi%
467  \West@bondtrue%E subst. on 1
468 \fi%end of ifcase
469 \fi\fi\fi}}%
    The macro \LewisTetrahedralB is defined as an extension of \LewistetrahedralB,

where it supports a nestec structures. As a basic function of \LewisTetrahedralB, atoms (W, X, Y, and Z) which are attached to a central atom (A) through Lewis bonds are drawn by the following \LewisTetrahedralB command.

  \LewisteTrahedralB{0==A;1==W;2==X;3==Y;4==Z}

       4  Z         W  1
            :     :
               A
            :     :
       3  Y         X  2

Each of the atoms can be omitted.

\LewisTetrahedralB
470 \def\LewisTetrahedralB{%
471 \@ifnextchar[{\@LewisTetrahedralB[r}{\@LewisTetrahedralB[r]}}
472 \def\@LewisTetrahedralB#1]#2{%
473 \begingroup
474 \let\NEbond=\NEbondlonepair
475 \let\SEbond=\SEbondlonepair
476 \let\SWbond=\SWbondlonepair
477 \let\NWbond=\NWbondlonepair
478 \let\ylsquareposition=\ylLewisTetrahedralBposition
479 \@squareplanar#1]{#2}%
480 \endgroup
481 }%end of macro LewisTetrahedralB

Note that the inner macros \NEbond etc. used in the definition of \squareplanar are replaced by \NEbondlonepair etc.

\NEbondlonepair
482 \def\NEbondlonepair{%
483 \begin{sfpicture}(100,300)(0,0)%
484 \if\@tmpb D\relax%
485  \put(50,50){\hbox to0pt{\hss\nelonepair\hss}}%
486  \put(75,75){\hbox to0pt{\hss\nelonepair\hss}}%
487  \putratom{90}{82}{\@memberb}%==1 northeast substituent
488 \else\if\@tmpb T\relax%
489  \put(50,50){\hbox to0pt{\hss\nelonepair\hss}}%
490  \put(75,75){\hbox to0pt{\hss\nelonepair\hss}}%
491  \put(100,100){\hbox to0pt{\hss\nelonepair\hss}}%
492  \putratom{115}{107}{\@memberb}%==1 northeast substituent
493 \else\if\@tmpb N\relax%normal single bond
494  \Put@Line(40,47)(1,1){95}%
495  \putratom{145}{137}{\@memberb}%==1 (northeast substituent)
496 \else
497  \put(50,50){\hbox to0pt{\hss\nelonepair\hss}}%
498  \putratom{65}{57}{\@memberb}%==1 northeast substituent
499 \fi\fi\fi%
500 \end{sfpicture}%

501 }

\SEbondlonepair
502 \def\SEbondlonepair{%
503 \begin{sfpicture}(100,300)(0,0)%
504 \if\@tmpb D\relax%
505  \put(50,-50){\hbox to0pt{\hss\selonepair\hss}}%
506  \put(75,-75){\hbox to0pt{\hss\selonepair\hss}}%
507  \putratom{90}{-148}{\@memberb}%==2 southeast substituent
508 \else\if\@tmpb T\relax%
509  \put(50,-50){\hbox to0pt{\hss\selonepair\hss}}%
510  \put(75,-75){\hbox to0pt{\hss\selonepair\hss}}%

511  \put(100,-100){\hbox to0pt{\hss\selonepair\hss}}%
512  \putratom{115}{-173}{\@memberb}%==2 southeast substituent
513 \else\if\@tmpb N\relax%normal single bond
514  \Put@Line(40,-47)(1,-1){95}%
515  \putratom{145}{-203}{\@memberb}%==2 (southeast substituent)
516 \else
517  \put(50,-50){\hbox to0pt{\hss\selonepair\hss}}%
518  \putratom{65}{-123}{\@memberb}%==2 southeast substituent
519 \fi\fi\fi%
520 \end{sfpicture}%

521 }

\SWbondlonepair
522 \def\SWbondlonepair{%
523 \begin{sfpicture}(100,300)(0,0)%
524 \if\@tmpb D\relax%
525  \put(-50,-50){\hbox to0pt{\hss\swlonepair\hss}}%
526  \put(-75,-75){\hbox to0pt{\hss\swlonepair\hss}}%
527  \putlatom{-90}{-148}{\@memberb}%==3 southeast substituent
528 \else\if\@tmpb T\relax%
529  \put(-50,-50){\hbox to0pt{\hss\swlonepair\hss}}%
530  \put(-75,-75){\hbox to0pt{\hss\swlonepair\hss}}%
531  \put(-100,-100){\hbox to0pt{\hss\swlonepair\hss}}%
532  \putlatom{-115}{-173}{\@memberb}%==3 southeast substituent
533 \else\if\@tmpb N\relax%normal single bond
534  \Put@Line(-50,-47)(-1,-1){95}%
535  \putlatom{-163}{-203}{\@memberb}%==3 (southwest substituent)
536 \else
537  \put(-50,-50){\hbox to0pt{\hss\swlonepair\hss}}%
538  \putlatom{-65}{-123}{\@memberb}%==3 southeast substituent
539 \fi\fi\fi%
540 \end{sfpicture}%

541 }

\NWbondlonepair
542 \def\NWbondlonepair{%
543 \begin{sfpicture}(100,300)(0,0)%
544 \if\@tmpb D\relax%
545  \put(-50,50){\hbox to0pt{\hss\nwlonepair\hss}}%
546  \put(-75,75){\hbox to0pt{\hss\nwlonepair\hss}}%
547  \putlatom{-90}{82}{\@memberb}%==4 northwest substituent
548 \else\if\@tmpb T\relax%
549  \put(-50,50){\hbox to0pt{\hss\nwlonepair\hss}}%
550  \put(-75,75){\hbox to0pt{\hss\nwlonepair\hss}}%
551  \put(-100,100){\hbox to0pt{\hss\nwlonepair\hss}}%
552  \putlatom{-115}{107}{\@memberb}%==4 northwest substituent
553 \else\if\@tmpb N\relax%normal single bond
554  \Put@Line(-40,47)(-1,1){95}%
555  \putlatom{-145}{137}{\@memberb}%==4 (northwest substituent)
556 \else
557  \put(-50,50){\hbox to0pt{\hss\nwlonepair\hss}}%
558  \putlatom{-65}{57}{\@memberb}%==1 northwest substituent
559 \fi\fi\fi%
560 \end{sfpicture}%

The macro \LewisTetrahedralB supports a (yl)-function, which is based on the x,y-adjustment due to the \ylLewisTetrahedralBposition, which is defined in a similar way to \ylsquareposition used in the definition of the macro \squaraplanar (renamed from \square). The original values are left as commented lines in order to compare with the aliphat package of the XΥMTEX system.

\ylLewisTetrahedralBposition
562 \def\ylLewisTetrahedralBposition#1{%
563 \@@ylswfalse%%%\@reset@ylsw
564 \@forsemicol\member:=#1\do{%
565 \if@@ylsw\else
566 \ifx\member\empty\else
567 \expandafter\@m@mb@r\member;\relax
568 \expandafter\threech@r\@membera{}{}\relax
569 \ifx\@memberb\@yl\relax\@@ylswtrue\else\@@ylswfalse\fi
570 \if@@ylsw
571 \ifcase\@tmpa
572 \or%
573 %     \gdef\@ylii{-40}\gdef\@yli{-47}\global\@ylswtrue% NE subst. on 1
574  \gdef\@ylii{-28}\gdef\@yli{40}\global\@ylswtrue% NE subst. on 1
575 \or%2
576 %     \gdef\@ylii{-40}\gdef\@yli{47}\global\@ylswtrue% SE subst. on 2
577  \gdef\@ylii{-28}\gdef\@yli{35}\global\@ylswtrue% SE subst. on 2
578 \or%3
579 %     \gdef\@ylii{50}\gdef\@yli{47}\global\@ylswtrue% SW subst. on 3
580  \gdef\@ylii{35}\gdef\@yli{22}\global\@ylswtrue% SW subst. on 3
581 \or%4
582 %     \gdef\@ylii{50}\gdef\@yli{-47}\global\@ylswtrue% NW subst. on 4
583  \gdef\@ylii{35}\gdef\@yli{40}\global\@ylswtrue% NW subst. on 4
584 \fi%end of ifcase
585 \fi\fi\fi}}%
586 \endinput

587 ⟨/lewisstruc⟩