% hetarom.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\typeout{XyMTeX for Drawing Chemical Structural Formulas. Version 1.00}
\typeout{       -- Released December 1, 1993 by Shinsaku Fujita}
\typeout{}
\typeout{}
% Copyright (C) 1993 by Shinsaku Fujita, all rights reserved.
%
% 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].  
%
% Copying of this file is authorized only if either
%  (1) you make absolutely no changes to your copy, including name and 
%     directory name; or
%  (2) if you do make changes, 
%     (a) you name it something other than the names included in the 
%         ``xymtex'' directory and 
%     (b) you are requested to leave this notice intact.
% This restriction ensures that all standard styles are identical.
%
% Please report any bugs, comments, suggestions, etc. to:
%   Shinsaku Fujita, 
%   Ashigara Research Laboratories, Fuji Photo Film Co., Ltd., 
%   Minami-Ashigara, Kanagawa-ken, 250-01, Japan.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\j@urnalname{hetarom}
\def\versi@ndate{December 01, 1993}
\def\versi@nno{ver1.00}
\def\copyrighth@lder{SF} % Shinsaku Fujita
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\typeout{XyMTeX Macro File `\j@urnalname' (\versi@nno) <\versi@ndate>\space%
% [\copyrighth@lder]}
%
% *********************************
% * hetarom.sty: list of commands *
% *********************************
%
% <Various flags (switches)>
%
%     \if@gclip \@gclipfalse \@gcliptrue
%     \if@hclip \@hclipfalse \@hcliptrue
%     \if@iclip \@iclipfalse \@icliptrue
%     \if@jclip \@jclipfalse \@jcliptrue
%     \iniflag
%     \iniatom
%     \aaa
%     \bbb
%     \ccc
%     \ddd
%     \eee
%     \fff
%     \ggg
%     \hhh
%     \iii
%     \jjj
%
%  <Six-Membered Heterocycles>
%    Setting inner double bonds
%
%     \bonda
%     \bondb
%     \bondc
%     \bondd
%     \bonde
%     \bondf
%     \bondhoriz
%     \bondhorizi
%
%    Setting skeletal bonds
%
%     \skbonda
%     \skbondf
%     \skbondc
%     \skbondd
%     \skbondb
%     \skbonde
%     \skbondhoriz
%     \skbondhorizi
%
%    Basic Macros
%
%     \sixheterov               \@sixheterov
%     \sixheterovi              \@sixheterovi
%
%    Application Macros
%
%     \pyridinev                \@pyridinev
%     \pyridinevi               \@pyridinevi
%     \pyrazinev                \@pyrazinev
%     \pyrimidinev              \@pyrimidinev
%     \pyrimidinevi             \@pyrimidinevi
%     \pyridazinev              \@pyridazinev
%     \pyridazinevi             \@pyridazinevi
%     \triazinev                \@triazinev
%     \triazinevi               \@triazinevi
%
%  <Five-Membered Heterocycles>
%    Basic Macros
%
%     \fiveheterov              \@fiveheterov
%     \fiveheterovi             \@fiveheterovi
%
%    Application Macros
%
%     \pyrrolev                 \@pyrrolev
%     \pyrazolev                \@pyrazolev
%     \imidazolev               \@imidazolev
%     \isoxazolev               \@isoxazolev
%     \oxazolev                 \@oxazolev
%     \pyrrolevi                \@pyrrolevi
%     \pyrazolevi               \@pyrazolevi
%     \imidazolevi              \@imidazolevi
%     \isoxazolevi              \@isoxazolevi
%     \oxazolevi                \@oxazolevi
%
%  <Six-Six-Fused Heterocycles>
%    Basic Macros
%
%     \decaheterov              \@decaheterov
%     \decaheterovi             \@decaheterovi
%
%    Application Macros
%
%     \quinolinev               \@quinolinev
%     \quinolinevi              \@quinolinevi
%     \isoquinolinev            \@isoquinolinev
%     \isoquinolinevi           \@isoquinolinevi
%     \quinoxalinev             \@quinoxalinev
%     \quinazolinev             \@quinazolinev
%     \quinazolinevi            \@quinazolinevi
%     \cinnolinev               \@cinnolinev
%     \cinnolinevi              \@cinnolinevi
%     \pteridinev               \@pteridinev
%     \pteridinevi              \@pteridinevi
%
%  <Six-Five-Fused Heterocycles>
%    Basic Macros
%
%     \nonaheterov              \@nonaheterov
%     \nonaheterovi             \@nonaheterovi
%
%    Application Macros
%
%     \purinev                  \@purinev
%     \purinevi                 \@purinevi
%     \indolev                  \@indolev
%     \indolevi                 \@indolevi
%     \indolizinev              \@indolizinev
%     \indolizinevi             \@indolizinevi
%     \isoindolev               \@isoindolev
%     \isoindolevi              \@isoindolevi
%     \benzofuranev             \@benzofuranev
%     \benzofuranevi            \@benzofuranevi
%     \isobenzofuranev          \@isobenzofuranev
%     \isobenzofuranevi         \@isobenzofuranevi
%     \benzoxazolev             \@benzoxazolev
%     \benzoxazolevi            \@benzoxazolevi
%
%  <Four-Membered Heterocycles>
%    Setting bonds
%     \bondshoriz               \bondshorizi
%     \skbondshoriz             \skbondshorizi
%
%    Basic Macros
%
%     \fourhetero               \@fourhetero
%
%  <Four-Membered Heterocycles>
%    Setting inner double bonds
%
%     \bondtria                 \bondtrib
%     \skbondtria               \skbondtrib
%
%    Basic Macros
%
%     \threehetero              \@threehetero
%
%  <Building Units>
%
%     \sixunitv                 \@sixunitv
%     \fiveunitv                \@fiveunitv
%     \fiveunitvi               \@fiveunitvi
%
% *************************
% * input of basic macros *
% *************************
\@ifundefined{setsixringv}{\input chemstr.sty\relax}{}%
\unitlength=0.1pt%
%% ****************************
%% * various flags (switches) *
%% ****************************
%\newif\if@gclip \@gclipfalse%
%\newif\if@hclip \@hclipfalse%
%\newif\if@iclip \@iclipfalse%
%\newif\if@jclip \@jclipfalse%
%\def\iniflag{%
%\@aclipfalse \@bclipfalse\@cclipfalse\@clipfalse\@eclipfalse%
%\@fclipfalse\@gclipfalse\@hclipfalse\@iclipfalse\@jclipfalse%
%\@clipfusefalse}%
%\def\iniatom{%
%\def\aaa{}\def\bbb{}\def\ccc{}\def\ddd{}\def\eee{}\def\fff{}%
%\def\ggg{}\def\hhh{}\def\iii{}\def\jjj{}%
%\def\@aaa{}\def\@bbb{}\def\@ccc{}\def\@ddd{}\def\@eee{}\def\@fff{}%
%}%
%\def\resetbdsw{\gdef\@aaa{a}\gdef\@bbb{b}\gdef\@ccc{c}%
%\gdef\@ddd{d}\gdef\@eee{e}\gdef\@fff{f}}%
%
\iniatom%
% ******************************
% * setting inner double bonds *
% ******************************
% These macros are used in \sixhetero and \fivehetero for setting 
% inner double bonds in accordance with the presence or the absence of 
% hetero atoms. The following numbering is adopted in this macro. 
%                   aaa
%                    1
%                  f * a
%           fff 6  *   *  2 bbb
%             e   |     |   b
%                 |     |
%           eee 5  *   *  3 ccc
%                 d  *  c
%                    4 <===== the original point
%                   ddd
% bond between 1 and 2
\def\bonda{%
  \ifx\aaa\empty%
   \ifx\bbb\empty%
    \put(6,364){\line(5,-3){126}}%         %double bond 1-2
   \else%
    \put(6,364){\line(5,-3){100}}%         %double bond 1-2
   \fi%
  \else%
   \ifx\bbb\empty%
    \put(35,340){\line(5,-3){100}}%        %double bond 1-2
   \else%
    \put(35,352){\line(5,-3){100}}%        %double bond 1-2
   \fi%                                    % line <1OO not available
  \fi%
 }%
% bond between 3 and 2
 \def\bondb{%
  \ifx\bbb\empty%
   \ifx\ccc\empty%
    \put(138,129){\line(0,1){148}}%        %double bond 3-2
   \else%
    \put(138,143){\line(0,1){134}}%        %double bond 3-2
   \fi%
  \else%
   \ifx\ccc\empty%
    \put(138,129){\line(0,1){134}}%        %double bond 3-2
   \else%
    \put(138,143){\line(0,1){110}}%        %double bond 3-2
   \fi%
  \fi%
}%
% bond between 4 and 3
 \def\bondc{%
  \ifx\ddd\empty%
   \ifx\ccc\empty%
    \put(6,42){\line(5,3){126}}           %double bond 4-3
   \else% 
    \put(6,42){\line(5,3){100}}           %double bond 4-3
   \fi%
  \else%
   \ifx\ccc\empty%
    \put(35,66){\line(5,3){100}}%          %double bond 4-3
   \else% 
    \put(35,60){\line(5,3){100}}%          %double bond 4-3
   \fi%                                    % line <1OO not available
  \fi%
}%
% bond between 4 and 5
 \def\bondd{%
  \ifx\ddd\empty%
   \ifx\eee\empty%
    \put(-6,42){\line(-5,3){126}}%         %double bond 4-5
   \else% 
    \put(-6,42){\line(-5,3){100}}%         %double bond 4-5
   \fi%
  \else%
   \ifx\eee\empty%
    \put(-35,66){\line(-5,3){100}}%        %double bond 4-5
   \else% 
    \put(-35,60){\line(-5,3){100}}%        %double bond 4-5
   \fi%                                    % line <1OO not available
  \fi%
 }%
% bond between 5 and 6
\def\bonde{%
  \ifx\fff\empty%
   \ifx\eee\empty%
    \put(-138,129){\line(0,1){148}}%       %double bond 5-6
   \else%
    \put(-138,143){\line(0,1){134}}%       %double bond 5-6
   \fi%
  \else%
   \ifx\eee\empty%
    \put(-138,129){\line(0,1){134}}%       %double bond 5-6
   \else%
    \put(-138,143){\line(0,1){110}}%       %double bond 5-6
   \fi%
  \fi%
}%
% bond between 1 and 6
\def\bondf{%
  \ifx\aaa\empty%
   \ifx\fff\empty%
    \put(-6,364){\line(-5,-3){126}}%        %double bond 1-6
   \else%
    \put(-6,364){\line(-5,-3){100}}%        %double bond 1-6
   \fi%
  \else%
   \ifx\fff\empty%
    \put(-35,340){\line(-5,-3){100}}%       %double bond 1-6
   \else%
    \put(-35,352){\line(-5,-3){100}}%       %double bond 1-6
   \fi%                                     % line <1OO not available
  \fi%
}%
% horizontal inner bond for five-membered rings
\def\bondhoriz{%
  \ifx\fff\empty%
    \ifx\bbb\empty%
     \put(-138,270){\line(1,0){277}}%      %double bond 4-3
    \else%
     \put(-138,270){\line(1,0){258}}%      %double bond 4-3
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(-120,270){\line(1,0){258}}%      %double bond 4-3
    \else%
     \put(-120,270){\line(1,0){239}}%      %double bond 4-3
    \fi%
  \fi}%
% horizontal inner bond for five-membered rings (inverse type) 
\def\bondhorizi{%
  \ifx\eee\empty%
    \ifx\ccc\empty%
     \put(-138,136){\line(1,0){277}}%      %double bond 4-3
    \else%
     \put(-138,136){\line(1,0){258}}%      %double bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(-120,136){\line(1,0){258}}%      %double bond 4-3
    \else%
     \put(-120,136){\line(1,0){239}}%      %double bond 4-3
    \fi%
  \fi}%
% **************************
% * setting skeletal bonds *
% **************************
% These macros are used in \sixhetero and \fivehetero for setting 
% skeletal bonds in accordance with the presence or the absence of 
% hetero atoms. The following numbering is adopted in this macro. 
%                   aaa
%                    1
%                  f * a
%           fff 6  *   *  2 bbb
%             e   |     |   b
%                 |     |
%           eee 5  *   *  3 ccc
%                 d  *  c
%                    4 <===== the original point
%                   ddd
% 
%bond between 1 and 2
\def\skbonda{%
  \ifx\aaa\empty%
    \ifx\bbb\empty%
     \put(0,406){\line(5,-3){171}}%        %bond 1-2
    \else%
     \put(0,406){\line(5,-3){136}}%        %bond 1-2
    \fi%
   \else%
    \ifx\bbb\empty%
     \put(35,385){\line(5,-3){136}}%       %bond 1-2
    \else%
     \put(35,385){\line(5,-3){100}}%       %bond 1-2
    \fi%
   \fi}%
%bond between 1 and 6
\def\skbondf{%
  \ifx\aaa\empty%
    \ifx\fff\empty%
     \put(0,406){\line(-5,-3){171}}%       %bond 1-6
    \else%
     \put(0,406){\line(-5,-3){136}}%       %bond 1-6
    \fi%
   \else%
    \ifx\fff\empty%
     \put(-35,385){\line(-5,-3){136}}%     %bond 1-6
    \else%
     \put(-35,385){\line(-5,-3){100}}%     %bond 1-6
    \fi%
   \fi}%
%bond between 4 and 3
\def\skbondc{%
  \ifx\ddd\empty%
    \ifx\ccc\empty%
     \put(0,0){\line(5,3){171}}%           %bond 4-3
    \else%
     \put(0,0){\line(5,3){136}}%           %bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(35,21){\line(5,3){138}}%         %bond 4-3
    \else%
     \put(35,21){\line(5,3){100}}%         %bond 4-3
    \fi%
  \fi}%
%bond between 4 and 5
\def\skbondd{%
  \ifx\ddd\empty%
    \ifx\eee\empty%
     \put(0,0){\line(-5,3){171}}%          %bond 4-5
    \else%
     \put(0,0){\line(-5,3){136}}%          %bond 4-5
    \fi%
  \else%
    \ifx\eee\empty%
     \put(-35,21){\line(-5,3){138}}%       %bond 4-5
    \else%
     \put(-35,21){\line(-5,3){100}}%        %bond 4-5
    \fi%
  \fi}%
%bond between 3 and 2
\def\skbondb{%
  \ifx\bbb\empty%%
    \ifx\ccc\empty%%
     \put(171,103){\line(0,1){200}}%       %bond 3-2
    \else%
     \put(171,143){\line(0,1){160}}%       %bond 3-2
    \fi%
  \else%
    \ifx\ccc\empty%%
     \put(171,103){\line(0,1){150}}%       %bond 3-2
    \else%
     \put(171,143){\line(0,1){110}}%       %bond 3-2
    \fi%
  \fi}%
%bond between 5 and 6
\def\skbonde{%
  \ifx\eee\empty%
    \ifx\fff\empty%
     \put(-171,103){\line(0,1){200}}%       %bond 5-6
    \else%
     \put(-171,103){\line(0,1){150}}%       %bond 5-6
    \fi%
  \else%
    \ifx\fff\empty%
     \put(-171,143){\line(0,1){160}}%       %bond 5-6
    \else%
     \put(-171,143){\line(0,1){110}}%       %bond 5-6
    \fi%
  \fi}%
%horizontal bond for five-membered rings
\def\skbondhoriz{%
  \ifx\fff\empty%
    \ifx\bbb\empty%
     \put(-171,303){\line(1,0){342}}%      %bond 4-3
    \else%
     \put(-171,303){\line(1,0){300}}%      %bond 4-3
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(171,303){\line(-1,0){300}}%      %bond 4-3
    \else%
     \put(-129,303){\line(1,0){258}}%      %bond 4-3
    \fi%
  \fi}%
%horizontal bond for five-membered rings (inverse type)
\def\skbondhorizi{%
  \ifx\eee\empty%
    \ifx\ccc\empty%
     \put(-171,103){\line(1,0){342}}%      %bond 4-3
    \else%
     \put(-171,103){\line(1,0){300}}%      %bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(171,103){\line(-1,0){300}}%      %bond 4-3
    \else%
     \put(-129,103){\line(1,0){258}}%      %bond 4-3
    \fi%
  \fi}%
%
% *************************
% * sixhetero derivatives *
% *  (vertical type)      *
% *************************
% The following numbering is adopted in this macro. 
%
%          1
%          * 
%     6  *   *  2
%       |     |
%       |     |
%     5  *   *  3
%          *
%          4 <===== the original point
%
%   \sixheterov[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST = 
%
%           none or r  :  sixhetero (right-handed)
%           l          :  sixhetero (left-handed)
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,6-double bond
%           f          :  6,1-double bond
%           A          :  aromatic circle 
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 6 atoms)
%
%       for n = 1 to 6
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position, 
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 6 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \sixheterov{1==N}{1==Cl;2==F}
%        \sixheterov[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \sixheterov[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5==Cl;6==Cl}
%
\def\sixheterov{\@ifnextchar[{\@sixheterov}{\@sixheterov[r]}}
\def\@sixheterov[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniatom\iniflag%initialize
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\aaa{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\ddd{\@memberb}%
 \or \xdef\eee{\@memberb}%
 \or \xdef\fff{\@memberb}%
\fi}%
 \begin{picture}(800,880)(-\shiftii,-\shifti)
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `sixheterov' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
 \skbonda% bond between 1 and 2
 \skbondf% bond between 1 and 6
 \skbondc% bond between 4 and 3
 \skbondd% bond between 4 and 5
 \skbondb% bond between 3 and 2
 \skbonde% bond between 5 and 6
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax \bondd \bondf \bondb%
\else\if\member l\relax \bonda \bondc \bonde%
\else\if\member a\relax \bonda%
\else\if\member b\relax \bondb%
\else\if\member c\relax \bondc%
\else\if\member d\relax \bondd%
\else\if\member e\relax \bonde%
\else\if\member f\relax \bondf%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 1\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-38}{88}{\@@tmpb}%       % right type
      \else\if\@@tmpa 6\relax%
        \putratom{-90}{253}{\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-90}{120}{\@@tmpb}%      % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue% 
   \putratom{-31}{-10}{\ddd}%  % right type
\fi%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{-31}{356}{\aaa}%  % right type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type
\fi%
\setsixringv{#3}{0}{0}{7}{0}%    %subst 1--6
\end{picture}\iniatom\iniflag}%     %end of \sixheterov macro
%
% **********************************
% * sixhetero derivatives          *
% *  (vertical type, inverse type) *
% **********************************
% The following numbering is adopted in this macro. 
%
%          4
%          * 
%     5  *   *  3
%       |     |
%       |     |
%     6  *   *  2
%          *
%          1 <===== the original point
%
%   \sixheterovi[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST = 
%
%           none or r  :  sixhetero (right-handed)
%           l          :  sixhetero (left-handed)
%           [] or H    :  fully saturated form
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,6-double bond
%           f          :  6,1-double bond
%           A          :  aromatic circle 
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 6 atoms)
%
%       for n = 1 to 6
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position, 
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 6 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \sixheterovi{1==N}{1==Cl;2==F}
%        \sixheterovi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \sixheterovi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5==Cl;6==Cl}
%
\def\sixheterovi{\@ifnextchar[{\@sixheterovi}{\@sixheterovi[r]}}
\def\@sixheterovi[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniatom\iniflag%initialize
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\ddd{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\aaa{\@memberb}%
 \or \xdef\fff{\@memberb}%
 \or \xdef\eee{\@memberb}%
\fi}%
 \begin{picture}(800,880)(-\shiftii,-\shifti)
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `sixheterovi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
 \skbonda% bond between 4 and 3
 \skbondf% bond between 4 and 5
 \skbondc% bond between 1 and 2
 \skbondd% bond between 1 and 6
 \skbondb% bond between 3 and 2
 \skbonde% bond between 5 and 6
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax \bondd \bondf \bondb%
\else\if\member l\relax \bonda \bondc \bonde%
\else\if\member a\relax \bondc%
\else\if\member b\relax \bondb%
\else\if\member c\relax \bonda%
\else\if\member d\relax \bondf%
\else\if\member e\relax \bonde%
\else\if\member f\relax \bondd%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 4\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 1\relax%
        \putratom{-38}{88}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-90}{253}{\@@tmpb}%      % right type
      \else\if\@@tmpa 6\relax%
        \putratom{-90}{120}{\@@tmpb}%      % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue% 
   \putratom{-31}{-10}{\ddd}%  % right type
\fi%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{-31}{356}{\aaa}%  % right type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type
\fi%
\setsixringv{#3}{5}{0}{5}{-1}%    %subst 1--4
\setsixringv{#3}{11}{4}{7}{-1}%   %subst 5 and 6
\end{picture}\iniatom\iniflag}%     %end of \sixheterovi macro
%
% ************************
% * pyridine derivatives *
% *  (vertical type)     *
% ************************
%
%   \pyridinev[BONDLIST]{SUBSLIST}
%   \pyridinevi[BONDLIST]{SUBSLIST}
%   \pyrazinev[BONDLIST]{SUBSLIST}
%   \pyrimidinev[BONDLIST]{SUBSLIST}
%   \pyrimidinevi[BONDLIST]{SUBSLIST}
%   \triazinev[BONDLIST]{SUBSLIST}
%   \triazinevi[BONDLIST]{SUBSLIST}
%
%     BONDLIST = 
%
%           none or r  :  pyridine (right-handed)
%           l          :  pyridine (left-handed)
%           H or []    :  fully saturated ring
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,6-double bond
%           f          :  6,1-double bond
%           A          :  aromatic circle 
%           *          :  plus at the nitrogen atom
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 6 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \pyridinev{1==Cl;2==F}
%        \pyridinev[c]{1==Cl;4==F;2==CH$_{3}$}
%        \pyridinev[eb]{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\pyridinev{\@ifnextchar[{\@pyridinev}{\@pyridinev[r]}}
\def\@pyridinev[#1]#2{%
\iforigpt \typeout{command `pyridinev' is based on `sixheterov'.}\fi%
\sixheterov[#1]{1==N}{#2}} %end of \pyridinev macro
\def\pyridinevi{\@ifnextchar[{\@pyridinevi}{\@pyridinevi[r]}}
\def\@pyridinevi[#1]#2{%
\iforigpt \typeout{command `pyridinevi' is based on `sixheterovi'.}\fi%
\sixheterovi[#1]{1==N}{#2}} %end of \pyridinevi macro
%
\def\pyrazinev{\@ifnextchar[{\@pyrazinev}{\@pyrazinev[r]}}
\def\@pyrazinev[#1]#2{%
\iforigpt \typeout{command `pyrazinev' is based on `sixheterov'.}\fi%
\sixheterov[#1]{1==N;4==N}{#2}}%end of \pyrazinev macro
%
\def\pyrimidinev{\@ifnextchar[{\@pyrimidinev}{\@pyrimidinev[r]}}
\def\@pyrimidinev[#1]#2{%
\iforigpt \typeout{command `pyrimidinev' is based on `sixheterov'.}\fi%
\sixheterov[#1]{1==N;3==N}{#2}} 
   %end of \pyrimidinev macro
\def\pyrimidinevi{\@ifnextchar[{\@pyrimidinevi}{\@pyrimidinevi[r]}}
\def\@pyrimidinevi[#1]#2{%
\iforigpt \typeout{command `pyrimidinevi' is based on `sixheterovi'.}\fi%
\sixheterovi[#1]{1==N;3==N}{#2}} 
   %end of \pyrimidinevi macro
%
\def\pyridazinev{\@ifnextchar[{\@pyridazinev}{\@pyridazinev[r]}}
\def\@pyridazinev[#1]#2{%
\iforigpt \typeout{command `pyridazinev' is based on `sixheterov'.}\fi%
\sixheterov[#1]{1==N;2==N}{#2}} 
   %end of \pyridazinev macro
\def\pyridazinevi{\@ifnextchar[{\@pyridazinevi}{\@pyridazinevi[r]}}
\def\@pyridazinevi[#1]#2{%
\iforigpt \typeout{command `pyridazinev' is based on `sixheterovi'.}\fi%
\sixheterovi[#1]{1==N;2==N}{#2}} 
   %end of \pyridazinevi macro
%
\def\triazinev{\@ifnextchar[{\@triazinev}{\@triazinev[r]}}
\def\@triazinev[#1]#2{%
\iforigpt \typeout{command `triazinev' is based on `sixheterov'.}\fi%
\sixheterov[#1]{1==N;3==N;5==N}{#2}} 
   %end of \triazinev macro
%
\def\triazinevi{\@ifnextchar[{\@triazinevi}{\@triazinevi[r]}}
\def\@triazinevi[#1]#2{%
\iforigpt \typeout{command `triazinevi' is based on `sixheterovi'.}\fi%
\sixheterovi[#1]{1==N;3==N;5==N}{#2}} 
   %end of \triazinevi macro
%
% **************************
% * fivehetero derivatives *
% *  (vertical type)       *
% **************************
% The following numbering is adopted in this macro. 
%
%     4  _____  3
%       |     |
%       |     |
%     5  *   *  2
%          *
%          1 <===== the original point
%
%   \fiveheterov[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST: list of inner double bonds 
%
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,1-double bond
%           A          :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 5)
%           {0+}       :  plus (or minus) at the center
%
%     ATOMLIST: list of heteroatoms (max 5 atoms)
%
%       for n = 1 to 5
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 5 substitution positions)
%
%       for n = 1 to 5 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \fiveheterov{1==N}{1==H;2==F}
%        \fiveheterov[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \fiveheterov[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\fiveheterov{\@ifnextchar[{\@fiveheterov}{\@fiveheterov[r]}}
\def\@fiveheterov[#1]#2#3{%
\iniatom\iniflag%initialize
%\def\aaa{}\def\bbb{}\def\ccc{}\def\ddd{}\def\eee{}\def\fff{}%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\ddd{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\fff{\@memberb}%
 \or \xdef\eee{\@memberb}%
\fi}%
\begin{picture}(800,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveheterov' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
\skbondc%bond between 1 and 2
\skbondd%bond between 1 and 5
\skbondb%bond between 2 to 3
\skbonde%bond between 5 and 4
\skbondhoriz%bond between 4 and 3
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else\if\member a\relax \bondc%
\else\if\member b\relax \bondb%
\else\if\member c\relax \bondhoriz%
\else\if\member d\relax \bonde%
\else\if\member e\relax \bondd%
\else\if\member A\relax%
 \put(0,173){\circle{180}}%aromatic circle
\else \expandafter\twoch@@r\member{}{}%     %plus or minus charges
      \if\@@tmpa 1\relax%
        \putratom{-38}{88}{\@@tmpb}%        % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{120}{\@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{233}{\@@tmpb}%        % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-60}{233}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 0\relax%
        \putratom{-38}{150}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue% 
   \putratom{-31}{-10}{\ddd}%    % right type at 1
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type at 3
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type at 4
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type at 2
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type at 5 
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringv{#3}{5}{1}{5}{-1}%   % for 1 to 3
\setsixringv{#3}{10}{4}{7}{-1}%  % for 4 to 5
\end{picture}\iniatom\iniflag}%             %end of \fiveheterov macro
%
% *****************************
% * fivehetero derivatives    *
% *  (vertical type, inverse) *
% *****************************
% The following numbering is adopted in this macro. 
%
%          1
%          * 
%     6  *   *  2
%       |     |
%       |_____|
%     4         3
%          *
%        (0,0) <===== the original point
%
%   \fiveheterovi[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST: list of inner double bonds 
%
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,1-double bond
%           A          :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 5)
%           {0+}       :  plus (or minus) at the center
%
%     ATOMLIST: list of heteroatoms (max 5 atoms)
%
%       for n = 1 to 5
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 5 substitution positions)
%
%       for n = 1 to 5 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \fiveheterovi{1==N}{1==H;2==F}
%        \fiveheterovi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \fiveheterovi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\fiveheterovi{\@ifnextchar[{\@fiveheterovi}{\@fiveheterovi[r]}}
\def\@fiveheterovi[#1]#2#3{%
\iniatom\iniflag%initialize
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\aaa{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\eee{\@memberb}%
 \or \xdef\fff{\@memberb}%
\fi}%
\begin{picture}(800,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveheterovi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
\skbonda%bond between 1 and 2
\skbondb%bond between 2 and 3
\skbonde%bond between 4 and 5
\skbondf%bond between 1 and 5
\skbondhorizi% bond between 3 and 4
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else\if\member a\relax \bonda%
\else\if\member b\relax \bondb%
\else\if\member c\relax \bondhorizi%
\else\if\member d\relax \bonde%
\else\if\member e\relax \bondf%
\else\if\member A\relax%
 \put(0,233){\circle{180}}%aromatic circle
\else \expandafter\twoch@@r\member{}{}%     %plus or minus charges
      \if\@@tmpa 1\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{233}{\@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{120}{\@@tmpb}%        % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-60}{233}{\@@tmpb}%       % right type
      \else\if\@@tmpa 0\relax%
        \putratom{-38}{213}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{-31}{356}{\aaa}%  % right type  at 1
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type at 2
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type at 5
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type at 3
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type at 4 
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringv{#3}{0}{0}{4}{0}%  % for 1 to 3
\setsixringv{#3}{1}{4}{7}{0}%  % for 4 to 5
\end{picture}\iniatom\iniflag}               %end of \fiveheterov macro
%
% ***********************************
% * pyrrole derivatives  and others *
% *  (vertical type)                *
% ***********************************
%
%   \pyrrolev[BONDLIST]{SUBSLIST}
%   \pyrazolev[BONDLIST]{SUBSLIST}
%   \imidazolev[BONDLIST]{SUBSLIST}
%   \isoxazolev[BONDLIST]{SUBSLIST}
%   \oxazolev[BONDLIST]{SUBSLIST}
%  
%     BONDLIST: list of inner double bonds 
%
%           none       :  mother nucleus
%           H or []    :  fully saturated form
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,1-double bond
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 5 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \pyrrolev{1==H;2==F}
%        \pyrrolev[]{1==H;2==F}
%        \pyrrolev[H]{1==H;2==F}
%        \imidazolev[c]{1==Cl;4==F;2==CH$_{3}$}
%        \isoxazolev[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\pyrrolev{\@ifnextchar[{\@pyrrolev}{\@pyrrolev[bd]}}
\def\@pyrrolev[#1]#2{%
%\iforigpt \typeout{command `pyrrolev' is based on `fiveheterov'.}\fi%
\fiveheterov[#1]{1==N}{#2}}
\def\pyrazolev{\@ifnextchar[{\@pyrazolev}{\@pyrazolev[bd]}}
\def\@pyrazolev[#1]#2{%
%\iforigpt \typeout{command `pyrazolev' is based on `fiveheterov'.}\fi%
\fiveheterov[#1]{1==N;2==N}{#2}}
\def\imidazolev{\@ifnextchar[{\@imidazolev}{\@imidazolev[bd]}}
\def\@imidazolev[#1]#2{%
%\iforigpt \typeout{command `imidazolev' is based on `fiveheterov'.}\fi%
\fiveheterov[#1]{1==N;3==N}{#2}}
\def\isoxazolev{\@ifnextchar[{\@isoxazolev}{\@isoxazolev[bd]}}
\def\@isoxazolev[#1]#2{%
%\iforigpt \typeout{command `isoxazolev' is based on `fiveheterov'.}\fi%
\fiveheterov[#1]{1==O;2==N}{#2}}
\def\oxazolev{\@ifnextchar[{\@oxazolev}{\@oxazolev[bd]}}
\def\@oxazolev[#1]#2{%
%\iforigpt \typeout{command `oxazolev' is based on `fiveheterov'.}\fi%
\fiveheterov[#1]{1==O;3==N}{#2}}
%
% ***********************************
% * pyrrole derivatives  and others *
% *  (vertical type, inverse)       *
% ***********************************
%
%   \pyrrolevi[BONDLIST]{SUBSLIST}
%   \pyrazolevi[BONDLIST]{SUBSLIST}
%   \imidazolevi[BONDLIST]{SUBSLIST}
%   \isoxazolevi[BONDLIST]{SUBSLIST}
%   \oxazolevi[BONDLIST]{SUBSLIST}
%  
%     BONDLIST: list of inner double bonds 
%
%           none       :  mother nucleus
%           H or []    :  fully saturated form
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,1-double bond
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 5 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \pyrrolevi{1==H;2==F}
%        \pyrrolevi[]{1==H;2==F}
%        \pyrrolevi[H]{1==H;2==F}
%        \imidazolevi[c]{1==Cl;4==F;2==CH$_{3}$}
%        \isoxazolevi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\pyrrolevi{\@ifnextchar[{\@pyrrolevi}{\@pyrrolevi[bd]}}
\def\@pyrrolevi[#1]#2{%
%\iforigpt \typeout{command `pyrrolevi' is based on `fiveheterovi'.}\fi%
\fiveheterovi[#1]{1==N}{#2}}
\def\pyrazolevi{\@ifnextchar[{\@pyrazolevi}{\@pyrazolevi[bd]}}
\def\@pyrazolevi[#1]#2{%
%\iforigpt \typeout{command `pyrazolevi' is based on `fiveheterovi'.}\fi%
\fiveheterovi[#1]{1==N;2==N}{#2}}
\def\imidazolevi{\@ifnextchar[{\@imidazolevi}{\@imidazolevi[bd]}}
\def\@imidazolevi[#1]#2{%
%\iforigpt \typeout{command `imidazolevi' is based on `fiveheterovi'.}\fi%
\fiveheterovi[#1]{1==N;3==N}{#2}}
\def\isoxazolevi{\@ifnextchar[{\@isoxazolevi}{\@isoxazolevi[bd]}}
\def\@isoxazolevi[#1]#2{%
%\iforigpt \typeout{command `isoxazolevi' is based on `fiveheterovi'.}\fi%
\fiveheterovi[#1]{1==O;2==N}{#2}}
\def\oxazolevi{\@ifnextchar[{\@oxazolevi}{\@oxazolevi[bd]}}
\def\@oxazolevi[#1]#2{%
%\iforigpt \typeout{command `oxazolevi' is based on `fiveheterovi'.}\fi%
\fiveheterovi[#1]{1==O;3==N}{#2}}
%
% **************************
% * decahetero derivatives *
% *  (vertical type)       *
% **************************
% The following numbering is adopted in this macro. 
%
%          8 (10)1
%          *  8a *
%     7  *   * *   *  2
%       |     |     |
%       |     |     |
%     6  *   * *   *  3
%          *  4a *
%          5 (9) 4
%          ^
%          |
%          the original point
%
%   \decaheterov[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  decahetero (right-handed)
%           l          :  decahetero (left-handed)
%           H or []    :  fully saturated form
%           a    :  1,2-double bond      b    :  2,3-double bond
%           c    :  4,3-double bond      d    :  4,4a-double bond
%           e    :  4a,5-double bond     f    :  5,6-double bond
%           g    :  6,7-double bond      h    :  7,8-double bond
%           i    :  8,8a-double bond     j    :  1,8a-double bond
%           k    :  4a,8a-double bond
%           A    :  aromatic circle      B    :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 10 atoms)
%
%       for n = 1 to 8
%
%            n         : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%            na        : Hetero atom at 4a or 8b (n=4 or 8)
%                        e.g. 4a==N (or 9==N) for N at 4a-position
%                             8a==N (or {{10}}==N) for N at 8a-position
%
%     SUBSLIST: list of substituents (max 8 substitution positions)
%
%       for n = 1 to 8
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       for 9 (4a position) and 10 (8a position)
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%
%       e.g. 
%        
%        \decaheterov{1==N}{1==Cl;2==F}
%        \decaheterov[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \decaheterov[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\decaheterov{\@ifnextchar[{\@decaheterov}{\@decaheterov[r]}}
\def\@decaheterov[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniflag\iniatom%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\aaa{\@memberb}%1
 \or \xdef\bbb{\@memberb}%2
 \or \xdef\ccc{\@memberb}%3
 \or%
   \if\@tmpb a%
     \xdef\iii{\@memberb}%4a
   \else\ifx\@tmpb\empty%
     \xdef\ddd{\@memberb}%4
   \fi\fi%
 \or \xdef\eee{\@memberb}%5
 \or \xdef\fff{\@memberb}%6
 \or \xdef\ggg{\@memberb}%7
 \or%
   \if\@tmpb a%
     \xdef\jjj{\@memberb}%8a
   \else\ifx\@tmpb\empty%
     \xdef\hhh{\@memberb}%8
   \fi\fi%
\or \xdef\iii{\@memberb}%9 (= 4a)
\or \xdef\jjj{\@memberb}%10 (= 8a)
\fi}%
 \begin{picture}(1200,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `decaheterov' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(342,0){\skbonda}% bond between 1 and 2
 \put(342,0){\skbondb}% bond between 3 and 2
 \put(342,0){\skbondc}% bond between 4 and 3
 \put(342,0){\skbondf}% bond between 1 and 6
 \put(342,0){\skbondd}% bond between 4 and 4a
 \put(342,0){\skbonde}% bond between 4a and 8a
}%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\skbonda}% bond between 8 and 8a
 \put(0,0){\skbondc}% bond between 5 and 4a
 \put(0,0){\skbondf}% bond between 8 and 7
 \put(0,0){\skbondd}% bond between 5 and 6
 \put(0,0){\skbonde}% bond between 6 and 7
}%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
{\let\fff=\jjj \let\eee=\iii%
 \put(342,0){\bonda}% bond between 1 and 2
 \put(342,0){\bondc}% bond between 3 and 4
}%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 8a and 4a
 \put(0,0){\bondf}% bond between 8 and 7
 \put(0,0){\bondd}% bond between 5 and 6
}%
\else\if\member l\relax%
\else\if\member a\relax%
 \put(342,0){\bonda}% bond between 1 and 2
\else\if\member b\relax
 \put(342,0){\bondb}% bond between 2 and 3
\else\if\member c\relax
 \put(342,0){\bondc}% bond between 3 and 4
\else\if\member d\relax%
{\let\eee=\iii%
 \put(342,0){\bondd}% bond between 4 and 4a
}%
\else\if\member e\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,0){\bondc}% bond between 5 and 4a
}%
\else\if\member f\relax%
{\let\ddd=\eee \let\eee=\fff%
 \put(0,0){\bondd}% bond between 5 and 6
}%
\else\if\member g\relax%
{\let\eee=\fff \let\fff=\ggg% 
 \put(0,0){\bonde}% bond between 6 and 7
}%
\else\if\member h\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,0){\bondf}% bond between 8 and 7
}%
\else\if\member i\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,0){\bonda}% bond between 8 and 8a
}%
\else\if\member j\relax%
{\let\fff=\jjj%
 \put(342,0){\bondf}% bond between 1 and 8a
}%
\else\if\member k\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 8a and 4a
}%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}               %circle
\else\if\member B%left aromatic circle 
  \put(342,203){\circle{240}}             %circle
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{8a} \def\aay{4a}%
      \if\@@tmpa 1\relax%                  % plus charge etc.
        \putratom{304}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{402}{253}{\@@tmpb}%      % right type
      \else\if\@@tmpa 3\relax%
        \putratom{402}{120}{\@@tmpb}%      % right type
      \else\if\@@tmpa 4\relax%
        \putratom{304}{68}{\@@tmpb}%       % right type
      \else\if\@@tmpa 6\relax%
        \putlatom{-60}{253}{\@@tmpb}%      % left type
      \else\if\@@tmpa 7\relax%
        \putlatom{-60}{120}{\@@tmpb}%      % left type
      \else\if\@@tmpa 8\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 10\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 9\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-38}{68}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
% hetero atom on 1
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{311}{356}{\aaa}%  % right type
\fi%
% hetero atom on 2
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{477}{280}{\bbb}%  % right type
\fi%
% hetero atom on 3
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{477}{65}{\ccc}%   % right type
\fi%
% hetero atom on 4
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{311}{-10}{\ddd}%  % right type
\fi%
% hetero atom on 4a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putlatom{207}{65}{\iii}%  % left type
\fi%
}%
% hetero atom on 8a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{207}{280}{\jjj}% % left type
\fi%
}%
% hetero atom on 5
{\let\ddd=\eee%
\ifx\ddd\empty\else
   \global\@ecliptrue%
   \putratom{-31}{-10}{\eee}%  % right type
\fi%
}%
% hetero atom on 6
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putlatom{-135}{65}{\fff}%  % left type
\fi%
}%
% hetero atom on 7
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{-135}{280}{\ggg}% % left type
\fi%
}%
% hetero atom on 8
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putratom{-31}{356}{\hhh}%  % right type
\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(342,0){\setsixringv{#3}{0}{0}{5}{0}}% %substituents on 1 to 4
{\@clipfalse \if@eclip \@cliptrue \fi%   %substituents on 5 to 7
 \@eclipfalse \if@fclip \@ecliptrue \fi%
 \@fclipfalse \if@gclip \@fcliptrue \fi%
\put(0,0){\setsixringv{#3}{-1}{3}{7}{0}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%   %substituent on 8
\put(0,0){\setsixringv{#3}{-7}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(171,103){\setatombond{#3}{-8}{7}}%   %9 %for 4a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(171,303){\setatombond{#3}{-9}{1}}%  %10 for 8a position
}%
\end{picture}\iniatom\iniflag}%               %end of \decaheterov macro
%
% **********************************
% * decahetero derivatives         *
% *  (vertical type, inverse type) *
% **********************************
% The following numbering is adopted in this macro. 
%
%          5 (9) 4
%          *  4a *
%     6  *   * *   *  3
%       |     |     |
%       |     |     |
%     7  *   * *   *  2
%          *  8a *
%          8 (10)1
%          ^
%          |
%          the original point
%
%   \decaheterovi[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  decahetero (right-handed)
%           l          :  decahetero (left-handed)
%           H or []    :  fully saturated form
%           a    :  1,2-double bond      b    :  2,3-double bond
%           c    :  4,3-double bond      d    :  4,4a-double bond
%           e    :  4a,5-double bond     f    :  5,6-double bond
%           g    :  6,7-double bond      h    :  7,8-double bond
%           i    :  8,8a-double bond     j    :  1,8a-double bond
%           k    :  4a,8a-double bond
%           A    :  aromatic circle      B    :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 10 atoms)
%
%       for n = 1 to 8
%
%            n         : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%            na        : Hetero atom at 4a or 8b (n=4 or 8)
%                        e.g. 4a==N (or 9==N) for N at 4a-position
%                             8a==N (or {{10}}==N) for N at 8a-position
%
%     SUBSLIST: list of substituents (max 8 substitution positions)
%
%       for n = 1 to 8
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       for 9 (4a position) and 10 (8a position)
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%
%       e.g. 
%        
%        \decaheterovi{1==N}{1==Cl;2==F}
%        \decaheterovi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \decaheterovi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\decaheterovi{\@ifnextchar[{\@decaheterovi}{\@decaheterovi[r]}}
\def\@decaheterovi[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniflag\iniatom%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\ddd{\@memberb}%1
 \or \xdef\ccc{\@memberb}%2
 \or \xdef\bbb{\@memberb}%3
 \or%
   \if\@tmpb a%
     \xdef\jjj{\@memberb}%4a
   \else\ifx\@tmpb\empty%
     \xdef\aaa{\@memberb}%4
   \fi\fi%
 \or \xdef\hhh{\@memberb}%5
 \or \xdef\ggg{\@memberb}%6
 \or \xdef\fff{\@memberb}%7
 \or%
   \if\@tmpb a%
     \xdef\iii{\@memberb}%8a
   \else\ifx\@tmpb\empty%
     \xdef\eee{\@memberb}%8
   \fi\fi%
\or \xdef\jjj{\@memberb}%9 (= 4a)
\or \xdef\iii{\@memberb}%10 (= 8a)
\fi}%
 \begin{picture}(1200,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `decaheterovi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(342,0){\skbonda}% bond between 1 and 2
 \put(342,0){\skbondb}% bond between 3 and 2
 \put(342,0){\skbondc}% bond between 4 and 3
 \put(342,0){\skbondf}% bond between 1 and 6
 \put(342,0){\skbondd}% bond between 4 and 4a
 \put(342,0){\skbonde}% bond between 4a and 8a
}%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\skbonda}% bond between 8 and 8a
 \put(0,0){\skbondc}% bond between 5 and 4a
 \put(0,0){\skbondf}% bond between 8 and 7
 \put(0,0){\skbondd}% bond between 5 and 6
 \put(0,0){\skbonde}% bond between 6 and 7
}%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
{\let\fff=\jjj \let\eee=\iii%
 \put(342,0){\bonda}% bond between 1 and 2
 \put(342,0){\bondc}% bond between 3 and 4
}%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 8a and 4a
 \put(0,0){\bondf}% bond between 8 and 7
 \put(0,0){\bondd}% bond between 5 and 6
}%
\else\if\member l\relax%
\else\if\member a\relax%
 \put(342,0){\bondc}% bond between 3 and 4
\else\if\member b\relax%
 \put(342,0){\bondb}% bond between 2 and 3
\else\if\member c\relax%
 \put(342,0){\bonda}% bond between 1 and 2
\else\if\member d\relax%
{\let\fff=\jjj%
 \put(342,0){\bondf}% bond between 1 and 8a
}%
\else\if\member e\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,0){\bonda}% bond between 8 and 8a
}%
\else\if\member f\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,0){\bondf}% bond between 8 and 7
}%
\else\if\member g\relax%
{\let\eee=\fff \let\fff=\ggg% 
 \put(0,0){\bonde}% bond between 6 and 7
}%
\else\if\member h\relax%
{\let\ddd=\eee \let\eee=\fff%
 \put(0,0){\bondd}% bond between 5 and 6
}%
\else\if\member i\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,0){\bondc}% bond between 5 and 4a
}%
\else\if\member j\relax%
{\let\eee=\iii%
 \put(342,0){\bondd}% bond between 4 and 4a
}%
\else\if\member k\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 8a and 4a
}%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}               %circle
\else\if\member B%left aromatic circle 
  \put(342,203){\circle{240}}             %circle
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{4a} \def\aay{8a}%
      \if\@@tmpa 4\relax%                  % plus charge etc.
        \putratom{304}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 3\relax%
        \putratom{402}{253}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{402}{120}{\@@tmpb}%      % right type
      \else\if\@@tmpa 1\relax%
        \putratom{304}{68}{\@@tmpb}%       % right type
      \else\if\@@tmpa 7\relax%
        \putlatom{-60}{253}{\@@tmpb}%      % left type
      \else\if\@@tmpa 6\relax%
        \putlatom{-60}{120}{\@@tmpb}%      % left type
      \else\if\@@tmpa 5\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 9\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 10\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 8\relax%
        \putratom{-38}{68}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
% hetero atom on 1
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{311}{356}{\aaa}%  % right type
\fi%
% hetero atom on 2
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{477}{280}{\bbb}%  % right type
\fi%
% hetero atom on 3
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{477}{65}{\ccc}%   % right type
\fi%
% hetero atom on 4
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{311}{-10}{\ddd}%  % right type
\fi%
% hetero atom on 4a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putlatom{207}{65}{\iii}%  % left type
\fi%
}%
% hetero atom on 8a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{207}{280}{\jjj}% % left type
\fi%
}%
% hetero atom on 5
{\let\ddd=\eee%
\ifx\ddd\empty\else%
   \global\@ecliptrue%
   \putratom{-31}{-10}{\eee}%  % right type
\fi%
}%
% hetero atom on 6
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putlatom{-135}{65}{\fff}%  % left type
\fi%
}%
% hetero atom on 7
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{-135}{280}{\ggg}% % left type
\fi%
}%
% hetero atom on 8
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putratom{-31}{356}{\hhh}%  % right type
\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(342,0){\setsixringv{#3}{5}{0}{5}{-1}}% %substituents on 1 to 4
{\@clipfalse \if@eclip \@cliptrue \fi%      %substituents on 6 to 8
 \@eclipfalse \if@fclip \@ecliptrue \fi%
 \@fclipfalse \if@gclip \@fcliptrue \fi%
\put(0,0){\setsixringv{#3}{12}{3}{7}{-1}}%
}
{\@aclipfalse \if@hclip \@acliptrue \fi%    %substituent on 5
\put(0,0){\setsixringv{#3}{-4}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(171,103){\setatombond{#3}{-9}{7}}%    %10 for 8a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(171,303){\setatombond{#3}{-8}{1}}%   %9 for 4a position
}%
\end{picture}\iniatom\iniflag}%             %end of \decaheterovi macro
%
% ****************************************************
% * heterocycles having two fused six-membered rings *
% *  (vertical type)                                 *
% ****************************************************
%
%   \quinolinev[BONDLIST]{SUBSLIST}
%   \quinolinevi[BONDLIST]{SUBSLIST}
%   \isoquinolinev[BONDLIST]{SUBSLIST}
%   \isoquinolinevi[BONDLIST]{SUBSLIST}
%   \quinoxalinev[BONDLIST]{SUBSLIST}
%   \quinazolinev[BONDLIST]{SUBSLIST}
%   \quinazolinevi[BONDLIST]{SUBSLIST}
%   \cinnolinev[BONDLIST]{SUBSLIST}
%   \cinnolinevi[BONDLIST]{SUBSLIST}
%   \pteridinev[BONDLIST]{SUBSLIST}
%   \pteridinevi[BONDLIST]{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  decahetero (right-handed)
%           l          :  decahetero (left-handed)
%           H or []    :  fully saturated form
%           a    :  1,2-double bond      b    :  2,3-double bond
%           c    :  4,3-double bond      d    :  4,4a-double bond
%           e    :  4a,5-double bond     f    :  5,6-double bond
%           g    :  6,7-double bond      h    :  7,8-double bond
%           i    :  8,8a-double bond     j    :  1,8a-double bond
%           k    :  4a,8a-double bond
%           A    :  aromatic circle      B    :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 8
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       for 9 (4a position) and 10 (8a position)
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%
%       e.g. 
%        
%        \decaheterov{1==N}{1==Cl;2==F}
%        \decaheterov[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \decaheterov[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\quinolinev{\@ifnextchar[{\@quinolinev}{\@quinolinev[acfhk]}}
\def\@quinolinev[#1]#2{%
\iforigpt \typeout{command `quinolinev' is based on `decaheterov'.}\fi%
\decaheterov[#1]{1==N}{#2}}
\def\quinolinevi{\@ifnextchar[{\@quinolinevi}{\@quinolinevi[acfhk]}}
\def\@quinolinevi[#1]#2{%
\iforigpt \typeout{command `quinolinevi' is based on `decaheterovi'.}\fi%
\decaheterovi[#1]{1==N}{#2}}
%
\def\isoquinolinev{\@ifnextchar[{\@isoquinolinev}{\@isoquinolinev[acfhk]}}
\def\@isoquinolinev[#1]#2{%
\iforigpt \typeout{command `isoquinolinev' is based on `decaheterov'.}\fi%
\decaheterov[#1]{2==N}{#2}}
\def\isoquinolinevi{\@ifnextchar[{\@isoquinolinevi}{\@isoquinolinevi[acfhk]}}
\def\@isoquinolinevi[#1]#2{%
\iforigpt \typeout{command `isoquinolinevi' is based on `decaheterovi'.}\fi%
\decaheterovi[#1]{2==N}{#2}}
%
\def\quinoxalinev{\@ifnextchar[{\@quinoxalinev}{\@quinoxalinev[acfhk]}}
\def\@quinoxalinev[#1]#2{%
\iforigpt \typeout{command `quinoxalinev' is based on `decaheterov'.}\fi%
\decaheterov[#1]{1==N;4==N}{#2}}
%
\def\quinazolinev{\@ifnextchar[{\@quinazolinev}{\@quinazolinev[acfhk]}}
\def\@quinazolinev[#1]#2{%
\iforigpt \typeout{command `quinazolinev' is based on `decaheterov'.}\fi%
\decaheterov[#1]{1==N;3==N}{#2}}
\def\quinazolinevi{\@ifnextchar[{\@quinazolinevi}{\@quinazolinevi[acfhk]}}
\def\@quinazolinevi[#1]#2{%
\iforigpt \typeout{command `quinazolinevu' is based on `decaheterovi'.}\fi%
\decaheterovi[#1]{1==N;3==N}{#2}}
%
\def\cinnolinev{\@ifnextchar[{\@cinnolinev}{\@cinnolinev[acfhk]}}
\def\@cinnolinev[#1]#2{%
\iforigpt \typeout{command `cinnolinev' is based on `decaheterov'.}\fi%
\decaheterov[#1]{1==N;2==N}{#2}}
\def\cinnolinevi{\@ifnextchar[{\@cinnolinevi}{\@cinnolinevi[acfhk]}}
\def\@cinnolinevi[#1]#2{%
\iforigpt \typeout{command `cinnolinev' is based on `decaheterovi'.}\fi%
\decaheterovi[#1]{1==N;2==N}{#2}}
%
\def\pteridinev{\@ifnextchar[{\@pteridinev}{\@pteridinev[acfhk]}}
\def\@pteridinev[#1]#2{%
\iforigpt \typeout{command `pteridinev' is based on `decaheterov'.}\fi%
\decaheterov[#1]{1==N;3==N;5==N;8==N}{#2}}
\def\pteridinevi{\@ifnextchar[{\@pteridinevi}{\@pteridinevi[acfhk]}}
\def\@pteridinevi[#1]#2{%
\iforigpt \typeout{command `pteridinevi' is based on `decaheterovi'.}\fi%
\decaheterovi[#1]{1==N;3==N;5==N;8==N}{#2}}
%
% **************************
% * nonahetero derivatives *
% *  (vertical type)       *
% **************************
% The following numbering is adopted in this macro. 
%
%          4
%          *  3a(8) 
%     5  *   * _____  3
%       |     |     |
%       |     |     |
%     6  *   * *   *  2
%          *  7a *
%          7 (9) 1
%          ^
%          |
%          the original point
%
%   \nonaheterov[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  aromatic six-membered ring
%           H or []    :  fully saturated form
%           a    :  1,2-double bond      b    :  2,3-double bond
%           c    :  3,3a-double bond     d    :  4,3a-double bond
%           e    :  4,5-double bond      f    :  5,6-double bond
%           g    :  6,7-double bond      h    :  7,7a-double bond
%           i    :  1,7a-double bond     j    :  3a,4a-double bond
%           A    :  aromatic circle (six-membered ring)
%           B    :  aromatic circle (five-membered ring)
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 7)
%
%     ATOMLIST: list of heteroatoms (max 9 atoms)
%
%       for n = 1 to 7
%
%            n         : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%            na        : Hetero atom at 3a or 7b (n=3 or 7)
%                        e.g. 3a==N (or 8==N) for N at 4a-position
%                             7a==N (or 9==N) for N at 8a-position
%
%     SUBSLIST: list of substituents (max 7 substitution positions)
%
%       for n = 1 to 8
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       for 8 (3a position) and 9 (7a position)
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%
%       e.g. 
%        
%        \nonaheterov{1==N}{1==Cl;2==F}
%        \nonaheterov[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%
\def\nonaheterov{\@ifnextchar[{\@nonaheterov}{\@nonaheterov[r]}}
\def\@nonaheterov[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniflag\iniatom%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\ddd{\@memberb}%1
 \or \xdef\ccc{\@memberb}%2
 \or%
   \if\@tmpb a%
     \xdef\jjj{\@memberb}%3a
   \else\ifx\@tmpb\empty%
     \xdef\bbb{\@memberb}%3
   \fi\fi
 \or \xdef\hhh{\@memberb}%4
 \or \xdef\ggg{\@memberb}%5
 \or \xdef\fff{\@memberb}%6
 \or% 
   \if\@tmpb a%
     \xdef\iii{\@memberb}%7a
   \else\ifx\@tmpb\empty%
     \xdef\eee{\@memberb}%7
   \fi\fi
\or \xdef\jjj{\@memberb}%8 (= 3a)
\or \xdef\iii{\@memberb}%9 (= 7a)
\fi}%
 \begin{picture}(1200,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `nonaheterov' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(342,0){\skbondb}% bond between 2 and 3  3 and 2
 \put(342,0){\skbondc}% bond between 1 and 2  4 and 3
 \put(342,0){\skbondd}% bond between 7a and 3a  4 and 4a
 \put(342,0){\skbonde}% bond between 1 and 7a  4a and 8a
 \put(342,0){\skbondhoriz}% bond between 3 and 3a
}%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\skbonda}% bond between 4 and 3a 8 and 8a
 \put(0,0){\skbondc}% bond between 7 and 7a 5 and 4a
 \put(0,0){\skbondf}% bond between 4 and 5 8 and 7
 \put(0,0){\skbondd}% bond between 7 and 6 5 and 6
 \put(0,0){\skbonde}% bond between 5 and 6 6 and 7
}%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 3a and 7a
 \put(0,0){\bondf}% bond between 4 and 5
 \put(0,0){\bondd}% bond between 6 and 7
}%
\else\if\member l\relax%
\else\if\member a\relax%
 \put(342,0){\bondc}% bond between 3 and 4
\else\if\member b\relax%
 \put(342,0){\bondb}% bond between 2 and 3
\else\if\member c\relax%
 \put(342,0){\bondhoriz}% bond between 3 and 3a
\else\if\member d\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,0){\bonda}% bond between 4 and 3a
}
\else\if\member e\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,0){\bondf}% bond between 4 and 5
}%
\else\if\member f\relax%
{\let\eee=\fff \let\fff=\ggg%
 \put(0,0){\bonde}% bond between 5 and 6
}%
\else\if\member g\relax%
{\let\ddd=\eee \let\eee=\fff%
 \put(0,0){\bondd}% bond between 6 and 7
}%
\else\if\member h\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,0){\bondc}% bond between 7 and 7a
}%
\else\if\member i\relax%
{\let\eee=\iii%
 \put(342,0){\bondd}% bond between 1 and 7a
}%
\else\if\member j\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 7a and 3a
}%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}               %circle
\else\if\member B%left aromatic circle 
  \put(342,173){\circle{180}}               %circle 1993/11/20 S.Fujita
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{7a} \def\aay{3a}%
      \if\@@tmpa 1\relax%
        \putratom{304}{68}{\@@tmpb}%       % right type
      \else\if\@@tmpa 2\relax%
        \putratom{402}{120}{\@@tmpb}%      % right type
      \else\if\@@tmpa 3\relax%
        \putratom{402}{253}{\@@tmpb}%      % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putlatom{-60}{120}{\@@tmpb}%      % left type
      \else\if\@@tmpa 6\relax%
        \putlatom{-60}{253}{\@@tmpb}%      % left type
      \else\if\@@tmpa 7\relax%
        \putratom{-38}{68}{\@@tmpb}%       % right type
      \else\if\@@tmpa 8\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 9\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
% hetero atom on 1
%\ifx\aaa\empty\else%
%     \@acliptrue
%     \putratom{311}{356}{\aaa}%  % right type
%\fi
% hetero atom on 1%4
\ifx\ddd\empty\else%
   \@cliptrue% 
   \putratom{311}{-10}{\ddd}%     % right type
\fi%
% hetero atom on 2%3
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{477}{65}{\ccc}%    % right type
\fi%
% hetero atom on 3%2
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{477}{280}{\bbb}%   % right type
\fi%
% hetero atom on 3a%8a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{207}{280}{\jjj}%   % left type
\fi%
}%
% hetero atom on 4%8
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putratom{-31}{356}{\hhh}%   % right type
\fi%
}
% hetero atom on 5%7
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{-135}{280}{\ggg}%  % left type
\fi%
}
% hetero atom on 6
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putlatom{-135}{65}{\fff}%   % left type
\fi
}%
% hetero atom on 7%5
{\let\ddd=\eee%
\ifx\ddd\empty\else%
   \global\@ecliptrue% 
   \putratom{-31}{-10}{\eee}%     % right type
\fi%
}
% hetero atom on 7a%4a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putlatom{207}{65}{\iii}%    % left type
\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(342,0){\setsixringv{#3}{5}{1}{5}{-1}}% %substituents on 1 to 3
{\@clipfalse \if@eclip \@cliptrue \fi%      %substituents on 5 to 7
 \@eclipfalse \if@fclip \@ecliptrue \fi%
 \@fclipfalse \if@gclip \@fcliptrue \fi%
\put(0,0){\setsixringv{#3}{11}{3}{7}{-1}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%    %substituent on 4
\put(0,0){\setsixringv{#3}{-3}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(171,103){\setatombond{#3}{-8}{7}}%    %9 for 7a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(171,303){\setatombond{#3}{-7}{1}}%   %8 for 3a position
}%
\end{picture}\iniatom\iniflag}%             %end of \nonaheterov macro
%
% **********************************
% * nonahetero derivatives         *
% *  (vertical type, inverse type) *
% **********************************
% The following numbering is adopted in this macro. 
%
%          7(10) 1
%          * 7a  *
%     6  *   * *   *  2
%       |     |     |
%       |     |_____|
%     5  *   *        3
%          *  3a(8) 
%          4 
%          ^
%          |
%          the original point
%
%   \nonaheterovi[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  aromatic six-membered ring
%           H or []    :  fully saturated form
%           a    :  1,2-double bond      b    :  2,3-double bond
%           c    :  3,3a-double bond     d    :  4,3a-double bond
%           e    :  4,5-double bond      f    :  5,6-double bond
%           g    :  6,7-double bond      h    :  7,7a-double bond
%           i    :  1,7a-double bond     j    :  3a,4a-double bond
%           A    :  aromatic circle (six-membered ring)
%           B    :  aromatic circle (five-membered ring)
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 7)
%
%     ATOMLIST: list of heteroatoms (max 9 atoms)
%
%       for n = 1 to 7
%
%            n         : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%            na        : Hetero atom at 3a or 7b (n=3 or 7)
%                        e.g. 3a==N (or 8==N) for N at 4a-position
%                             7a==N (or 9==N) for N at 8a-position
%
%     SUBSLIST: list of substituents (max 7 substitution positions)
%
%       for n = 1 to 8
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       for 8 (3a position) and 9 (7a position)
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%
%       e.g. 
%        
%        \nonaheterovi{1==N}{1==Cl;2==F}
%        \nonaheterovi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%
\def\nonaheterovi{\@ifnextchar[{\@nonaheterovi}{\@nonaheterovi[r]}}
\def\@nonaheterovi[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniflag\iniatom%initialize
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\aaa{\@memberb}%1
 \or \xdef\bbb{\@memberb}%2
 \or%
   \if\@tmpb a%
     \xdef\iii{\@memberb}%3a
   \else\ifx\@tmpb\empty%
     \xdef\ccc{\@memberb}%3
   \fi\fi
 \or \xdef\eee{\@memberb}%4
 \or \xdef\fff{\@memberb}%5
 \or \xdef\ggg{\@memberb}%6
 \or% 
   \if\@tmpb a%
     \xdef\jjj{\@memberb}%7a
   \else\ifx\@tmpb\empty%
     \xdef\hhh{\@memberb}%7
   \fi\fi
\or \xdef\iii{\@memberb}%8 (= 3a)
\or \xdef\jjj{\@memberb}%9 (= 7a)
\fi}%
 \begin{picture}(1200,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `nonaheterovi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(342,0){\skbonda}% bond between 1 and 2
 \put(342,0){\skbondb}% bond between 2 and 3
 \put(342,0){\skbonde}% bond between 7a and 3a
 \put(342,0){\skbondf}% bond between 1 and 7a
 \put(342,0){\skbondhorizi}% bond between 3 and 3a
}%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg%
 \let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\skbonda}% bond between 7 and 7a
 \put(0,0){\skbondc}% bond between 4 and 3a
 \put(0,0){\skbondf}% bond between 6 and 7
 \put(0,0){\skbondd}% bond between 4 and 5 
 \put(0,0){\skbonde}% bond between 5 and 6 
}%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
{\let\aaa=\hhh \let\ddd=\eee\let\eee=\fff\let\fff=\ggg
 \let\ccc=\iii\let\bbb=\jjj
 \put(0,0){\bondb}% bond between 3a and 7a
 \put(0,0){\bondf}% bond between 6 and 7
 \put(0,0){\bondd}% bond between 4 and 5
}%
\else\if\member l\relax%
\else\if\member a\relax%
 \put(342,0){\bonda}% bond between 1 and 2
\else\if\member b\relax%
 \put(342,0){\bondb}% bond between 2 and 3
\else\if\member c\relax%
 \put(342,0){\bondhorizi}% bond between 3 and 3a
\else\if\member d\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,0){\bondc}% bond between 4 and 3a
}%
\else\if\member e\relax%
{\let\ddd=\eee\let\eee=\fff%
 \put(0,0){\bondd}% bond between 4 and 5
}%
%{\let\eee=\iii%
% \put(342,0){\bondd}% bond between 4 and 5
%}%
\else\if\member f\relax%
{\let\eee=\fff \let\fff=\ggg%
 \put(0,0){\bonde}% bond between 5 and 6
}%
\else\if\member g\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,0){\bondf}% bond between 7 and 6
}%
\else\if\member h\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,0){\bonda}% bond between 7 and 7a
}%
\else\if\member i\relax%
{\let\fff=\jjj%
 \put(342,0){\bondf}% bond between 1 and 7a
}%
\else\if\member j\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,0){\bondb}% bond between 7a and 3a
}%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}%               %circle
\else\if\member B%left aromatic circle 
  \put(342,233){\circle{180}}               %circle 1993/11/20 S.Fujita
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{7a} \def\aay{3a}%
      \if\@@tmpa 1\relax%
        \putratom{304}{282}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{402}{120}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{402}{253}{\@@tmpb}%      % right type
      \else\if\@@tmpa 7\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 6\relax%
        \putlatom{-60}{120}{\@@tmpb}%      % left type
      \else\if\@@tmpa 5\relax%
        \putlatom{-60}{253}{\@@tmpb}%      % left type
      \else\if\@@tmpa 4\relax%
        \putratom{-38}{68}{\@@tmpb}%       % right type
      \else\if\@@tmpa 9\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 8\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
% hetero atom on 1
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{311}{356}{\aaa}%  % right type
\fi%
% hetero atom on 1%4
%\ifx\ddd\empty\else%
%   \@cliptrue% 
%   \putratom{311}{-10}{\ddd}%     % right type
%\fi
% hetero atom on 3
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{477}{65}{\ccc}%    % right type
\fi%
% hetero atom on 2
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{477}{280}{\bbb}%   % right type
\fi%
% hetero atom on 7a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{207}{280}{\jjj}%   % left type
\fi%
}%
% hetero atom on 7
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putratom{-31}{356}{\hhh}%   % right type
\fi%
}%
% hetero atom on 6
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{-135}{280}{\ggg}%  % left type
\fi%
}%
% hetero atom on 5
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putlatom{-135}{65}{\fff}%   % left type
\fi%
}
% hetero atom on 4
{\let\ddd=\eee%
\ifx\ddd\empty\else%
   \global\@ecliptrue% 
   \putratom{-31}{-10}{\eee}%     % right type
\fi%
}
% hetero atom on 3a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putlatom{207}{65}{\iii}%    % left type
\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(342,0){\setsixringv{#3}{0}{0}{4}{0}}% %substituents on 1 to 3
{\@clipfalse \if@eclip \@cliptrue \fi%     %substituents on 4 to 6
 \@eclipfalse \if@fclip \@ecliptrue \fi%
 \@fclipfalse \if@gclip \@fcliptrue \fi%
\put(0,0){\setsixringv{#3}{0}{3}{7}{0}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%   %substituent on 7
\put(0,0){\setsixringv{#3}{-6}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(171,103){\setatombond{#3}{-7}{7}}%   %8 for 3a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(171,303){\setatombond{#3}{-8}{1}}%  %9 for 7a position
}%
\end{picture}\iniatom\iniflag}%            %end of \nonaheterovi macro
%
% **********************************************************
% * heterocycles having fused six- and five-membered rings *
% *  (vertical type)                                       *
% **********************************************************
%
%   N-heterocycles:
%
%   \indolev[BONDLIST]{SUBSLIST}
%   \indolevi[BONDLIST]{SUBSLIST}
%
%   \isoindolev[BONDLIST]{SUBSLIST}
%   \isoindolevi[BONDLIST]{SUBSLIST}
%
%   \indolizinev[BONDLIST]{SUBSLIST}
%   \indolizinevi[BONDLIST]{SUBSLIST}
%          (different from the IUPAC numbering)
%
%   \purinev[BONDLIST]{SUBSLIST}
%   \purinevi[BONDLIST]{SUBSLIST}
%          (different from the IUPAC numbering)
%
%   O-heterocycles:
%
%   \benzofuranev[BONDLIST]{SUBSLIST}
%   \benzofuranevi[BONDLIST]{SUBSLIST}
%
%   \isobenzofuranevi[BONDLIST]{SUBSLIST}
%
%   \benzoxazolev[BONDLIST]{SUBSLIST}
%   \benzoxazolevi[BONDLIST]{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  aromatic six-membered ring
%           H or []    :  fully saturated form
%           a    :  1,2-double bond      b    :  2,3-double bond
%           c    :  3,3a-double bond     d    :  4,3a-double bond
%           e    :  4,5-double bond      f    :  5,6-double bond
%           g    :  6,7-double bond      h    :  7,7a-double bond
%           i    :  1,7a-double bond     j    :  3a,4a-double bond
%           A    :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 7)
%
%     SUBSLIST: list of substituents (max 7 substitution positions)
%
%       for n = 1 to 8
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       for 8 (3a position) and 9 (7a position)
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%
%       e.g. 
%        
%        \indolev{1==N}{1==Cl;2==F}
%        \indolev[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%
\def\purinev{\@ifnextchar[{\@purinev}{\@purinev[ra]}}
\def\@purinev[#1]#2{%
\iforigpt \typeout{command `purinev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{1==N;3==N;5==N;7==N}{#2}}
\def\purinevi{\@ifnextchar[{\@purinevi}{\@purinevi[ra]}}
\def\@purinevi[#1]#2{%
\iforigpt \typeout{command `purinevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{1==N;3==N;5==N;7==N}{#2}}
%
\def\indolev{\@ifnextchar[{\@indolev}{\@indolev[rb]}}
\def\@indolev[#1]#2{%
\iforigpt \typeout{command `indolev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{1==N}{#2}}
\def\indolevi{\@ifnextchar[{\@indolevi}{\@indolevi[rb]}}
\def\@indolevi[#1]#2{%
\iforigpt \typeout{command `indolevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{1==N}{#2}}
%
\def\indolizinev{\@ifnextchar[{\@indolizinev}{\@indolizinev[aceg]}}
\def\@indolizinev[#1]#2{%
\iforigpt \typeout{command `indolizinev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{7a==N}{#2}}
\def\indolizinevi{\@ifnextchar[{\@indolizinevi}{\@indolizinevi[aceg]}}
\def\@indolizinevi[#1]#2{%
\iforigpt \typeout{command `indolizinevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{7a==N}{#2}}
%
\def\isoindolev{\@ifnextchar[{\@isoindolev}{\@isoindolev[cegi]}}
\def\@isoindolev[#1]#2{%
\iforigpt \typeout{command `isoindolev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{2==N}{#2}}
\def\isoindolevi{\@ifnextchar[{\@isoindolevi}{\@isoindolevi[cegi]}}
\def\@isoindolevi[#1]#2{%
\iforigpt \typeout{command `isoindolevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{2==N}{#2}}
%
\def\benzofuranev{\@ifnextchar[{\@benzofuranev}{\@benzofuranev[rb]}}
\def\@benzofuranev[#1]#2{%
\iforigpt \typeout{command `benzofuranev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{1==O}{#2}}
\def\benzofuranevi{\@ifnextchar[{\@benzofuranevi}{\@benzofuranevi[rb]}}
\def\@benzofuranevi[#1]#2{%
\iforigpt \typeout{command `benzofuranevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{1==O}{#2}}
%
\def\isobenzofuranev{\@ifnextchar[{\@isobenzofuranev}%
 {\@isobenzofuranev[cegi]}}
\def\@isobenzofuranev[#1]#2{%
\iforigpt \typeout{command `isobenzofuranev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{2==O}{#2}}
\def\isobenzofuranevi{\@ifnextchar[{\@isobenzofuranevi}%
 {\@isobenzofuranevi[cegi]}}
\def\@isobenzofuranevi[#1]#2{%
\iforigpt \typeout{command `isobenzofuranevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{2==O}{#2}}
%
\def\benzoxazolev{\@ifnextchar[{\@benzoxazolev}{\@benzoxazolev[rb]}}
\def\@benzoxazolev[#1]#2{%
\iforigpt \typeout{command `benzoxazolev' is based on `nonaheterov'.}\fi%
\nonaheterov[#1]{1==O;3==N}{#2}}
\def\benzoxazolevi{\@ifnextchar[{\@benzoxazolevi}{\@benzoxazolevi[rb]}}
\def\@benzoxazolevi[#1]#2{%
\iforigpt \typeout{command `benzoxazolevi' is based on `nonaheterovi'.}\fi%
\nonaheterovi[#1]{1==O;3==N}{#2}}
%
% **********************
% * six-membered unit  *
% *  (vertical type)   *
% **********************
% This macro is a six-membered fragment that can be fused to another 
% ring structure to produce a new ring system. The following 
% numbering is adopted in this macro. 
%
%          1
%          *  
%     6  *   *  2
%       |     |
%       |     |
%     5  *   *  3
%          *
%          4 <===== the original point
%
%   \sixunitv[BONDLIST]{ATOMLIST}{SUBSLIST}{OMIT}
%  
%     BONDLIST = 
%
%           none       :  fully saturated
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,6-double bond
%           f          :  6,1-double bond
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 6 atoms)
%
%       for n = 1 to 6
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position, 
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 6 substitution positions)
%
%       for n = 1 to 6 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%     OMIT:  one bond omitted (a, b, c, d, e, or f)
%
%       e.g. 
%        
%        \sixhunitv{1==N}{1==Cl;2==F}{e}
%
\def\sixunitv{\@ifnextchar[{\@sixunitv}{\@sixunitv[r]}}
\def\@sixunitv[#1]#2#3#4{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniatom\iniflag%initialize%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\aaa{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\ddd{\@memberb}%
 \or \xdef\eee{\@memberb}%
 \or \xdef\fff{\@memberb}%
\fi}%
 \begin{picture}(800,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `sixunitv' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
% changed OMIT into a list 1993/11/21 by Shinsaku Fujita
{\resetbdsw%
\@tfor\memBer:=#4\do{%
\if\memBer a\relax\gdef\@aaa{}\fi%
\if\memBer b\relax\gdef\@bbb{}\fi%
\if\memBer c\relax\gdef\@ccc{}\fi%
\if\memBer d\relax\gdef\@ddd{}\fi%
\if\memBer e\relax\gdef\@eee{}\fi%
\if\memBer f\relax\gdef\@fff{}\fi%
}%
\if\@aaa a\relax\skbonda\fi% bond between 1 and 2
\if\@bbb b\relax\skbondb\fi% bond between 2 and 3
\if\@ccc c\relax\skbondc\fi% bond between 3 and 4
\if\@ddd d\relax\skbondd\fi% bond between 4 and 5
\if\@eee e\relax\skbonde\fi% bond between 5 and 6
\if\@fff f\relax\skbondf\fi% bond between 6 and 1
}%
% old
%\ifx#4a\relax\else%
% \skbonda% bond between 1 and 2
%\fi%
%\ifx#4f\relax\else%
% \skbondf% bond between 1 and 6
%\fi%
%\ifx#4c\relax\else%
% \skbondc% bond between 4 and 3
%\fi%
%\ifx#4d\relax\else%
% \skbondd% bond between 4 and 5
%\fi%
%\ifx#4b\relax\else%
% \skbondb% bond between 3 and 2
%\fi%
%\ifx#4e\relax\else%
% \skbonde% bond between 5 and 6
%\fi%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
\else\if\member l\relax%
\else\if\member a\relax% 
 \ifx#4a\relax\else%
  \bonda%
 \fi%
\else\if\member b\relax% 
 \ifx#4b\relax\else%
   \bondb%
 \fi%
\else\if\member c\relax%
 \ifx#4c\relax\else%
   \bondc%
 \fi%
\else\if\member d\relax%
 \ifx#4d\relax\else%
   \bondd%
 \fi%
\else\if\member e\relax%
 \ifx#4e\relax\else%
   \bonde%
 \fi%
\else\if\member f\relax%
 \ifx#4f\relax\else%
   \bondf%
 \fi%
\else\if\member A%left aromatic circle 
  \put(0,203){\circle{240}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 1\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{253}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-38}{68}{\@@tmpb}%       % right type
      \fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue% 
   \putratom{-31}{-10}{\ddd}%  % right type
\fi%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{-31}{356}{\aaa}%  % right type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\bbb}% % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\ccc}%  % left type
\fi%
\setsixringv{#3}{0}{0}{7}{0}%
\end{picture}\iniatom\iniflag}%     %end of \sixunitv macro
%
% **********************
% * five-membered unit *
% *  (vertical type)   *
% **********************
% This macro is a five-membered fragment that can be fused to another 
% ring structure to produce a new ring system. The following 
% numbering is adopted in this macro. 
%
%     4 _______ 3
%       |     |
%       |     |
%     5  *   *  2
%          *
%          1 <===== the original point
%
%
%   \fiveunitv[BONDLIST]{ATOMLIST}{SUBSLIST}{OMIT}
%  
%     BONDLIST: list of inner double bonds 
%
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,1-double bond
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 5 atoms)
%
%       for n = 1 to 5
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 5 substitution positions)
%
%       for n = 1 to 5 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%     OMIT:  one bond omitted (a, b, c, d, e, or f)
%
%       e.g. 
%        
%        \fiveunitv{1==N}{1==H;2==F}{a}
%
\def\fiveunitv{\@ifnextchar[{\@fiveunitv}{\@fiveunitv[r]}}
\def\@fiveunitv[#1]#2#3#4{%
\iniatom\iniflag%initialize
%\def\aaa{}\def\bbb{}\def\ccc{}\def\ddd{}\def\eee{}\def\fff{}%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\ddd{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\fff{\@memberb}%
 \or \xdef\eee{\@memberb}%
\fi}%
 \begin{picture}(800,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveunitv' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
% changed OMIT to a list 1993/11/21 by Shinsaku Fujita
{\resetbdsw%
\@tfor\memBer:=#4\do{%
\if\memBer a\relax\gdef\@aaa{}\fi%
\if\memBer b\relax\gdef\@bbb{}\fi%
\if\memBer c\relax\gdef\@ccc{}\fi%
\if\memBer d\relax\gdef\@ddd{}\fi%
\if\memBer e\relax\gdef\@eee{}\fi%
%\if\memBer f\relax\gdef\@fff{}\fi%
}%
\if\@aaa a\relax\skbondc\fi% bond between 1 and 2
\if\@bbb b\relax\skbondb\fi% bond between 2 and 3
\if\@ccc c\relax\skbondhoriz\fi% bond between 3 and 4
\if\@ddd d\relax\skbonde\fi% bond between 4 and 5
\if\@eee e\relax\skbondd\fi% bond between 5 and 6
%\if\@fff f\relax\skbondf\fi% bond between 6 and 1
}%
% old
%\ifx#4a\relax\else%
% \skbondc%bond between 1 and 2
%\fi%
%\ifx#4e\relax\else%
% \skbondd%bond between 1 and 5
%\fi%
%\ifx#4b\relax\else%
%  \skbondb%bond between 2 to 3
%\fi%
%\ifx#4d\relax\else%
% \skbonde%bond between 5 and 4
%\fi%
%\ifx#4c\relax\else%
% \skbondhoriz%bond between 4 and 3
%\fi%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else\if\member a\relax%
 \ifx#4a\relax\else%
   \bondc%
 \fi%
\else\if\member b\relax%
 \ifx#4b\relax\else%
  \bondb%
 \fi%
\else\if\member c\relax%
 \ifx#4c\relax\else%
   \bondhoriz%
 \fi%
\else\if\member d\relax%
 \ifx#4d\relax\else%
  \bonde%
 \fi%
\else\if\member e\relax%
 \ifx#4e\relax\else%
  \bondd%
 \fi%
\else \expandafter\twoch@@r\member{}{}%     %plus or minus charges
      \if\@@tmpa 1\relax%
        \putratom{-38}{68}{\@@tmpb}%        % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{120}{\@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{233}{\@@tmpb}%        % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-60}{233}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-60}{120}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue% 
   \putratom{-31}{-10}{\ddd}%    % right type at 1
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type at 3
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type at 4
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type at 2
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type at 5 
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringv{#3}{5}{1}{5}{-1}%   % for 1 to 3
\setsixringv{#3}{10}{4}{7}{-1}%  % for 4 to 5
\end{picture}\iniatom\iniflag}               %end of \fiveunitv macro
%
% ************************************
% * five-membered unit               *
% *  (vertical type, inverse type)   *
% ************************************
% This macro is a five-membered fragment that can be fused to another 
% ring structure to produce a new ring system. The following 
% numbering is adopted in this macro. 
%
%          1
%          * 
%     6  *   *  2
%       |     |
%       |_____|
%     4         3
%          *
%        (0,0) <===== the original point
%
%   \fiveunitvi[BONDLIST]{ATOMLIST}{SUBSLIST}{OMIT}
%  
%     BONDLIST: list of inner double bonds 
%
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           d          :  4,5-double bond
%           e          :  5,1-double bond
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 5 atoms)
%
%       for n = 1 to 5
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 5 substitution positions)
%
%       for n = 1 to 5 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%     OMIT:  one bond omitted (a, b, c, d, e, or f)
%
%       e.g. 
%        
%        \fiveunitvi{1==N}{1==H;2==F}{a}
%
\def\fiveunitvi{\@ifnextchar[{\@fiveunitvi}{\@fiveunitvi[r]}}
\def\@fiveunitvi[#1]#2#3#4{%
\iniatom\iniflag%initialize
%\def\aaa{}\def\bbb{}\def\ccc{}\def\ddd{}\def\eee{}\def\fff{}%
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\aaa{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\eee{\@memberb}%
 \or \xdef\fff{\@memberb}%
\fi}%
 \begin{picture}(800,880)(-\shiftii,-\shifti)%
  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveunitvi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
% changed OMIT to a list 1993/11/21 by Shinsaku Fujita
{\resetbdsw%
\@tfor\memBer:=#4\do{%
\if\memBer a\relax\gdef\@aaa{}\fi%
\if\memBer b\relax\gdef\@bbb{}\fi%
\if\memBer c\relax\gdef\@ccc{}\fi%
\if\memBer d\relax\gdef\@ddd{}\fi%
\if\memBer e\relax\gdef\@eee{}\fi%
%\if\memBer f\relax\gdef\@fff{}\fi%
}%
\if\@aaa a\relax\skbonda\fi% bond between 1 and 2
\if\@bbb b\relax\skbondb\fi% bond between 2 and 3
\if\@ccc c\relax\skbondhorizi\fi% bond between 3 and 4
\if\@ddd d\relax\skbonde\fi% bond between 4 and 5
\if\@eee e\relax\skbondf\fi% bond between 5 and 6
%\if\@fff f\relax\skbondf\fi% bond between 6 and 1
}%
% old
%\ifx#4a\relax\else%
% \skbonda%bond between 1 and 2
%\fi%
%\ifx#4e\relax\else%
% \skbondf%bond between 1 and 5
%\fi%
%\ifx#4b\relax\else%
%  \skbondb%bond between 2 to 3
%\fi%
%\ifx#4d\relax\else%
% \skbonde%bond between 5 and 4
%\fi%
%\ifx#4c\relax\else%
% \skbondhorizi%bond between 4 and 3
%\fi%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else\if\member a\relax%
 \ifx#4a\relax\else%
   \bonda%
 \fi%
\else\if\member b\relax%
 \ifx#4b\relax\else%
  \bondb%
 \fi%
\else\if\member c\relax%
 \ifx#4c\relax\else%
   \bondhorizi%
 \fi%
\else\if\member d\relax%
 \ifx#4d\relax\else%
  \bonde%
 \fi%
\else\if\member e\relax%
 \ifx#4e\relax\else%
  \bondf%
 \fi%
\else \expandafter\twoch@@r\member{}{}%     %plus or minus charges
      \if\@@tmpa 1\relax%
        \putratom{-38}{282}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{233}{\@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{120}{\@@tmpb}%        % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-60}{120}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{-60}{233}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putratom{-31}{356}{\aaa}%  % right type  at 1
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{135}{280}{\bbb}%  % right type at 3
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type at 4
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{135}{65}{\ccc}%   % right type at 2
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type at 5 
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringv{#3}{0}{0}{4}{0}%  % for 1 to 3
\setsixringv{#3}{1}{4}{7}{0}%  % for 4 to 5
\end{picture}\iniatom\iniflag}%               %end of \fiveunitvi macro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
% horizontal bond %
%%%%%%%%%%%%%%%%%%%
% horizontal inner bond for four-membered rings
\def\bondshoriz{%
 \begin{picture}(200,300)(0,0)
  \ifx\fff\empty%
    \ifx\bbb\empty%
     \put(-138,270){\line(1,0){134}}%double bond 4-3
    \else%
     \put(-138,270){\line(1,0){115}}%double bond 4-3
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(-120,270){\line(1,0){115}}%double bond 4-3
    \else%
     \put(-120,270){\line(1,0){96}}%double bond 4-3
    \fi%
  \fi\end{picture}}%
% horizontal inner bond for four-membered rings (inverse type) 
\def\bondshorizi{%
 \begin{picture}(200,300)(0,0)
  \ifx\eee\empty%
    \ifx\ccc\empty%
     \put(-138,136){\line(1,0){134}}%double bond 4-3
    \else%%
     \put(-138,136){\line(1,0){115}}%double bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(-120,136){\line(1,0){115}}%double bond 4-3
    \else%
     \put(-120,136){\line(1,0){96}}%double bond 4-3
    \fi%
  \fi\end{picture}}%
%%%
%horizontal bond for four-membered rings
\def\skbondshoriz{%
 \begin{picture}(200,300)(0,0)
  \ifx\fff\empty%
    \ifx\bbb\empty%
     \put(-171,303){\line(1,0){200}}%bond 4-3
    \else%
     \put(-171,303){\line(1,0){158}}%bond 4-3
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(29,303){\line(-1,0){158}}%bond 4-3
    \else%
     \put(-129,303){\line(1,0){116}}%bond 4-3
    \fi%
  \fi\end{picture}}%
%horizontal bond for five-membered rings (inverse type)
\def\skbondshorizi{%
 \begin{picture}(200,300)(0,0)
  \ifx\eee\empty%
    \ifx\ccc\empty%
     \put(-171,103){\line(1,0){200}}%bond 4-3
    \else%
     \put(-171,103){\line(1,0){158}}%bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(29,103){\line(-1,0){158}}%bond 4-3
    \else%
     \put(-129,103){\line(1,0){116}}%bond 4-3
    \fi%
  \fi\end{picture}}%
% **************************
% * fourhetero derivatives *
% *  (vertical type)       *
% **************************
% The following numbering is adopted in this macro. 
%
%          c
%     4  _____  3
%    d  |     |  b
%       |     |
%     1  -----  2<===== the original point
%          a
%
%   \fourhetero[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST: list of inner double bonds 
%
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  4,3-double bond
%           e          :  4,1-double bond
%
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%
%     ATOMLIST: list of heteroatoms (max 5 atoms)
%
%       for n = 1 to 4
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 5 substitution positions)
%
%       for n = 1 to 4 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \fourhetero{1==N}{1==H;2==F}
%        \fourhetero[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \fourhetero[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\fourhetero{\@ifnextchar[{\@fourhetero}{\@fourhetero[r]}}
\def\@fourhetero[#1]#2#3{%
\iniatom\iniflag%initialize
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\eee{\@memberb}%
 \or \xdef\ccc{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\fff{\@memberb}%
\fi}%
%
%\begin{picture}(800,880)(-\shiftii,-\shifti)%
%  \iforigpt\put(-\shiftii,-\shifti){\circle*{50}}%
%           \put(-\noshift,-\noshift){\circle{50}}% 
%   \typeout{command `fourhetero' origin: %
%    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
% Correction of the zero point: S. Fujita 1993/11/19
%   x axis: 400 + 171 = 571
%   y axis: 240 - 103 = 137
%
\begin{picture}(800,880)(-571,-137)%
  \iforigpt\put(-571,-137){\circle*{50}}%
           \put(-171,103){\circle{50}}% 
   \typeout{command `fourhetero' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
%\skbondc%bond between 1 and 2
%\skbondd%bond between 1 and 5
\put(-142,0){\skbondb}%bond between 2 to 3
\put(0,0){\skbonde}%bond between 1 and 4
\put(0,0){\skbondshoriz}%bond between 4 and 3
\put(0,0){\skbondshorizi}%bond between 1 and 2
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else\if\member a\relax \put(0,0){\bondshorizi}%
\else\if\member b\relax \put(-142,0){\bondb}%
\else\if\member c\relax \put(0,0){\bondshoriz}%
\else\if\member d\relax \put(0,0){\bonde}%
\else \expandafter\twoch@@r\member{}{}%     %plus or minus charges
      \if\@@tmpa 1\relax%
        \putlatom{-200}{120}{\scriptsize \@@tmpb}%       % right type
      \else\if\@@tmpa 2\relax%
        \putratom{60}{120}{\scriptsize \@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax%
        \putratom{60}{233}{\scriptsize \@@tmpb}%        % right type
      \else\if\@@tmpa 4\relax%
        \putlatom{-200}{233}{\scriptsize \@@tmpb}%       % right type
      \fi\fi\fi%
\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{-7}{280}{\bbb}%  % right type at 3
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{280}{\fff}% % left type at 4
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{-7}{65}{\ccc}%   % right type at 2
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putlatom{-135}{65}{\eee}%  % left type at 5 
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\put(-142,0){\setsixringv{#3}{5}{1}{4}{-1}}% for 2 to 3
\put(0,0){\setsixringv{#3}{4}{4}{6}{0}}% for 1
\put(0,0){\setsixringv{#3}{2}{5}{7}{0}}% for 4
\end{picture}\iniatom\iniflag}%               %end of \fourhetero macro
%
% **********************
% * bonds for triangle *
% **********************
% fff 3--------2bbb
%      `     /
%   ddd  `1/ <===== the original point
% bond between 1 and 2
 \def\bondtria{%
  \ifx\ddd\empty%
   \ifx\bbb\empty%
    \put(-6,42){\line(3,5){72}}%           %double bond 1-2
   \else%
    \put(-6,42){\line(3,5){60}}%           %double bond 1-2
   \fi%
  \else%
   \ifx\bbb\empty%
    \put(6,62){\line(3,5){60}}%            %double bond 1-2
   \else%
    \put(10,32){\line(3,5){60}}%           %double bond 1-2
   \fi%                                    
  \fi%
}%
% bond between 1 and 3
 \def\bondtrib{%
  \ifx\ddd\empty%
   \ifx\fff\empty%
    \put(6,42){\line(-3,5){72}}%           %double bond 1-3
   \else%
    \put(6,42){\line(-3,5){60}}%           %double bond 1-3
   \fi%
  \else%
   \ifx\fff\empty%
    \put(-6,62){\line(-3,5){60}}%          %double bond 1-2
   \else%
    \put(6,42){\line(-3,5){60}}%           %double bond 1-2
   \fi%                                    
  \fi%
 }%
%bond between 1 and 2
\def\skbondtria{%
 \begin{picture}(200,200)(0,0)
  \ifx\ddd\empty%
    \ifx\bbb\empty%
     \put(0,0){\line(3,5){103}}%           %bond 1-2
    \else%
     \put(0,0){\line(3,5){80}}%            %bond 1-2
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(103,171){\line(-3,-5){80}}%      %bond 1-2
    \else%
     \put(35,21){\line(3,5){60}}%          %bond 1-2
    \fi%
  \fi\end{picture}}%
%bond between 1 and 3
\def\skbondtrib{%
 \begin{picture}(200,200)(0,0)
  \ifx\ddd\empty%
    \ifx\fff\empty%
     \put(0,0){\line(-3,5){103}}%         %bond 1-3
    \else%
     \put(0,0){\line(-3,5){80}}%          %bond 1-3
    \fi%
  \else%
%    \ifx\eee\empty%bug fix 1993/11/19
    \ifx\fff\empty%
     \put(-103,171){\line(3,-5){80}}%     %bond 1-3
    \else%
     \put(-35,21){\line(-3,5){60}}%       %bond 1-3
    \fi%
  \fi\end{picture}}%
%
% ****************************
% * thereehetero derivatives *
% *  (vertical type)         *
% ****************************
% The following numbering is adopted in this macro. 
%
%         b
%     3--------2
%    c `     / a
%        `1/ <===== the original point
%
%
%   \threehetero[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST = 
%
%           none       :  saturated 
%           a          :  1,2-double bond
%           b          :  2,3-double bond
%           c          :  3,1-double bond
%           A          :  aromatic circle 
%           {n+}       :  plus at the n-hetero atom (n = 1 to 3)
%                      :  n=4 -- outer plus at 1 position
%                      :  n=5 -- outer plus at 2 position
%                      :  n=6 -- outer plus at 3 position
%           {0+}       :  plus at the center of a cyclopropane ring
%
%     ATOMLIST: list of heteroatoms (max 3 atoms)
%
%       for n = 1 to 3
%
%           n          : Hetero atom, e.g. N, O, etc. at n-position, 
%                        e.g. 1==N for N at 1-position
%
%     SUBSLIST: list of substituents (max 3 substitution positions)
%
%       for n = 1 to 3 
%
%           nD         :  exocyclic double bond at n-atom
%           n or nS    :  exocyclic single bond at n-atom
%           nA         :  alpha single bond at n-atom
%           nB         :  beta single bond at n-atom
%           nSA        :  alpha single bond at n-atom (boldface)
%           nSB        :  beta single bond at n-atom (dotted line)
%           nSa        :  alpha (not specified) single bond at n-atom
%           nSb        :  beta (not specified) single bond at n-atom
%
%       e.g. 
%        
%        \threehetero{1==N}{1==Cl;2==F}
%        \threehetero[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \threehetero{1==N}{1D==O;4SA==MeO;4SB==OMe;5==Cl;6==Cl}
%
\def\threehetero{\@ifnextchar[{\@threehetero}{\@threehetero[r]}}
\def\@threehetero[#1]#2#3{%
%%%%%%%%%%%%%%%%%%%%%%%%%%
% treatment of atom list %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\iniatom\iniflag%initialize
\@forsemicol\member:=#2\do{%
\expandafter\@m@mb@r\member;\relax%
\expandafter\twoch@r\@membera{}%
\ifcase\@tmpa%
 \or \xdef\ddd{\@memberb}%
 \or \xdef\bbb{\@memberb}%
 \or \xdef\fff{\@memberb}%
\fi}%
%
%\begin{picture}(800,880)(-\shiftii,-\shifti)%
%  \iforigpt \put(-\shiftii,-\shifti){\circle*{50}}%
%           \put(-\noshift,-\noshift){\circle{50}}% 
%  adjust x,y-coodinate by S. Fujita 1993/11/20
\begin{picture}(800,880)(-468,-240)%
  \iforigpt \put(-468,-240){\circle*{50}}%
           \put(-68,0){\circle{50}}% 
   \typeout{command `threeheterov' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shifti)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
 \put(-68,0){\skbondtria}% bond between 1 and 2
 \put(-68,0){\skbondtrib}% bond between 1 and 3
 \put(0,-132){\skbondshoriz}%bond between 2 and 3
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
\else\if\member a\relax\put(-68,0){\bondtria}%
\else\if\member b\relax\put(0,-126){\bondshoriz}%
\else\if\member c\relax\put(-68,0){\bondtrib}%
\else\if\member A\relax% aromatic circle 
  \put(-70,108){\circle{100}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 0\relax%
        \putratom{-94}{92}{\scriptsize\@@tmpb}%      % right type
      \else\if\@@tmpa 1\relax%
        \putratom{-94}{60}{\scriptsize\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{-52}{120}{\scriptsize\@@tmpb}%     % right type
      \else\if\@@tmpa 3\relax%
        \putratom{-126}{126}{\scriptsize\@@tmpb}%    % right type
      \else\if\@@tmpa 4\relax%
        \putratom{-30}{-20}{\scriptsize\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putratom{52}{110}{\scriptsize\@@tmpb}%      % right type
      \else\if\@@tmpa 6\relax%
        \putratom{-250}{110}{\scriptsize\@@tmpb}%    % right type
      \fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi%\fi\fi\fi\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{-99}{-22}{\ddd}% right type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putratom{0}{148}{\bbb}% right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{-135}{148}{\fff}% left type
\fi%
\put(-68,0){\setsixringv{#3}{3}{3}{5}{0}}%subst 1
\put(-142,-132){\setsixringv{#3}{0}{1}{3}{0}}%subst 2
\put(0,-132){\setsixringv{#3}{3}{5}{7}{0}}%subst 3
\end{picture}%
\iniatom\iniflag}%     %end of \threehetero macro

