% hetaromh.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{hetaromh}
\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]}
%
% **********************************
% * hetaromh.sty: list of commands *
% **********************************
%
% <Conventions for bond-setting>
%
%     \hbonda
%     \hbondf
%     \hbondb
%     \hbondc
%     \hbondd
%     \hbonde
%     \hbondvert
%     \hbondverti
%
%     \hskbonda
%     \hskbondf
%     \hskbondc
%     \hskbondd
%     \hskbondb
%     \hskbonde
%     \hskbondvert
%     \hskbondverti
%
%  <Six-membered heterocycles (horizontal)>
%
%    Basic Macros
%
%     \sixheteroh                \@sixheteroh
%     \sixheterohi               \@sixheterohi
%
%    Application Macros
%
%     \pyridineh                 \@pyridineh
%     \pyridinehi                \@pyridinehi
%     \pyrazineh                 \@pyrazineh
%     \pyrimidineh               \@pyrimidineh
%     \pyrimidinehi              \@pyrimidinehi
%     \pyridazineh               \@pyridazineh
%     \pyridazinehi              \@pyridazinehi
%     \triazineh                 \@triazineh
%     \triazinehi                \@triazinehi
%
%  <Five-membered heterocycles (horizontal)>
%
%    Basic Macros
%
%     \fiveheteroh               \@fiveheteroh
%     \fiveheterohi              \@fiveheterohi
%
%    Application Macros
%
%     \pyrroleh                  \@pyrroleh
%     \pyrazoleh                 \@pyrazoleh
%     \imidazoleh                \@imidazoleh
%     \isoxazoleh                \@isoxazoleh
%     \oxazoleh                  \@oxazoleh
%     \pyrrolehi                 \@pyrrolehi
%     \pyrazolehi                \@pyrazolehi
%     \imidazolehi               \@imidazolehi
%     \isoxazolehi               \@isoxazolehi
%     \oxazolehi                 \@oxazolehi
%
%  <Six-Six fused heterocycles (horizontal)>
%
%    Basic Macros
%
%     \decaheteroh               \@decaheteroh
%     \decaheterohi              \@decaheterohi
%
%    Application Macros
%
%     \quinolineh                \@quinolineh
%     \quinolinehi               \@quinolinehi
%     \isoquinolineh             \@isoquinolineh
%     \isoquinolinehi            \@isoquinolinehi
%     \quinoxalineh              \@quinoxalineh
%     \quinazolineh              \@quinazolineh
%     \quinazolinehi             \@quinazolinehi
%     \cinnolineh                \@cinnolineh
%     \cinnolinehi               \@cinnolinehi
%     \pteridineh                \@pteridineh
%     \pteridinehi               \@pteridinehi
%
%  <Six-Five fused heterocycles (horizontal)>
%
%    Basic Macros
%
%     \nonaheteroh               \@nonaheteroh
%     \nonaheterohi              \@nonaheterohi
%
%    Application Macros
%
%     \purineh                   \@purineh
%     \purinehi                  \@purinehi
%     \indoleh                   \@indoleh
%     \indolehi                  \@indolehi
%     \indolizineh               \@indolizineh
%     \indolizinehi              \@indolizinehi
%     \isoindoleh                \@isoindoleh
%     \isoindolehi               \@isoindolehi
%     \benzofuraneh              \@benzofuraneh
%     \benzofuranehi             \@benzofuranehi
%     \isobenzofuraneh           \@isobenzofuraneh
%     \isobenzofuranehi          \@isobenzofuranehi
%     \benzoxazoleh              \@benzoxazoleh
%     \benzoxazolehi             \@benzoxazolehi
%
%   <Building units>
%
%     \sixunith                  \@sixunith
%     \fiveunith                 \@fiveunith
%     \fiveunithi                \@fiveunithi
%
% *************************
% * 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. 
%
%                                   b
%                          (bbb) 2      3  (ccc)
%                            a    -----    c
%                               *       *
%   the original point ===> 1 * (aaa)     * 4  (ddd)
%          (0,0)                *       *  c
%                            f    -----
%                          (fff) 6      5  (eee)
%                                   e
%
% bond between 1 and 2
\def\hbonda{%
  \ifx\aaa\empty%
   \ifx\bbb\empty%
     \put(42,6){\line(3,5){78}}%           %double bond 1-2
   \else%
     \put(42,6){\line(3,5){62}}%           %double bond 1-2
   \fi%
  \else%
   \ifx\bbb\empty%
     \put(57,36){\line(3,5){62}}%          %double bond 1-2
   \else%
     \put(57,36){\line(3,5){62}}%          %double bond 1-2
   \fi\fi}%
% bond between 1 and 6
\def\hbondf{%
  \ifx\aaa\empty%
   \ifx\fff\empty%
    \put(42,-6){\line(3,-5){78}}%          %double bond 1-6
   \else%
     \put(42,-6){\line(3,-5){62}}%         %double bond 1-6
   \fi%
  \else%
   \ifx\fff\empty%
     \put(57,-36){\line(3,-5){62}}%        %double bond 1-6
   \else%
     \put(57,-36){\line(3,-5){62}}%        %double bond 1-6
   \fi\fi}%
% bond between 3 and 2
 \def\hbondb{%
  \ifx\bbb\empty%
   \ifx\ccc\empty%
    \put(129,138){\line(1,0){148}}%        %double bond 2-3
   \else%
    \put(129,138){\line(1,0){134}}%        %double bond 3-2
   \fi%
  \else%
   \ifx\ccc\empty%
    \put(143,138){\line(1,0){134}}%        %double bond 3-2
   \else%
    \put(143,138){\line(1,0){110}}%        %double bond 3-2
   \fi\fi}%
% bond between 4 and 3
 \def\hbondc{%
  \ifx\ddd\empty%
   \ifx\ccc\empty%
    \put(364,6){\line(-3,5){78}}%          %double bond 4-3
   \else%
    \put(364,6){\line(-3,5){62}}%          %double bond 4-3
   \fi%
  \else%
   \ifx\ccc\empty%
    \put(349,36){\line(-3,5){62}}%         %double bond 4-3
   \else%
    \put(349,36){\line(-3,5){62}}%         %double bond 4-3
   \fi\fi}%
% bond between 4 and 5
 \def\hbondd{%
  \ifx\ddd\empty%
   \ifx\eee\empty%
    \put(364,-6){\line(-3,-5){78}}%        %double bond 4-5
   \else%
    \put(364,-6){\line(-3,-5){62}}%        %double bond 4-5
   \fi%
  \else%
   \ifx\eee\empty%
    \put(349,-36){\line(-3,-5){62}}%       %double bond 4-5
   \else%
    \put(349,-36){\line(-3,-5){62}}%       %double bond 4-5
   \fi\fi}%
% bond between 5 and 6
\def\hbonde{%
  \ifx\fff\empty%
   \ifx\eee\empty%
    \put(129,-138){\line(1,0){148}}%       %double bond 6-5
   \else%
    \put(129,-138){\line(1,0){134}}%       %double bond 5-6
   \fi%
  \else%
   \ifx\eee\empty%
    \put(143,-138){\line(1,0){134}}%       %double bond 5-6
   \else%
    \put(143,-138){\line(1,0){110}}%       %double bond 5-6
   \fi\fi}%
% vertical inner bond for five-membered rings
\def\hbondvert{%
  \ifx\fff\empty%
    \ifx\bbb\empty%
     \put(136,-138){\line(0,1){277}}%      %double bond 4-3
    \else%
     \put(136,-138){\line(0,1){258}}%      %double bond 4-3
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(136,-120){\line(0,1){258}}%      %double bond 4-3
    \else
     \put(136,-120){\line(0,1){239}}%      %double bond 4-3
    \fi\fi}%
% horizontal inner bond for five-membered rings (inverse type) 
\def\hbondverti{%
  \ifx\eee\empty%
    \ifx\ccc\empty%
     \put(270,-138){\line(0,0){277}}%      %double bond 4-3
    \else%
     \put(270,-138){\line(0,1){258}}%      %double bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(270,-120){\line(0,1){258}}%      %double bond 4-3
    \else%
     \put(270,-120){\line(0,1){239}}%      %double bond 4-3
    \fi\fi}%
% ********************************************
% * setting skeletal bonds (horizontal type) *
% ********************************************
% These macros are used in \sixheteroh and \fiveheteroh for setting 
% skeletal bonds in accordance with the presence or the absence of 
% hetero atoms. The following numbering is adopted in this macro. 
%
%                                   b
%                          (bbb) 2      3  (ccc)
%                            a    -----    c
%                               *       *
%   the original point ===> 1 * (aaa)     * 4  (ddd)
%          (0,0)                *       *  d
%                            f    -----
%                          (fff) 6      5  (eee)
%                                   e
% 
%bond between 1 and 2
\def\hskbonda{%
  \ifx\aaa\empty%
    \ifx\bbb\empty%
     \put(0,0){\line(3,5){103}}%           %bond 1-2
    \else%
     \put(0,0){\line(3,5){79}}%            %bond 1-2
    \fi%
   \else%
    \ifx\bbb\empty%
     \put(24,40){\line(3,5){79}}%          %bond 1-2
    \else%
     \put(24,40){\line(3,5){62}}%          %bond 1-2
    \fi\fi}%
%bond between 1 and 6
\def\hskbondf{%
  \ifx\aaa\empty%
    \ifx\fff\empty
     \put(0,0){\line(3,-5){103}}%          %bond 1-6
    \else%
     \put(0,0){\line(3,-5){79}}%           %bond 1-6
    \fi%
   \else%
    \ifx\fff\empty%
     \put(24,-40){\line(3,-5){79}}%        %bond 1-6
    \else%
     \put(24,-40){\line(3,-5){62}}%        %bond 1-6
    \fi\fi}%
%bond between 4 and 3
\def\hskbondc{%
  \ifx\ddd\empty%
    \ifx\ccc\empty%
    \put(406,0){\line(-3,5){103}}%         %bond 4-3
    \else%
     \put(406,0){\line(-3,5){79}}%         %bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(382,40){\line(-3,5){79}}%        %bond 4-3
    \else%
     \put(382,40){\line(-3,5){62}}%        %bond 4-3
    \fi\fi}%
%bond between 4 and 5
\def\hskbondd{%
  \ifx\ddd\empty%
    \ifx\eee\empty%
     \put(406,0){\line(-3,-5){103}}%       %bond 4-5
    \else%
     \put(406,0){\line(-3,-5){79}}%        %bond 4-5
    \fi%
  \else%
    \ifx\eee\empty%
     \put(382,-40){\line(-3,-5){79}}%      %bond 4-5
    \else%
     \put(382,-40){\line(-3,-5){62}}%      %bond 4-5
    \fi\fi}%
%bond between 3 and 2
\def\hskbondb{%
  \ifx\bbb\empty%
    \ifx\ccc\empty%
     \put(103,171){\line(1,0){200}}%       %bond 2-3
    \else%
     \put(103,171){\line(1,0){160}}%       %bond 3-2
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(143,171){\line(1,0){160}}%       %bond 3-2
    \else%
     \put(143,171){\line(1,0){120}}%       %bond 3-2
    \fi\fi}%
%bond between 5 and 6
\def\hskbonde{%
  \ifx\eee\empty%
    \ifx\fff\empty%
     \put(103,-171){\line(1,0){200}}%      %bond 6-5
    \else%
     \put(143,-171){\line(1,0){160}}%      %bond 5-6
    \fi%
  \else%
    \ifx\fff\empty%
     \put(103,-171){\line(1,0){160}}%      %bond 5-6
    \else%
     \put(143,-171){\line(1,0){120}}%      %bond 5-6
    \fi\fi}%
%vertical bond for five-membered rings
\def\hskbondvert{%
  \ifx\fff\empty%
    \ifx\bbb\empty%
     \put(103,-171){\line(0,1){342}}%      %bond 4-3
    \else%
     \put(103,-171){\line(0,1){300}}%      %bond 4-3
    \fi%
  \else%
    \ifx\bbb\empty%
     \put(103,171){\line(0,-1){300}}%      %bond 4-3
    \else%
     \put(103,-129){\line(0,1){258}}%      %bond 4-3
    \fi\fi}%
%vertical bond for five-membered rings (inverse type)
\def\hskbondverti{%
  \ifx\eee\empty%
    \ifx\ccc\empty%
     \put(303,-171){\line(0,1){342}}%      %bond 4-3
    \else%
     \put(303,-171){\line(0,1){300}}%      %bond 4-3
    \fi%
  \else%
    \ifx\ccc\empty%
     \put(303,171){\line(0,-1){300}}%      %bond 4-3
    \else%
     \put(303,-129){\line(0,1){258}}%      %bond 4-3
    \fi\fi}%
%
% *************************
% * sixhetero derivatives *
% *  (horizontal type)    *
% *************************
% The following numbering is adopted in this macro. 
%
%                                   b
%                                2      3  
%                            a    -----    c
%                               *       *
%   the original point ===> 1 *           * 4
%          (0,0)                *       *  d
%                            f    -----
%                                6      5 
%                                   e
%
%   \sixheteroh[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. 
%        
%        \sixheteroh{1==N}{1==Cl;2==F}
%        \sixheteroh[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \sixheteroh[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5==Cl;6==Cl}
%
\def\sixheteroh{\@ifnextchar[{\@sixheteroh}{\@sixheteroh[r]}}
\def\@sixheteroh[#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}(880,800)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `sixheteroh' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
 \hskbonda% bond between 1 and 2
 \hskbondf% bond between 1 and 6
 \hskbondc% bond between 4 and 3
 \hskbondd% bond between 4 and 5
 \hskbondb% bond between 3 and 2
 \hskbonde% bond between 5 and 6
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax \hbondd \hbondf \hbondb%
\else \if\member l\relax \hbonda \hbondc \hbonde%
\else \if\member a\relax \hbonda%
\else \if\member b\relax \hbondb%
\else \if\member c\relax \hbondc%
\else \if\member d\relax \hbondd%
\else \if\member e\relax \hbonde%
\else \if\member f\relax \hbondf%
\else \if\member A%left aromatic circle 
  \put(0,203){\circle{240}}%                %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 4\relax%
        \putratom{272}{-18}{\@@tmpb}%      % right type
      \else\if\@@tmpa 1\relax%
        \putratom{68}{-18}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{233}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 2\relax%
        \putratom{120}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 6\relax%
        \putratom{120}{-110}{\@@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{346}{-36}{\ddd}%              % right type
\fi%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{60}{-36}{\aaa}%             % left type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%            % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%            % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%           % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%           % right type
\fi%
\setsixringh{#3}{0}{0}{7}{0}%              %subst 1--6
\end{picture}\iniatom\iniflag}%     %end of \sixheteroh macro
%
% ************************************
% * sixhetero derivatives            *
% *  (horizontal type, inverse type) *
% ************************************
% The following numbering is adopted in this macro. 
%
%                                   b
%                                3      2  
%                            c    -----    a
%                               *       *
%   the original point ===> 4 *           * 1
%          (0,0)                *       *  f
%                            d    -----
%                                5      6 
%                                   e
%
%   \sixheterohi[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. 
%        
%        \sixheterohi{1==N}{1==Cl;2==F}
%        \sixheterohi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \sixheterohi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5==Cl;6==Cl}
%
\def\sixheterohi{\@ifnextchar[{\@sixheterohi}{\@sixheterohi[r]}}
\def\@sixheterohi[#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}(880,800)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `sixheterohi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
 \hskbonda% bond between 4 and 3
 \hskbondf% bond between 4 and 5
 \hskbondc% bond between 1 and 2
 \hskbondd% bond between 1 and 6
 \hskbondb% bond between 3 and 2
 \hskbonde% bond between 5 and 6
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax \hbondd \hbondf \hbondb%
\else \if\member l\relax \hbonda \hbondc \hbonde%
\else \if\member a\relax \hbondc%
\else \if\member b\relax \hbondb%
\else \if\member c\relax \hbonda%
\else \if\member d\relax \hbondf%
\else \if\member e\relax \hbonde%
\else \if\member f\relax \hbondd%
\else \if\member A%left aromatic circle 
  \put(0,203){\circle{240}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 1\relax%
        \putratom{272}{-18}{\@@tmpb}%      % right type
      \else\if\@@tmpa 4\relax%
        \putratom{68}{-18}{\@@tmpb}%       % right type
      \else\if\@@tmpa 2\relax%
        \putratom{233}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{120}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 6\relax%
        \putratom{233}{-110}{\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putratom{120}{-110}{\@@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{346}{-36}{\ddd}%                % right type
\fi%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{60}{-36}{\aaa}%               % left type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%              % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%              % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%             % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%             % right type
\fi%
\setsixringh{#3}{5}{0}{5}{-1}%               %subst 1--4
\setsixringh{#3}{11}{4}{7}{-1}%              %subst 5 and 6
\end{picture}\iniatom\iniflag}%     %end of \sixheterohi macro
%
% ************************
% * pyridine derivatives *
% *  (horizontal type)   *
% ************************
%
%   \pyridineh[BONDLIST]{SUBSLIST}
%   \pyridinehi[BONDLIST]{SUBSLIST}
%   \pyrazineh[BONDLIST]{SUBSLIST}
%   \pyrimidineh[BONDLIST]{SUBSLIST}
%   \pyrimidinehi[BONDLIST]{SUBSLIST}
%   \triazineh[BONDLIST]{SUBSLIST}
%   \triazinehi[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. 
%        
%        \pyridineh{1==Cl;2==F}
%        \pyridineh[c]{1==Cl;4==F;2==CH$_{3}$}
%        \pyridineh[eb]{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\pyridineh{\@ifnextchar[{\@pyridineh}{\@pyridineh[r]}}%
\def\@pyridineh[#1]#2{%
\iforigpt \typeout{command `pyridineh' is based on `sixheteroh'.}\fi%
\sixheteroh[#1]{1==N}{#2}}%end of \pyridineh macro
\def\pyridinehi{\@ifnextchar[{\@pyridinehi}{\@pyridinehi[r]}}%
\def\@pyridinehi[#1]#2{%
\iforigpt \typeout{command `pyridinehi' is based on `sixheterohi'.}\fi%
\sixheterohi[#1]{1==N}{#2}}% %end of \pyridinehi macro
%
\def\pyrazineh{\@ifnextchar[{\@pyrazineh}{\@pyrazineh[r]}}%
\def\@pyrazineh[#1]#2{%
\iforigpt \typeout{command `pyrazineh' is based on `sixheteroh'.}\fi%
\sixheteroh[#1]{1==N;4==N}{#2}}%end of \pyrazineh macro
%
\def\pyrimidineh{\@ifnextchar[{\@pyrimidineh}{\@pyrimidineh[r]}}%
\def\@pyrimidineh[#1]#2{%
\iforigpt \typeout{command `pyrimidineh' is based on `sixheteroh'.}\fi%
\sixheteroh[#1]{1==N;3==N}{#2}}%
   %end of \pyrimidineh macro
\def\pyrimidinehi{\@ifnextchar[{\@pyrimidinehi}{\@pyrimidinehi[r]}}%
\def\@pyrimidinehi[#1]#2{%
\iforigpt \typeout{command `pyrimidinehi' is based on `sixheterohi'.}\fi%
\sixheterohi[#1]{1==N;3==N}{#2}}%
   %end of \pyrimidinehi macro
%
\def\pyridazineh{\@ifnextchar[{\@pyridazineh}{\@pyridazineh[r]}}%
\def\@pyridazineh[#1]#2{%
\iforigpt \typeout{command `pyridazineh' is based on `sixheteroh'.}\fi%
\sixheteroh[#1]{1==N;2==N}{#2}}%
   %end of \pyridazineh macro
\def\pyridazinehi{\@ifnextchar[{\@pyridazinehi}{\@pyridazinehi[r]}}%
\def\@pyridazinehi[#1]#2{%
\iforigpt \typeout{command `pyridazinehi' is based on `sixheterohi'.}\fi%
\sixheterohi[#1]{1==N;2==N}{#2}}%
   %end of \pyridazinehi macro
%
\def\triazineh{\@ifnextchar[{\@triazineh}{\@triazineh[r]}}%
\def\@triazineh[#1]#2{%
\iforigpt \typeout{command `triazineh' is based on `sixheteroh'.}\fi%
\sixheteroh[#1]{1==N;3==N;5==N}{#2}}%
   %end of \triazineh macro
%
\def\triazinehi{\@ifnextchar[{\@triazinehi}{\@triazinehi[r]}}%
\def\@triazinehi[#1]#2{%
\iforigpt \typeout{command `triazinehi' is based on `sixheterohi'.}\fi%
\sixheterohi[#1]{1==N;3==N;5==N}{#2}}%
   %end of \triazinehi macro
%
% ****************************
% * fivehetero derivatives   *
% *  (horizontal type)       *
% ****************************
% The following numbering is adopted in this macro. 
%
%     3  _____  2
%       |       *
%       |         * 1 <===== the original point
%       |       *
%     4  -----  5
%
%   \fiveheteroh[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 4)
%           {0+}       :  plus (or others) 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. 
%        
%        \fiveheteroh{1==N}{1==H;2==F}
%        \fiveheteroh[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \fiveheteroh[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\fiveheteroh{\@ifnextchar[{\@fiveheteroh}{\@fiveheteroh[r]}}%
\def\@fiveheteroh[#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)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveheteroh' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
\hskbondc%bond between 1 and 2
\hskbondd%bond between 1 and 5
\hskbondb%bond between 2 to 3
\hskbonde%bond between 5 and 4
\hskbondvert%bond between 4 and 3
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else \if\member a\relax \hbondc%
\else \if\member b\relax \hbondb%
\else \if\member c\relax \hbondvert%
\else \if\member d\relax \hbonde%
\else \if\member e\relax \hbondd%
\else \if\member A%left aromatic circle 
  \put(233,0){\circle{180}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 1\relax%
        \putratom{272}{-18}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{233}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{120}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 4\relax%
        \putratom{120}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 0\relax%
        \putratom{196}{-30}{\@@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{356}{-36}{\ddd}%              % right type
%   \putratom{346}{-36}{\ddd}%              % right type
\fi%
%\ifx\aaa\empty\else
%     \@acliptrue
%     \putlatom{60}{-36}{\aaa}  % left type
%\fi
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%             % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%             % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%            % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%            % right type
\fi
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\put(0,0){\setsixringh{#3}{5}{1}{5}{-1}}%   % for 1 to 3
\put(0,0){\setsixringh{#3}{10}{4}{7}{-1}}%  % for 4 to 5
\end{picture}\iniatom\iniflag}%      %end of \fiveheteroh macro
%
% *******************************
% * fivehetero derivatives      *
% *  (horizontal type, inverse) *
% *******************************
% The following numbering is adopted in this macro. 
%
%                       2  -----  3
%                        *       |
% the original point 1 *         |
%                        *       |
%                           _____|
%                        5        4
%
%   \fiveheterohi[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 4)
%           {0+}       :  plus (or others) 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. 
%        
%        \fiveheterohi{1==N}{1==H;2==F}
%        \fiveheterohi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \fiveheterohi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\fiveheterohi{\@ifnextchar[{\@fiveheterohi}{\@fiveheterohi[r]}}
\def\@fiveheterohi[#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)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveheterohi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
\hskbonda%bond between 1 and 2
\hskbondb%bond between 2 and 3
\hskbonde%bond between 4 and 5
\hskbondf%bond between 1 and 5
\hskbondverti% bond between 3 and 4
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r%
\else \if\member a\relax \hbonda%
\else \if\member b\relax \hbondb%
\else \if\member c\relax \hbondverti%
\else \if\member d\relax \hbonde%
\else \if\member e\relax \hbondf%
\else \if\member A%left aromatic circle 
  \put(173,0){\circle{180}}%               %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{140}{-30}{\@@tmpb}%      % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{50}{-36}{\aaa}%             % left type
%     \putlatom{60}{-36}{\aaa}%             % left type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%            % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%            % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%           % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%           % left type
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringh{#3}{0}{0}{4}{0}%              % for 1 to 3
\setsixringh{#3}{1}{4}{7}{0}%              % for 4 to 5
\end{picture}\iniatom\iniflag}%         %end of \fiveheterohi macro
%
% ***********************************
% * pyrrole derivatives  and others *
% *  (horizontal type)              *
% ***********************************
%
%   \pyrroleh[BONDLIST]{SUBSLIST}
%   \pyrazoleh[BONDLIST]{SUBSLIST}
%   \imidazoleh[BONDLIST]{SUBSLIST}
%   \isoxazoleh[BONDLIST]{SUBSLIST}
%   \oxazoleh[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. 
%        
%        \pyrroleh{1==H;2==F}
%        \pyrroleh[]{1==H;2==F}
%        \pyrroleh[H]{1==H;2==F}
%        \imidazoleh[c]{1==Cl;4==F;2==CH$_{3}$}
%        \isoxazoleh[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\pyrroleh{\@ifnextchar[{\@pyrroleh}{\@pyrroleh[bd]}}%
\def\@pyrroleh[#1]#2{%
\iforigpt \typeout{command `pyrroleh' is based on `fiveheteroh'.}\fi%
\fiveheteroh[#1]{1==N}{#2}}%
\def\pyrazoleh{\@ifnextchar[{\@pyrazoleh}{\@pyrazoleh[bd]}}%
\def\@pyrazoleh[#1]#2{%
\iforigpt \typeout{command `pyrazoleh' is based on `fiveheteroh'.}\fi%
\fiveheteroh[#1]{1==N;2==N}{#2}}%
\def\imidazoleh{\@ifnextchar[{\@imidazoleh}{\@imidazoleh[bd]}}%
\def\@imidazoleh[#1]#2{%
\iforigpt \typeout{command `imidazoleh' is based on `fiveheteroh'.}\fi%
\fiveheteroh[#1]{1==N;3==N}{#2}}%
\def\isoxazoleh{\@ifnextchar[{\@isoxazoleh}{\@isoxazoleh[bd]}}%
\def\@isoxazoleh[#1]#2{%
\iforigpt \typeout{command `isoxazoleh' is based on `fiveheteroh'.}\fi%
\fiveheteroh[#1]{1==O;2==N}{#2}}%
\def\oxazoleh{\@ifnextchar[{\@oxazoleh}{\@oxazoleh[bd]}}%
\def\@oxazoleh[#1]#2{%
\iforigpt \typeout{command `oxazoleh' is based on `fiveheteroh'.}\fi%
\fiveheteroh[#1]{1==O;3==N}{#2}}%
%
% *************************************
% * pyrrole derivatives  and others   *
% *  (horizontal type, inverse)       *
% *************************************
%
%   \pyrrolehi[BONDLIST]{SUBSLIST}
%   \pyrazolehi[BONDLIST]{SUBSLIST}
%   \imidazolehi[BONDLIST]{SUBSLIST}
%   \isoxazolehi[BONDLIST]{SUBSLIST}
%   \oxazolehi[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. 
%        
%        \pyrrolehi{1==H;2==F}
%        \pyrrolehi[]{1==H;2==F}
%        \pyrrolehi[H]{1==H;2==F}
%        \imidazolehi[c]{1==Cl;4==F;2==CH$_{3}$}
%        \isoxazolehi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\pyrrolehi{\@ifnextchar[{\@pyrrolehi}{\@pyrrolehi[bd]}}%
\def\@pyrrolehi[#1]#2{%
\iforigpt \typeout{command `pyrrolehi' is based on `fiveheterohi'.}\fi%
\fiveheterohi[#1]{1==N}{#2}}%
\def\pyrazolehi{\@ifnextchar[{\@pyrazolehi}{\@pyrazolehi[bd]}}%
\def\@pyrazolehi[#1]#2{%
\iforigpt \typeout{command `pyrazolehi' is based on `fiveheterohi'.}\fi%
\fiveheterohi[#1]{1==N;2==N}{#2}}%
\def\imidazolehi{\@ifnextchar[{\@imidazolehi}{\@imidazolehi[bd]}}%
\def\@imidazolehi[#1]#2{%
\iforigpt \typeout{command `imidazolehi' is based on `fiveheterohi'.}\fi%
\fiveheterohi[#1]{1==N;3==N}{#2}}%
\def\isoxazolehi{\@ifnextchar[{\@isoxazolehi}{\@isoxazolehi[bd]}}%
\def\@isoxazolehi[#1]#2{%
\iforigpt \typeout{command `isoxazolehi' is based on `fiveheterohi'.}\fi%
\fiveheterohi[#1]{1==O;2==N}{#2}}%
\def\oxazolehi{\@ifnextchar[{\@oxazolehi}{\@oxazolehi[bd]}}%
\def\@oxazolehi[#1]#2{%
\iforigpt \typeout{command `oxazolehi' is based on `fiveheterohi'.}\fi%
\fiveheterohi[#1]{1==O;3==N}{#2}}%
%
% ****************************
% * decahetero derivatives   *
% *  (horizontal type)       *
% ****************************
% The following numbering is adopted in this macro. 
%
%           2   3
%
%      *1          4           (*1 origin)
%
%      (10)8a   4a(9)
%
%       8          5
%
%           7   6
%   ____                     ____
%  |cf.                          |
%  |        8 (10)1              |
%  |        *  8a *              |
%  |   7  *   * *   *  2         |
%  |     |     |     |           |
%  |     |     |     |           |
%  |   6  *   * *   *  3         |
%  |        *  4a *              |
%  |        5 (9) 4              |
%  |        ^                    |
%  |        |                    |
%  |        the original point   |
%  |____                     ____|
%
%   \decaheteroh[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  decahetero (right-handed)
%           l          :  no action
%           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. 
%        
%        \decaheteroh{1==N}{1==Cl;2==F}
%        \decaheteroh[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \decaheteroh[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\decaheteroh{\@ifnextchar[{\@decaheteroh}{\@decaheteroh[r]}}
\def\@decaheteroh[#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,1200)(-400,-800)
  \iforigpt \put(-\shiftii,-\shiftiii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `decaheteroh' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shiftiii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(0,0){\hskbonda}% bond between 1 and 2
 \put(0,0){\hskbondb}% bond between 3 and 2
 \put(0,0){\hskbondc}% bond between 4 and 3
 \put(0,0){\hskbondf}% bond between 1 and 6
 \put(0,0){\hskbondd}% bond between 4 and 4a
 \put(0,0){\hskbonde}% 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,-342){\hskbonda}% bond between 8 and 8a
 \put(0,-342){\hskbondc}% bond between 5 and 4a
 \put(0,-342){\hskbondf}% bond between 8 and 7
 \put(0,-342){\hskbondd}% bond between 5 and 6
 \put(0,-342){\hskbonde}% bond between 6 and 7
}%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
{\let\fff=\jjj \let\eee=\iii%
 \put(0,0){\hbonda}% bond between 1 and 2%
 \put(0,0){\hbondc}% 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,-342){\hbondb}% bond between 8a and 4a
 \put(0,-342){\hbondf}% bond between 8 and 7
 \put(0,-342){\hbondd}% bond between 5 and 6
}%
\else \if\member l\relax%
\else \if\member a\relax%
 \put(0,0){\hbonda}% bond between 1 and 2
\else \if\member b\relax%
 \put(0,0){\hbondb}% bond between 2 and 3
\else \if\member c\relax%
 \put(0,0){\hbondc}% bond between 3 and 4
% \put(342,0){\hbondc}% bond between 3 and 4
\else \if\member d\relax%
{\let\eee=\iii%
 \put(0,0){\hbondd}% bond between 4 and 4a
}%
\else \if\member e\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,-342){\hbondc}% bond between 5 and 4a
}%
\else \if\member f\relax%
{\let\ddd=\eee \let\eee=\fff%
 \put(0,-342){\hbondd}% bond between 5 and 6
}%
\else \if\member g\relax%
{\let\eee=\fff \let\fff=\ggg% 
 \put(0,-342){\hbonde}% bond between 6 and 7
}%
\else \if\member h\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,-342){\hbondf}% bond between 8 and 7
}%
\else \if\member i\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,-342){\hbonda}% bond between 8 and 8a
}%
\else \if\member j\relax%
{\let\fff=\jjj%
 \put(0,0){\hbondf}% bond between 1 and 8a
}%
\else \if\member k\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,-342){\hbondb}% bond between 8a and 4a
}%
\else \if\member A%left aromatic circle 
  \put(203,0){\circle{240}}%                %circle
\else \if\member B%left aromatic circle 
  \put(203,-342){\circle{240}}%             %circle
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{8a} \def\aay{4a} \def\aaz{10}%
      \if\@@tmpa 4\relax%
        \putratom{272}{-18}{\@@tmpb}%       % right type
      \else\if\@@tmpa 1\relax%
        \putratom{68}{-18}{\@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax%
        \putratom{233}{60}{\@@tmpb}%        % right type
      \else\if\@@tmpa 2\relax%
        \putratom{120}{60}{\@@tmpb}%        % right type
      \else\ifx\@@tmpa\aaz\relax%
        \putratom{120}{-110}{\@@tmpb}%      % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{120}{-110}{\@@tmpb}%      % right type
      \else\ifx\@@tmpa\aay\relax
        \putratom{233}{-110}{\@@tmpb}%      % right type
      \else\if\@@tmpa 9\relax%
        \putratom{233}{-110}{\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putratom{272}{-360}{\@@tmpb}%      % right type
      \else\if\@@tmpa 8\relax%
        \putratom{68}{-360}{\@@tmpb}%       % right type
      \else\if\@@tmpa 6\relax%
        \putratom{233}{-452}{\@@tmpb}%      % right type
      \else\if\@@tmpa 7\relax%
        \putratom{120}{-452}{\@@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%
     \putlatom{60}{-36}{\aaa}%              % left type
\fi%
% hetero atom on 2
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%             % left type
\fi%
% hetero atom on 3
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%             % right type
\fi%
% hetero atom on 4
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{346}{-36}{\ddd}%               % right type
\fi%
% hetero atom on 4a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putratom{273}{-211}{\iii}%            % right type
\fi%
}%
% hetero atom on 8a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{135}{-211}{\jjj}%            % left type
\fi%
}%
% hetero atom on 5
{\let\ddd=\eee%
\ifx\ddd\empty\else
   \global\@ecliptrue%
   \putratom{346}{-378}{\eee}%              % right type
\fi%
}%
% hetero atom on 6
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putratom{273}{-553}{\fff}%             % left type
\fi%
}%
% hetero atom on 7
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{135}{-553}{\ggg}%             % left type
\fi%
}%
% hetero atom on 8
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putlatom{60}{-378}{\hhh}%              % left type
\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(0,0){\setsixringh{#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,-342){\setsixringh{#3}{-1}{3}{7}{0}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%   %substituent on 8
\put(0,-342){\setsixringh{#3}{-7}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(303,-171){\setatombond{#3}{-8}{4}}   %9 for 4a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(103,-171){\setatombond{#3}{-9}{10}} %10 for 8a position
}%
\end{picture}\iniatom\iniflag}%      %end of \decaheteroh macro
%
% ************************************
% * decahetero derivatives           *
% *  (horizonatl type, inverse type) *
% ************************************
% The following numbering is adopted in this macro. 
%
%           3   2
%
%      *4          1           (*4 origin)
%
%       (8)4a   8a(10)
%
%       5          8
%
%           6   7
%   ____                     ____
%  |cf.                          |
%  |        5 (9) 4              |
%  |        *  4a *              |
%  |   6  *   * *   *  3         |
%  |     |     |     |           |
%  |     |     |     |           |
%  |   7  *   * *   *  2         |
%  |        *  8a *              |
%  |        8 (9) 1              |
%  |        ^                    |
%  |        |                    |
%  |        the original point   |
%  |____                     ____|
%
%   \decaheterohi[BONDLIST]{ATOMLIST}{SUBSLIST}
%  
%     BONDLIST:  list of bonds 
%
%           none or r  :  decahetero (right-handed)
%           l          :  no action
%           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. 
%        
%        \decaheterohi{1==N}{1==Cl;2==F}
%        \decaheterohi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%        \decaheterohi[eb]{1==N}{1D==O;4SA==MeO;4SB==OMe;5W==Cl;6==Cl}
%
\def\decaheterohi{\@ifnextchar[{\@decaheterohi}{\@decaheterohi[r]}}
\def\@decaheterohi[#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,1200)(-400,-800)%
  \iforigpt \put(-\shiftii,-\shiftiii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `decaheterohi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shiftiii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(0,0){\hskbonda}% bond between 1 and 2
 \put(0,0){\hskbondb}% bond between 3 and 2
 \put(0,0){\hskbondc}% bond between 4 and 3
 \put(0,0){\hskbondf}% bond between 1 and 6
 \put(0,0){\hskbondd}% bond between 4 and 4a
 \put(0,0){\hskbonde}% 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,-342){\hskbonda}% bond between 8 and 8a
 \put(0,-342){\hskbondc}% bond between 5 and 4a
 \put(0,-342){\hskbondf}% bond between 8 and 7
 \put(0,-342){\hskbondd}% bond between 5 and 6
 \put(0,-342){\hskbonde}% bond between 6 and 7
}%
%%%%%%%%%%%%%%%%%%%%%
% inner double bond %
%%%%%%%%%%%%%%%%%%%%%
\@tfor\member:=#1\do{%
\if\member r\relax%
{\let\fff=\jjj \let\eee=\iii%
 \put(0,0){\hbonda}% bond between 1 and 2
 \put(0,0){\hbondc}% 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,-342){\hbondb}% bond between 8a and 4a
 \put(0,-342){\hbondf}% bond between 8 and 7
 \put(0,-342){\hbondd}% bond between 5 and 6
}%
\else \if\member l\relax%
\else \if\member a\relax%
 \put(0,0){\hbondc}% bond between 3 and 4
\else \if\member b\relax
 \put(0,0){\hbondb}% bond between 2 and 3
\else \if\member c\relax
 \put(0,0){\hbonda}% bond between 1 and 2
\else \if\member d\relax%
{\let\fff=\jjj%
 \put(0,0){\hbondf}% bond between 1 and 8a
}%
\else \if\member e\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,-342){\hbonda}% bond between 8 and 8a
}%
\else \if\member f\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,-342){\hbondf}% bond between 8 and 7
}%
\else \if\member g\relax%
{\let\eee=\fff \let\fff=\ggg% 
 \put(0,-342){\hbonde}% bond between 6 and 7
}%
\else \if\member h\relax%
{\let\ddd=\eee \let\eee=\fff%
 \put(0,-342){\hbondd}% bond between 5 and 6
}%
\else \if\member i\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,-342){\hbondc}% bond between 5 and 4a
}%
\else \if\member j\relax%
{\let\eee=\iii%
 \put(0,0){\hbondd}% bond between 4 and 4a
}%
\else \if\member k\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,-342){\hbondb}% bond between 8a and 4a
}%
\else \if\member A%left aromatic circle
  \put(203,0){\circle{240}}%                %circle
\else \if\member B%left aromatic circle 
  \put(203,-342){\circle{240}}%             %circle
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{8a} \def\aay{4a} \def\aaz{10}%
      \if\@@tmpa 4\relax%
        \putratom{68}{-18}{\@@tmpb}%        % right type
      \else\if\@@tmpa 1\relax%
        \putratom{272}{-18}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{120}{60}{\@@tmpb}%        % right type
      \else\if\@@tmpa 2\relax%
        \putratom{233}{60}{\@@tmpb}%        % right type
      \else\ifx\@@tmpa\aaz\relax%
        \putratom{233}{-110}{\@@tmpb}%      % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{233}{-110}{\@@tmpb}%      % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{120}{-110}{\@@tmpb}%      % right type
      \else\if\@@tmpa 9\relax%
        \putratom{120}{-110}{\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putratom{68}{-360}{\@@tmpb}%       % right type
      \else\if\@@tmpa 8\relax%
        \putratom{272}{-360}{\@@tmpb}%      % right type
      \else\if\@@tmpa 6\relax%
        \putratom{120}{-452}{\@@tmpb}%      % right type
      \else\if\@@tmpa 7\relax%
        \putratom{233}{-452}{\@@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 4   (1)
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{60}{-36}{\aaa}%               % left type
\fi%
% hetero atom on 3   (2)
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%              % left type
\fi%
% hetero atom on 2   (3)
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%              % right type
\fi%
% hetero atom on 1   (4)
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{346}{-36}{\ddd}%                % right type
\fi%
% hetero atom on 8a  (4a)
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putratom{273}{-211}{\iii}%             % right type
\fi%
}%
% hetero atom on 4a   (8a)
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{135}{-211}{\jjj}%             % left type
\fi%
}%
% hetero atom on 8    (5)
{\let\ddd=\eee%
\ifx\ddd\empty\else%
   \global\@ecliptrue%
   \putratom{346}{-378}{\eee}%               % right type
\fi%
}%
% hetero atom on 7    (6)
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putratom{273}{-553}{\fff}%             % left type
\fi%
}%
% hetero atom on 6    (7)
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{135}{-553}{\ggg}%             % left type
\fi%
}%
% hetero atom on 5    (8)
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putlatom{60}{-378}{\hhh}%              % left type
\fi%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(0,0){\setsixringh{#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,-342){\setsixringh{#3}{12}{3}{7}{-1}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%    %substituent on 5
\put(0,-342){\setsixringh{#3}{-4}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(303,-171){\setatombond{#3}{-9}{4}}%   %10 for 8a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi
  \put(103,-171){\setatombond{#3}{-8}{10}}% %9 for 4a position
}%
\end{picture}\iniatom\iniflag}%      %end of \decaheterohi macro
%
% ****************************************************
% * heterocycles having two fused six-membered rings *
% *  (horizontal type)                               *
% ****************************************************
%
%   \quinolineh[BONDLIST]{SUBSLIST}
%   \quinolinehi[BONDLIST]{SUBSLIST}
%   \isoquinolineh[BONDLIST]{SUBSLIST}
%   \isoquinolinehi[BONDLIST]{SUBSLIST}
%   \quinoxalineh[BONDLIST]{SUBSLIST}
%   \quinazolineh[BONDLIST]{SUBSLIST}
%   \quinazolinehi[BONDLIST]{SUBSLIST}
%   \cinnolineh[BONDLIST]{SUBSLIST}
%   \cinnolinehi[BONDLIST]{SUBSLIST}
%   \pteridineh[BONDLIST]{SUBSLIST}
%   \pteridinehi[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. 
%        
%        \quinolineh{2==Cl;3==F}
%
\def\quinolineh{\@ifnextchar[{\@quinolineh}{\@quinolineh[acfhk]}}%
\def\@quinolineh[#1]#2{%
\iforigpt \typeout{command `quinolineh' is based on `decaheteroh'.}\fi%
\decaheteroh[#1]{1==N}{#2}}%
\def\quinolinehi{\@ifnextchar[{\@quinolinehi}{\@quinolinehi[acfhk]}}%
\def\@quinolinehi[#1]#2{%
\iforigpt \typeout{command `quinolinehi' is based on `decaheterohi'.}\fi%
\decaheterohi[#1]{1==N}{#2}}%
%
\def\isoquinolineh{\@ifnextchar[{\@isoquinolineh}{\@isoquinolineh[acfhk]}}%
\def\@isoquinolineh[#1]#2{%
\iforigpt \typeout{command `isoquinolineh' is based on `decaheteroh'.}\fi%
\decaheteroh[#1]{2==N}{#2}}%
\def\isoquinolinehi{\@ifnextchar[{\@isoquinolinehi}{\@isoquinolinehi[acfhk]}}%
\def\@isoquinolinehi[#1]#2{%
\iforigpt \typeout{command `isoquinolinehi' is based on `decaheterohi'.}\fi%
\decaheterohi[#1]{2==N}{#2}}%
%
\def\quinoxalineh{\@ifnextchar[{\@quinoxalineh}{\@quinoxalineh[acfhk]}}%
\def\@quinoxalineh[#1]#2{%
\iforigpt \typeout{command `quinoxalineh' is based on `decaheteroh'.}\fi%
\decaheteroh[#1]{1==N;4==N}{#2}}%
%
\def\quinazolineh{\@ifnextchar[{\@quinazolineh}{\@quinazolineh[acfhk]}}%
\def\@quinazolineh[#1]#2{%
\iforigpt \typeout{command `quinazolineh' is based on `decaheteroh'.}\fi%
\decaheteroh[#1]{1==N;3==N}{#2}}%
\def\quinazolinehi{\@ifnextchar[{\@quinazolinehi}{\@quinazolinehi[acfhk]}}%
\def\@quinazolinehi[#1]#2{%
\iforigpt \typeout{command `quinazolinehi' is based on `decaheterohi'.}\fi%
\decaheterohi[#1]{1==N;3==N}{#2}}%
%
\def\cinnolineh{\@ifnextchar[{\@cinnolineh}{\@cinnolineh[acfhk]}}%
\def\@cinnolineh[#1]#2{%
\iforigpt \typeout{command `cinnolineh' is based on `decaheteroh'.}\fi%
\decaheteroh[#1]{1==N;2==N}{#2}}%
\def\cinnolinehi{\@ifnextchar[{\@cinnolinehi}{\@cinnolinehi[acfhk]}}%
\def\@cinnolinehi[#1]#2{%
\iforigpt \typeout{command `cinnolinehi' is based on `decaheterohi'.}\fi%
\decaheterohi[#1]{1==N;2==N}{#2}}%
%
\def\pteridineh{\@ifnextchar[{\@pteridineh}{\@pteridineh[acfhk]}}%
\def\@pteridineh[#1]#2{%
\iforigpt \typeout{command `pteridineh' is based on `decaheteroh'.}\fi%
\decaheteroh[#1]{1==N;3==N;5==N;8==N}{#2}}%
\def\pteridinehi{\@ifnextchar[{\@pteridinehi}{\@pteridinehi[acfhk]}}%
\def\@pteridinehi[#1]#2{%
\iforigpt \typeout{command `pteridinehi' is based on `decaheterohi'.}\fi%
\decaheterohi[#1]{1==N;3==N;5==N;8==N}{#2}}%
%
% **************************
% * nonahetero derivatives *
% *  (horizontal type)     *
% **************************
% The following numbering is adopted in this macro. 
%
%           3   2
%
%                  1           (*1 origin)
%
%       (8)3a   7a(9)
%
%       4          7
%
%           5   6
%   ____                     ____
%  |cf.                          |
%  |        4 (8)               |
%  |        *  3a                |
%  |   5  *   * -----  3         |
%  |     |     |     |           |
%  |     |     |     |           |
%  |   6  *   * *   *  2         |
%  |        *  7a *              |
%  |        7 (9) 1              |
%  |        ^                    |
%  |        |                    |
%  |        the original point   |
%  |____                     ____|
%
%
%   \nonaheteroh[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)
%           B    :  aromatic circle (five-membered)
%           {n+} :  plus at the n-nitrogen atom (n = 1 to 7)
%           {0+} :  plus (or others) at the center 
%                    of the five-membered cycle
%
%     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. 
%        
%        \nonaheteroh{1==N}{1==Cl;2==F}
%        \nonaheteroh[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%
\def\nonaheteroh{\@ifnextchar[{\@nonaheteroh}{\@nonaheteroh[r]}}
\def\@nonaheteroh[#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,1200)(-400,-800)%
  \iforigpt \put(-\shiftii,-\shiftiii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `nonahetero' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shiftiii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(0,0){\hskbondb}% bond between 2 and 3  3 and 2
 \put(0,0){\hskbondc}% bond between 1 and 2  4 and 3
 \put(0,0){\hskbondd}% bond between 7a and 3a  4 and 4a
 \put(0,0){\hskbonde}% bond between 1 and 7a  4a and 8a
 \put(0,0){\hskbondvert}% 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,-342){\hskbonda}% bond between 4 and 3a 8 and 8a
 \put(0,-342){\hskbondc}% bond between 7 and 7a 5 and 4a
 \put(0,-342){\hskbondf}% bond between 4 and 5 8 and 7
 \put(0,-342){\hskbondd}% bond between 7 and 6 5 and 6
 \put(0,-342){\hskbonde}% 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,-342){\hbondb}% bond between 3a and 7a
 \put(0,-342){\hbondf}% bond between 4 and 5
 \put(0,-342){\hbondd}% bond between 6 and 7
}%
\else \if\member l\relax%
\else \if\member a\relax%
 \put(0,0){\hbondc}% bond between 3 and 4
\else \if\member b\relax%
 \put(0,0){\hbondb}% bond between 2 and 3
\else \if\member c\relax%
 \put(0,0){\hbondvert}% bond between 3 and 3a
\else \if\member d\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,-342){\hbonda}% bond between 4 and 3a
}%
\else \if\member e\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,-342){\hbondf}% bond between 4 and 5
}%
\else \if\member f\relax%
{\let\eee=\fff \let\fff=\ggg%
 \put(0,-342){\hbonde}% bond between 5 and 6
}%
\else \if\member g\relax%
{\let\ddd=\eee \let\eee=\fff%
 \put(0,-342){\hbondd}% bond between 6 and 7
}%
\else \if\member h\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,-342){\hbondc}% bond between 7 and 7a
}%
\else \if\member i\relax%
{\let\eee=\iii%
 \put(0,0){\hbondd}% bond between 1 and 7a
}%
\else \if\member j\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,-342){\hbondb}% bond between 7a and 3a
}%
\else \if\member B%left aromatic circle 
  \put(233,0){\circle{180}}%               %circle (five-membered)
\else \if\member A%left aromatic circle 
  \put(203,-342){\circle{240}}%            %circle (six-membered)
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{3a} \def\aay{7a}%
      \if\@@tmpa 1\relax%
        \putratom{272}{-18}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{233}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{120}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 4\relax%
        \putratom{68}{-360}{\@@tmpb}%      % right type
      \else\if\@@tmpa 5\relax%
        \putratom{120}{-452}{\@@tmpb}%     % right type
      \else\if\@@tmpa 6\relax%
        \putratom{233}{-452}{\@@tmpb}%     % right type
      \else\if\@@tmpa 7\relax%
        \putratom{272}{-360}{\@@tmpb}%     % right type
      \else\if\@@tmpa 8\relax%
        \putratom{120}{-110}{\@@tmpb}%     % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{120}{-110}{\@@tmpb}%     % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 9\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 0\relax%
        \putratom{196}{-30}{\@@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}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
% hetero atom on 1
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{356}{-36}{\ddd}%     % right type
%   \putratom{346}{-36}{\ddd}%     % right type
\fi%
% hetero atom on 2
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%   % right type
\fi%
% hetero atom on 3
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%   % left type
\fi%
% hetero atom on 3a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue
     \putlatom{135}{-211}{\jjj}%  % left type
\fi}%
% hetero atom on 4
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putlatom{50}{-378}{\hhh}%   % left type
%     \putlatom{60}{-378}{\hhh}%   % left type
\fi}%
% hetero atom on 5
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{135}{-553}{\ggg}%  % left type
\fi}%
% hetero atom on 6
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putratom{273}{-553}{\fff}%  % left type
\fi}%
% hetero atom on 7
{\let\ddd=\eee%
\ifx\ddd\empty\else%
   \global\@ecliptrue%
   \putratom{356}{-378}{\eee}%    % right type
%   \putratom{346}{-378}{\eee}%    % right type
\fi}%
% hetero atom on 7a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putratom{273}{-211}{\iii}%  % left type
\fi}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(0,0){\setsixringh{#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,-342){\setsixringh{#3}{11}{3}{7}{-1}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%   %substituent on 4
\put(0,-342){\setsixringh{#3}{-3}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(303,-171){\setatombond{#3}{-8}{4}}%   %9 for 7a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(103,-171){\setatombond{#3}{-7}{10}}% %8 for 3a position
}%
\end{picture}\iniatom\iniflag}%        %end of \nonaheteroh macro
%
% ************************************
% * nonahetero derivatives           *
% *  (horizontal type, inverse type) *
% ************************************
% The following numbering is adopted in this macro. 
%
%
%           2   3
%
%        1       
%
%       (9)7a   3a(8)
%
%       7          4
%
%           6   5
%   ____                     ____
%  |cf.                          |
%  |        7 (9) 1              |
%  |        *  7a *              |
%  |   6  *   * *   *  2         |
%  |     |     |     |           |
%  |     |     |     |           |
%  |   5  *   * -----  3         |
%  |        *  3a                |
%  |        4 (8)                |
%  |        ^                    |
%  |        |                    |
%  |        the original point   |
%  |____                     ____|
%
%   \nonaheterohi[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)
%           B    :  aromatic circle (five-membered)
%           {n+} :  plus at the n-nitrogen atom (n = 1 to 7)
%           {0+} :  plus (or others) at the center 
%                    of the five-membered cycle
%
%     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. 
%        
%        \nonaheterohi{1==N}{1==Cl;2==F}
%        \nonaheterohi[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%
\def\nonaheterohi{\@ifnextchar[{\@nonaheterohi}{\@nonaheterohi[r]}}%
\def\@nonaheterohi[#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,1200)(-400,-800)%
  \iforigpt \put(-\shiftii,-\shiftiii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `nonaheterohi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shiftii,\the\shiftiii)}\fi%
%%%%%%%%%%%%%%%%%%
% outer skeleton %
%%%%%%%%%%%%%%%%%%
{\let\fff=\jjj \let\eee=\iii%
 \put(0,0){\hskbonda}% bond between 1 and 2
 \put(0,0){\hskbondb}% bond between 2 and 3
 \put(0,0){\hskbonde}% bond between 7a and 3a
 \put(0,0){\hskbondf}% bond between 1 and 7a
 \put(0,0){\hskbondverti}% 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,-342){\hskbonda}% bond between 7 and 7a
 \put(0,-342){\hskbondc}% bond between 4 and 3a
 \put(0,-342){\hskbondf}% bond between 6 and 7
 \put(0,-342){\hskbondd}% bond between 4 and 5 
 \put(0,-342){\hskbonde}% 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,-342){\hbondb}% bond between 3a and 7a
 \put(0,-342){\hbondf}% bond between 6 and 7
 \put(0,-342){\hbondd}% bond between 4 and 5
}%
\else \if\member l\relax%
\else \if\member a\relax%
 \put(0,0){\hbonda}% bond between 1 and 2
\else \if\member b\relax%
 \put(0,0){\hbondb}% bond between 2 and 3
\else \if\member c\relax%
 \put(0,0){\hbondverti}% bond between 3 and 3a
\else \if\member d\relax%
{\let\ccc=\iii \let\ddd=\eee%
 \put(0,-342){\hbondc}% bond between 4 and 3a
}%
\else \if\member e\relax%
{\let\ddd=\eee\let\eee=\fff%
 \put(0,-342){\hbondd}% bond between 4 and 5
}%
\else \if\member f\relax%
{\let\eee=\fff \let\fff=\ggg%
 \put(0,-342){\hbonde}% bond between 5 and 6
}%
\else \if\member g\relax%
{\let\aaa=\hhh \let\fff=\ggg%
 \put(0,-342){\hbondf}% bond between 7 and 6
}%
\else \if\member h\relax%
{\let\aaa=\hhh \let\bbb=\jjj%
 \put(0,-342){\hbonda}% bond between 7 and 7a
}%
\else \if\member i\relax%
{\let\fff=\jjj%
 \put(0,0){\hbondf}% bond between 1 and 7a
}%
\else \if\member j\relax%
{\let\ccc=\iii\let\bbb=\jjj%
 \put(0,-342){\hbondb}% bond between 7a and 3a
}%
\else \if\member B%aromatic circle 
  \put(173,0){\circle{180}}%               %circle (five-membered)
\else \if\member A%aromatic circle 
  \put(203,-342){\circle{240}}%            %circle (six-membered)
\else \expandafter\twoch@@r\member{}{}%
  \def\aax{7a} \def\aay{3a}%
      \if\@@tmpa 1\relax%
        \putratom{68}{-18}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{233}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 2\relax%
        \putratom{120}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 7\relax%
        \putratom{68}{-360}{\@@tmpb}%      % right type
      \else\if\@@tmpa 6\relax%
        \putratom{120}{-452}{\@@tmpb}%     % right type
      \else\if\@@tmpa 5\relax%
        \putratom{233}{-452}{\@@tmpb}%     % right type
      \else\if\@@tmpa 4\relax%
        \putratom{272}{-360}{\@@tmpb}%     % right type
      \else\if\@@tmpa 9\relax%
        \putratom{120}{-110}{\@@tmpb}%     % right type
      \else\ifx\@@tmpa\aax\relax%
        \putratom{120}{-110}{\@@tmpb}%     % right type
      \else\ifx\@@tmpa\aay\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 8\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 0\relax%
        \putratom{140}{-30}{\@@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}%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting hetero atoms %
%%%%%%%%%%%%%%%%%%%%%%%%
% hetero atom on 1
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{50}{-36}{\aaa}%     % left type
%     \putlatom{60}{-36}{\aaa}%     % left type
\fi%
% hetero atom on 3
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%    % right type
\fi%
% hetero atom on 2
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%    % left type
\fi%
% hetero atom on 7a
{\let\fff=\jjj%
\ifx\fff\empty\else%
     \global\@jcliptrue%
     \putlatom{135}{-211}{\jjj}%   % left type
\fi}%
% hetero atom on 7
{\let\aaa=\hhh%
\ifx\aaa\empty\else%
     \global\@hcliptrue%
     \putlatom{50}{-378}{\hhh}%    % left type
%     \putlatom{60}{-378}{\hhh}%    % left type
\fi}%
% hetero atom on 6
{\let\fff=\ggg%
\ifx\fff\empty\else%
     \global\@gcliptrue%
     \putlatom{135}{-553}{\ggg}%   % left type
\fi}%
% hetero atom on 5
{\let\eee=\fff%
\ifx\eee\empty\else%
     \global\@fcliptrue%
     \putratom{273}{-553}{\fff}%   % left type
\fi}%
% hetero atom on 4
{\let\ddd=\eee%
\ifx\ddd\empty\else%
   \global\@ecliptrue%
   \putratom{356}{-378}{\eee}%     % right type
%   \putratom{346}{-378}{\eee}%     % right type
\fi}%
% hetero atom on 3a
{\let\eee=\iii%
\ifx\eee\empty\else%
     \global\@icliptrue%
     \putratom{273}{-211}{\iii}%   % right type
\fi}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents and exocyclic bonds %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\put(0,0){\setsixringh{#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,-342){\setsixringh{#3}{0}{3}{7}{0}}%
}%
{\@aclipfalse \if@hclip \@acliptrue \fi%   %substituent on 7
\put(0,-342){\setsixringh{#3}{-6}{0}{2}{0}}%
}%
{\@clipfusefalse \if@iclip \@clipfusetrue \fi%
 \put(303,-171){\setatombond{#3}{-7}{4}}%  %8 for 3a position
}%
{\@clipfusefalse \if@jclip \@clipfusetrue \fi%
  \put(103,-171){\setatombond{#3}{-8}{10}}%%9 for 7a position
}%
\end{picture}\iniatom\iniflag}%      %end of \nonaheterohi macro
%
% **********************************************************
% * heterocycles having fused six- and five-membered rings *
% *  (horizontal type)                                     *
% **********************************************************
%
%   N-heterocycles:
%
%   \indoleh[BONDLIST]{SUBSLIST}
%   \indolehi[BONDLIST]{SUBSLIST}
%
%   \isoindoleh[BONDLIST]{SUBSLIST}
%   \isoindolehi[BONDLIST]{SUBSLIST}
%
%   \indolizineh[BONDLIST]{SUBSLIST}
%   \indolizinehi[BONDLIST]{SUBSLIST}
%          (different from the IUPAC numbering)
%
%   \purineh[BONDLIST]{SUBSLIST}
%   \purinehi[BONDLIST]{SUBSLIST}
%          (different from the IUPAC numbering)
%
%   O-heterocycles:
%
%   \benzofuraneh[BONDLIST]{SUBSLIST}
%   \benzofuranehi[BONDLIST]{SUBSLIST}
%
%   \isobenzofuranehi[BONDLIST]{SUBSLIST}
%
%   \benzoxazoleh[BONDLIST]{SUBSLIST}
%   \benzoxazolehi[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. 
%        
%        \indoleh{1==N}{1==Cl;2==F}
%        \indoleh[c]{1==N}{1==Cl;4==F;2==CH$_{3}$}
%
\def\purineh{\@ifnextchar[{\@purineh}{\@purineh[ra]}}%
\def\@purineh[#1]#2{%
\iforigpt \typeout{command `purineh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{1==N;3==N;5==N;7==N}{#2}}%
\def\purinehi{\@ifnextchar[{\@purinehi}{\@purinehi[ra]}}%
\def\@purinehi[#1]#2{%
\iforigpt \typeout{command `purinehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{1==N;3==N;5==N;7==N}{#2}}%
%
\def\indoleh{\@ifnextchar[{\@indoleh}{\@indoleh[rb]}}%
\def\@indoleh[#1]#2{%
\iforigpt \typeout{command `indoleh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{1==N}{#2}}%
\def\indolehi{\@ifnextchar[{\@indolehi}{\@indolehi[rb]}}%
\def\@indolehi[#1]#2{%
\iforigpt \typeout{command `indolehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{1==N}{#2}}%
%
\def\indolizineh{\@ifnextchar[{\@indolizineh}{\@indolizineh[aceg]}}%
\def\@indolizineh[#1]#2{%
\iforigpt \typeout{command `indolizineh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{7a==N}{#2}}%
\def\indolizinehi{\@ifnextchar[{\@indolizinehi}{\@indolizinehi[aceg]}}%
\def\@indolizinehi[#1]#2{%
\iforigpt \typeout{command `indolizinehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{7a==N}{#2}}%
%
\def\isoindoleh{\@ifnextchar[{\@isoindoleh}{\@isoindoleh[cegi]}}%
\def\@isoindoleh[#1]#2{%
\iforigpt \typeout{command `isoindoleh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{2==N}{#2}}%
\def\isoindolehi{\@ifnextchar[{\@isoindolehi}{\@isoindolehi[cegi]}}%
\def\@isoindolehi[#1]#2{%
\iforigpt \typeout{command `isoindolehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{2==N}{#2}}%
%
\def\benzofuraneh{\@ifnextchar[{\@benzofuraneh}{\@benzofuraneh[rb]}}%
\def\@benzofuraneh[#1]#2{%
\iforigpt \typeout{command `benzofuraneh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{1==O}{#2}}%
\def\benzofuranehi{\@ifnextchar[{\@benzofuranehi}{\@benzofuranehi[rb]}}%
\def\@benzofuranehi[#1]#2{%
\iforigpt \typeout{command `benzofuranehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{1==O}{#2}}%
%
\def\isobenzofuraneh{\@ifnextchar[{\@isobenzofuraneh}%
 {\@isobenzofuraneh[cegi]}}%
\def\@isobenzofuraneh[#1]#2{%
\iforigpt \typeout{command `isobenzofuraneh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{2==O}{#2}}%
\def\isobenzofuranehi{\@ifnextchar[{\@isobenzofuranehi}%
 {\@isobenzofuranehi[cegi]}}%
\def\@isobenzofuranehi[#1]#2{%
\iforigpt \typeout{command `isobenzofuranehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{2==O}{#2}}%
%
\def\benzoxazoleh{\@ifnextchar[{\@benzoxazoleh}{\@benzoxazoleh[rb]}}%
\def\@benzoxazoleh[#1]#2{%
\iforigpt \typeout{command `benzoxazoleh' is based on `nonaheteroh'.}\fi%
\nonaheteroh[#1]{1==O;3==N}{#2}}%
\def\benzoxazolehi{\@ifnextchar[{\@benzoxazolehi}{\@benzoxazolehi[rb]}}%
\def\@benzoxazolehi[#1]#2{%
\iforigpt \typeout{command `benzoxazolehi' is based on `nonaheterohi'.}\fi%
\nonaheterohi[#1]{1==O;3==N}{#2}}%
%
% **********************
% * six-membered unit  *
% *  (horizontal 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. 
%
%                                   b
%                                2      3  
%                            a    -----    c
%                               *       *
%   the original point ===> 1 *           * 4
%          (0,0)                *       *  d
%                            f    -----
%                                6      5 
%                                   e
%
%   \sixunith[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\sixunith{\@ifnextchar[{\@sixunith}{\@sixunith[r]}}
\def\@sixunith[#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)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `sixunith' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\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\hskbonda\fi% bond between 1 and 2
\if\@bbb b\relax\hskbondb\fi% bond between 2 and 3
\if\@ccc c\relax\hskbondc\fi% bond between 3 and 4
\if\@ddd d\relax\hskbondd\fi% bond between 4 and 5
\if\@eee e\relax\hskbonde\fi% bond between 5 and 6
\if\@fff f\relax\hskbondf\fi% bond between 6 and 1
}%
%\ifx#4a\relax \else%
% \hskbonda% bond between 1 and 2
%\fi%
%\ifx#4f\relax \else%
% \hskbondf% bond between 1 and 6
%\fi%
%\ifx#4c\relax \else%
% \hskbondc% bond between 4 and 3
%\fi%
%\ifx#4d\relax \else%
% \hskbondd% bond between 4 and 5
%\fi%
%\ifx#4b\relax \else%
% \hskbondb% bond between 3 and 2
%\fi%
%\ifx#4e\relax \else%
% \hskbonde% 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%
  \hbonda%
 \fi%
\else \if\member b\relax%
 \ifx#4b\relax \else%
   \hbondb%
 \fi%
\else \if\member c\relax%
 \ifx#4c\relax \else%
   \hbondc%
 \fi%
\else \if\member d\relax%
 \ifx#4d\relax \else%
   \hbondd%
 \fi%
\else \if\member e\relax%
 \ifx#4e\relax \else%
   \hbonde%
 \fi%
\else \if\member f\relax%
 \ifx#4f\relax \else%
   \hbondf%
 \fi%
\else \if\member A%left aromatic circle 
  \put(203,0){\circle{240}}%                %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 4\relax%
        \putratom{272}{-18}{\@@tmpb}%       % right type
      \else\if\@@tmpa 1\relax%
        \putratom{68}{-18}{\@@tmpb}%        % right type
      \else\if\@@tmpa 3\relax
        \putratom{233}{60}{\@@tmpb}%        % right type
      \else\if\@@tmpa 2\relax%
        \putratom{120}{60}{\@@tmpb}%        % right type
      \else\if\@@tmpa 5\relax%
        \putratom{233}{-110}{\@@tmpb}%      % right type
      \else\if\@@tmpa 6\relax%
        \putratom{120}{-110}{\@@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{346}{-36}{\ddd}%               % right type
\fi%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{60}{-36}{\aaa}%              % left type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%             % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%             % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%            % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%            % right type
\fi%
\setsixringh{#3}{0}{0}{7}{0}%
\end{picture}\iniatom\iniflag}%     %end of \sixunith macro
%
% **********************
% * five-membered unit *
% *  (horizontal 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. 
%
%     3  _____  2
%       |       *
%       |         * 1 <===== the original point
%       |       *
%     4  -----  5
%
%   \fiveunith[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
%           A          :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%           {0+}       :  plus (or others) 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
%
%     OMIT:  one bond omitted (a, b, c, d, e, or f)
%
%       e.g. 
%        
%        \fiveunith{1==N}{1==H;2==F}{a}
%
\def\fiveunith{\@ifnextchar[{\@fiveunith}{\@fiveunith[r]}}
\def\@fiveunith[#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)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveunith' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\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\hskbondc\fi% bond between 1 and 2
\if\@bbb b\relax\hskbondb\fi% bond between 2 and 3
\if\@ccc c\relax\hskbondvert\fi% bond between 3 and 4
\if\@ddd d\relax\hskbonde\fi% bond between 4 and 5
\if\@eee e\relax\hskbondd\fi% bond between 5 and 6
%\if\@fff f\relax\hskbondf\fi% bond between 6 and 1
}%
% old
%\ifx#4a\relax\else%
% \hskbondc%bond between 1 and 2
%\fi%
%\ifx#4e\relax\else%
% \hskbondd%bond between 1 and 5
%\fi%
%\ifx#4b\relax\else%
%  \hskbondb%bond between 2 to 3
%\fi%
%\ifx#4d\relax\else%
% \hskbonde%bond between 5 and 4
%\fi%
%\ifx#4c\relax\else%
% \hskbondvert%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%
   \hbondc%
 \fi%
\else \if\member b\relax%
 \ifx#4b\relax\else%
  \hbondb%
 \fi%
\else \if\member c\relax%
 \ifx#4c\relax\else%
   \hbondvert%
 \fi%
\else \if\member d\relax%
 \ifx#4d\relax\else%
  \hbonde%
 \fi%
\else \if\member e\relax%
 \ifx#4e\relax\else%
  \hbondd%
 \fi%
\else \if\member A%left aromatic circle 
  \put(233,0){\circle{180}}%               %circle
\else \expandafter\twoch@@r\member{}{}%
      \if\@@tmpa 1\relax%
        \putratom{272}{-18}{\@@tmpb}%      % right type
      \else\if\@@tmpa 2\relax%
        \putratom{233}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 3\relax%
        \putratom{120}{60}{\@@tmpb}%       % right type
      \else\if\@@tmpa 5\relax%
        \putratom{233}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 4\relax%
        \putratom{120}{-110}{\@@tmpb}%     % right type
      \else\if\@@tmpa 0\relax%
        \putratom{196}{-30}{\@@tmpb}%      % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\ddd\empty\else%
   \@cliptrue%
   \putratom{346}{-36}{\ddd}%              % right type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%            % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%            % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%           % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%           % right type
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringh{#3}{5}{1}{5}{-1}%   % for 1 to 3
\setsixringh{#3}{10}{4}{7}{-1}%  % for 4 to 5
\end{picture}\iniatom\iniflag}%  %end of \fiveunith macro
%
% ************************************
% * five-membered unit               *
% *  (horizontal 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. 
%
%                       2  -----  3
%                        *       |
% the original point 1 *         |
%                        *       |
%                           _____|
%                        5        4
%
%   \fiveunithi[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
%           A          :  aromatic circle
%           {n+}       :  plus at the n-nitrogen atom (n = 1 to 4)
%           {0+}       :  plus (or others) 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
%
%     OMIT:  one bond omitted (a, b, c, d, e, or f)
%
%       e.g. 
%        
%        \fiveunithi{1==N}{1==H;2==F}{a}
%
\def\fiveunithi{\@ifnextchar[{\@fiveunithi}{\@fiveunithi[r]}}%
\def\@fiveunithi[#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)(-240,-400)%
  \iforigpt \put(-\shifti,-\shiftii){\circle*{50}}%
           \put(-\noshift,-\noshift){\circle{50}}% 
   \typeout{command `fiveunithi' origin: %
    (\the\noshift,\the\noshift) ---> (\the\shifti,\the\shiftii)}\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\hskbonda\fi% bond between 1 and 2
\if\@bbb b\relax\hskbondb\fi% bond between 2 and 3
\if\@ccc c\relax\hskbondverti\fi% bond between 3 and 4
\if\@ddd d\relax\hskbonde\fi% bond between 4 and 5
\if\@eee e\relax\hskbondf\fi% bond between 5 and 6
%\if\@fff f\relax\hskbondf\fi% bond between 6 and 1
}%
% old
%\ifx#4a\relax\else%
% \hskbonda%bond between 1 and 2
%\fi%
%\ifx#4e\relax\else%
% \hskbondf%bond between 1 and 5
%\fi%
%\ifx#4b\relax\else%
%  \hskbondb%bond between 2 to 3
%\fi%
%\ifx#4d\relax\else%
% \hskbonde%bond between 5 and 4
%\fi%
%\ifx#4c\relax\else%
% \hskbondverti%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%
   \hbonda%
 \fi%
\else \if\member b\relax%
 \ifx#4b\relax\else%
  \hbondb%
 \fi%
\else \if\member c\relax%
 \ifx#4c\relax\else%
   \hbondverti%
 \fi%
\else \if\member d\relax%
 \ifx#4d\relax\else%
  \hbonde%
 \fi%
\else \if\member e\relax%
 \ifx#4e\relax\else%
  \hbondf%
 \fi%
\else \if\member A%left aromatic circle 
  \put(173,0){\circle{180}}%                %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{140}{-30}{\@@tmpb}%       % right type
      \fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi}%
%%%%%%%%%%%%%%%%%%%%%%%
% setting heteroatoms %
%%%%%%%%%%%%%%%%%%%%%%%
\ifx\aaa\empty\else%
     \@acliptrue%
     \putlatom{60}{-36}{\aaa}%              % left type
\fi%
\ifx\bbb\empty\else%
     \@bcliptrue%
     \putlatom{135}{141}{\bbb}%             % left type
\fi%
\ifx\ccc\empty\else%
     \@ccliptrue%
     \putratom{273}{141}{\ccc}%             % right type
\fi%
\ifx\fff\empty\else%
     \@fcliptrue%
     \putlatom{135}{-211}{\fff}%            % left type
\fi%
\ifx\eee\empty\else%
     \@ecliptrue%
     \putratom{273}{-211}{\eee}%            % right type
\fi%
%%%%%%%%%%%%%%%%%%%%%%%%
% setting substituents %
%%%%%%%%%%%%%%%%%%%%%%%%
\setsixringh{#3}{0}{0}{4}{0}%  % for 1 to 3
\setsixringh{#3}{1}{4}{7}{0}%  % for 4 to 5
\end{picture}\iniatom\iniflag}%      %end of \fiveunithi macro

