%%% -*- mode: LaTeX; fill-column: 78; tab-width: 4; coding: euc-jp; -*-
%%% OhTeX.sty -- Style file to print shogi board.
%%% This file is part of OhTeX Ver.2.3
%%%	Copyright (C) 1991, 1995, 1998 Electrotechnical Laboratory, JAPAN
%%%	Written by K. Handa <handa@etl.go.jp>,
%%%		   F. Motoyoshi <moto@etl.go.jp>, and
%%%		   H. Matsubara <matsubar@etl.go.jp>
%%%
%%%	This software is distributed in the hope that it will be useful,
%%%	but WITHOUT ANY WARRANTY.
%%%	Permission is granted to any individual or institution to use, copy,
%%%	modify, or redistribute this software so long as it is not sold for
%%%	profit, provided that this notice and the original copyright notices
%%%	are retained.  
%%%
%%% HISTORY
%%%	91.10.9  Ver.0.9 (beta)
%%%	95.3.8   Ver.2.0
%%%	95.5.8   Ver.2.1 (modified for NFSS)
%%%	98.10.8  Ver.2.2 (modified for LaTeX2e)
%%%	98.10.14 Ver.2.3 (bug fix)

\typeout{OhTeX Ver.2.3 (98.10.14)}

%%% Usage: \documentstyle[...,OhTeX]{...}

% This file should be loaded after art10.sty, art12.sty, etc.
% because \ixpt, \xpt ... are redefined in this file.

\def\OhTeX{{\rm	O\kern-.05em\lower.3ex\hbox{h}\kern-.2em\TeX }}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Japanese TeX or not?
%%%    If we are using Japanese TeX, we need special
%%%    treatment for KINSOKU characters.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifJTEX
\newif\ifNTTJTEX
\ifx\dg\undefined		% \dg is a command of NTT jTeX
  \ifx\gt\undefined		% \gt is a command of ASCII jTeX and pTeX
    \JTEXfalse\NTTJTEXfalse
  \else
    \JTEXtrue\NTTJTEXfalse
	\let\dm=\mc\let\dg=\gt
  \fi
\else
  \JTEXtrue\NTTJTEXtrue
\fi

\newif\ifAlphabetOrdinate
\newif\ifChessStyle
\def\AlphabetOrdinate{\AlphabetOrdinatetrue}
\def\KanjiOrdinate{\AlphabetOrdinatefalse}
\def\ChessStyle{\AlphabetOrdinatetrue\ChessStyletrue}
\def\KanjiStyle{\AlphabetOrdinatefalse\ChessStylefalse}
\let\ChesslikeStyle=\ChessStyle
\def\ifChesslikeStyle{\ifChessStyle}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% FONT
%%%    For the moment, font for OhTeX is designed only for
%%%    10pt (shogi10.mf).  So we must use it for all sizes.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Although the original \magstep can only handle up to
%% scale5, OhTeX uses up to scale7.  So we redefined it
%% here. 
\def\magstep#1{\ifcase#1 \@m\or 1200\or 1440\or 1728\or 2074\or 2488\or 2986
	\or 3583\fi\relax}

\@ifundefined{@addfontinfo}{
\@ifundefined{DeclareFontFamily}{
\typeout{Using NFSS with LaTeX Ver.2.09 ...}
\new@fontshape{sh}{m}{n}{
	<5>shogi10 at5pt
	<6>shogi10 at6pt
	<7>shogi10 at7pt
	<8>shogi10 at8pt
	<9>shogi10 at9pt
	<10>shogi10
	<11>shogi10 at10.95pt
	<12>shogi10 at12pt
	<14>shogi10 at14.4pt
	<17>shogi10 at17.28pt
	<20>shogi10 at20.74pt
	<25>shogi10 at24.88pt
	<30>shogi10 at35.83pt}{}
\def\shdefault{sh}
\def\psh{\family\shdefault\selectfont}
\def\shsize#1{\size{#1}{#1pt}\sh}
%% \sh is used to change the current font to shogi font.
\def\sh{\protect\psh}
%% The maximum size provided by the original LaTeX is
%% \Huge.  But OhTeX uses the larger one.
\def\HUGE{\@setsize\HUGE{48pt}\xxxvipt\@xxxvipt}
}{
\typeout{Using LaTeX2e ...}
\DeclareFontFamily{OT1}{sh}{}
\DeclareFontShape{OT1}{sh}{m}{n}{
	<5>shogi10
	<6>shogi10
	<7>shogi10
	<8>shogi10
	<9>shogi10
	<10>shogi10
	<11>shogi10
	<12>shogi10
	<14>shogi10
	<17>shogi10
	<20>shogi10
	<25>shogi10
	<30>shogi10}{}
%% \sh is used to change the current font to shogi font.
\def\sh{\fontfamily{sh}\selectfont}
\def\shsize#1{\fontsize{#1}{#1}\sh}
%% The maximum size provided by the original LaTeX is
%% \Huge.  But OhTeX uses the larger one.
\def\@xxxvipt{35.83}
\def\HUGE{\@setsize\HUGE{48pt}\xxxvipt\@xxxvipt}
}}{
\typeout{Using LaTeX 2.09 ...}
%% Font definitions from \fivsh to \thsxsh.
\newfont{\fivsh}{shogi10 \@ptscale5}
\newfont{\sixsh}{shogi10 \@ptscale6}
\newfont{\sevsh}{shogi10 \@ptscale7}
\newfont{\egtsh}{shogi10 \@ptscale8}
\newfont{\ninsh}{shogi10 \@ptscale9}
\newfont{\tensh}{shogi10}
\newfont{\elvsh}{shogi10 \@halfmag}
\newfont{\twlsh}{shogi10 \@magscale1}
\newfont{\frtsh}{shogi10 \@magscale2}
\newfont{\svtsh}{shogi10 \@magscale3}
\newfont{\twtysh}{shogi10 \@magscale4}
\newfont{\twfvsh}{shogi10 \@magscale5}
\newfont{\thsxsh}{shogi10 \@magscale7}

\@addfontinfo\@vpt{\def\psh{\fivsh}}
\@addfontinfo\@vipt{\def\psh{\sixsh}}
\@addfontinfo\@viipt{\def\psh{\sevsh}}
\@addfontinfo\@viiipt{\def\psh{\egtsh}}
\@addfontinfo\@ixpt{\def\psh{\ninsh}}
\@addfontinfo\@xpt{\def\psh{\tensh}}
\@addfontinfo\@xipt{\def\psh{\elvsh}}
\@addfontinfo\@xiipt{\def\psh{\twlsh}}
\@addfontinfo\@xivpt{\def\psh{\frtsh}}
\@addfontinfo\@xviipt{\def\psh{\svtsh}}
\@addfontinfo\@xxpt{\def\psh{\twtysh}}
\@addfontinfo\@xxvpt{\def\psh{\twfvsh}}
\def\xxxvipt{}
\def\@xxxvipt{}
\@addfontinfo\@xxxvipt{\def\psh{\thsxsh}}
%% \sh is used to change the current font to shogi font.
\def\sh{\protect\psh}
\def\shsize#1{\csname @\romannumeral#1pt\endcsname}
%% The maximum size provided by the original LaTeX is
%% \Huge.  But OhTeX uses the larger one.
\def\HUGE{\@setsize\HUGE{48pt}\xxxvipt\@xxxvipt}
}

\let\giant=\HUGE		% for backward compatibility

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Declaration of variables (counter and dimensions)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\x
\newcount\y
\newcount\z
\newcount\w
\newcount\h
\newcount\cx
\newcount\cxx
\newcount\cy
\newcount\cyy
\newcount\ch
\newcount\chh
\newcount\cw
\newcount\cww
\newcount\cmochi
\newcount\cmochii
\newcount\cmochix
\newcount\cmochiy
\newcount\cmochixx
\newcount\cmochiyy
\newcount\cmochiybase
\newcount\cmochiyybase

\newdimen\thickaxis
\newdimen\thinaxis

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Definition of characters in shogi font
%%%     Convention of namings:
%%%	  XXXX and xxxx are for normal characters.
%%%       Xxxx are for upside-down characters of the
%%%       corresponding XXXX or xxxx.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% \symbol{0} through \symbol{29} are for real KOMA shapes.
%% \symbol{30} through \symbol{39} are for mask of the above.

\def\mochi{\ifChessStyle\else{\sh\symbol{40}}\fi}
\def\Mochi{\ifChessStyle\else{\sh\symbol{41}}\fi}
\def\goma{\ifChessStyle\else{\sh\symbol{42}}\fi}
\def\Goma{\ifChessStyle\else{\sh\symbol{43}}\fi}
\def\na{\ifChessStyle\else{\sh\symbol{44}}\fi}
\def\Na{\ifChessStyle\else{\sh\symbol{45}}\fi}
\def\si{\ifChessStyle\else{\sh\symbol{46}}\fi}
\def\Si{\ifChessStyle\else{\sh\symbol{47}}\fi}

%% \symbol{48} through \symbol{67} are for arabic numbers.
%% Example: \num2 => arabic number two
%%          \Num2 => upside down of arabic number two.
\def\num#1{\w=#1\multiply\w by2 \advance\w by48 \mbox{\sh\char\w}}
\def\Num#1{\w=#1\multiply\w by2 \advance\w by49 \mbox{\sh\char\w}}

%% \symbol{68} through \symbol{77} are for chinese numbers.
%% Example: \jnum2 => chinese number two
\def\jnum#1{\w=#1%
		\advance\w by 96\mbox{\tt\char\w}%
}

%% \symbol{80} through \symbol{109} are for KOMA.
\def\komasymbol#1{\ifChessStyle\w=80 \else\w=0 \fi
	\advance\w by #1\char\w}

\def\OU{\mbox{\sh\komasymbol{80}}}
\def\Ou{\mbox{\sh\komasymbol{81}}}
\def\GY{\mbox{\sh\komasymbol{82}}}
\def\Gy{\mbox{\sh\komasymbol{83}}}
\def\HI{\mbox{\sh\komasymbol{84}}}
\def\Hi{\mbox{\sh\komasymbol{85}}}
\def\KA{\mbox{\sh\komasymbol{86}}}
\def\Ka{\mbox{\sh\komasymbol{87}}}
\def\KI{\mbox{\sh\komasymbol{88}}}
\def\Ki{\mbox{\sh\komasymbol{89}}}
\def\GI{\mbox{\sh\komasymbol{90}}}
\def\Gi{\mbox{\sh\komasymbol{91}}}
\def\KE{\mbox{\sh\komasymbol{92}}}
\def\Ke{\mbox{\sh\komasymbol{93}}}
\def\KY{\mbox{\sh\komasymbol{94}}}
\def\Ky{\mbox{\sh\komasymbol{95}}}
\def\FU{\mbox{\sh\komasymbol{96}}}
\def\Fu{\mbox{\sh\komasymbol{97}}}
\def\RY{\mbox{\sh\komasymbol{98}}}
\def\Ry{\mbox{\sh\komasymbol{99}}}
\def\UM{\mbox{\sh\komasymbol{100}}}
\def\Um{\mbox{\sh\komasymbol{101}}}
\def\NG{\mbox{\sh\komasymbol{102}}}
\def\Ng{\mbox{\sh\komasymbol{103}}}
\def\NK{\mbox{\sh\komasymbol{104}}}
\def\Nk{\mbox{\sh\komasymbol{105}}}
\def\NY{\mbox{\sh\komasymbol{106}}}
\def\Ny{\mbox{\sh\komasymbol{107}}}
\def\TO{\mbox{\sh\komasymbol{108}}}
\def\To{\mbox{\sh\komasymbol{109}}}

\def\OUx{{\sh\komasymbol{80}\tt x}}
\def\GYx{{\sh\komasymbol{82}\tt x}}
\def\HIx{{\sh\komasymbol{84}\tt x}}
\def\KAx{{\sh\komasymbol{86}\tt x}}
\def\KIx{{\sh\komasymbol{88}\tt x}}
\def\GIx{{\sh\komasymbol{90}\tt x}}
\def\KEx{{\sh\komasymbol{92}\tt x}}
\def\KYx{{\sh\komasymbol{94}\tt x}}
\def\FUx{{\sh\komasymbol{96}\tt x}}
\def\RYx{{\sh\komasymbol{98}\tt x}}
\def\UMx{{\sh\komasymbol{100}\tt x}}
\def\NGx{{\sh\komasymbol{102}\tt x}}
\def\NKx{{\sh\komasymbol{104}\tt x}}
\def\NYx{{\sh\komasymbol{106}\tt x}}
\def\TOx{{\sh\komasymbol{108}\tt x}}

%% \symbol{110} throught \symbol{121} are used to denote KIFU.
\def\migi{\mbox{\sh\symbol{110}}}
\def\hidari{\mbox{\sh\symbol{111}}}
\def\yoru{\mbox{\sh\symbol{112}}}
\def\iku{\mbox{\sh\symbol{113}}}
\def\choku{\mbox{\sh\symbol{114}}}
\def\hiku{\mbox{\sh\symbol{115}}}
\def\agaru{\mbox{\sh\symbol{116}}}
\def\ai{\mbox{\sh\symbol{117}}}
\def\da{\mbox{\sh\symbol{118}}}
\def\fu{\mbox{\sh\symbol{119}}}
\def\dou{\mbox{\sh\symbol{120}}}
\def\nari{\mbox{\sh\symbol{121}}}

%% \symbol{122} and \symbol{123} are used to denote SENTE.
\def\sirokoma{\ifChessStyle\else\mbox{\sh\symbol{122}}\fi}
\def\Sirokoma{\ifChessStyle\else\mbox{\sh\symbol{123}}\fi}
%% \symbol{124} and \symbol{125} are used to denote GOTE.
\def\kurokoma{\ifChessStyle\else\mbox{\sh\symbol{124}}\fi}
\def\Kurokoma{\ifChessStyle\else\mbox{\sh\symbol{125}}\fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Macros to print KIFU (棋譜)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Example: \siro23{\KI} \kuro44{\HI\da}

\def\kifuhead{\hspace*{2pt}}
\def\kifutail{}

\def\siro#1#2#3{\kifuhead\sirokoma\num{#1}\jnum{#2}{#3}\kifutail}
\def\kuro#1#2#3{\kifuhead\kurokoma\num{#1}\jnum{#2}{#3}\kifutail}
\def\Siro#1{\kifuhead\sirokoma{#1}\kifutail}
\def\Kuro#1{\kifuhead\kurokoma{#1}\kifutail}

\newcount\mvcount\mvcount=1
\def\mv{\@ifnextchar ,{\mvvv}{\mvv}}
\def\mvv#1,{\global\mvcount=#1\mvvv,}
\def\mvvv,{{\hspace{0.5em}\bf\the\mvcount.\kern0.2em}\global\advance\mvcount1\mvx}
\def\mvx{\@ifnextchar ,{...\mvxxx\@gobble}{\mvxx}}
\def\mvxx#1,{{\tt#1}\mvxxx}
\def\mvxxx{\@ifnextchar .{\@gobble}{\mvxxxx}}
\def\mvxxxx#1.{{\kern0.2em\tt#1}}

\def\kifu{\@ifnextchar [{\@kifu}{\@kifu[1]}}
\def\@kifu[#1]{\global\mvcount=#1\begin{tabular}{llllllll}}
\def\endkifu{\end{tabular}}
\let\score=\kifu
\let\endscore=\endkifu

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Macros to print SHOGIBAN (将棋盤)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\shogiban#1{\shogibanmain{1}{9}{1}{9}{0}{0}{#1}}

\def\Shogiban#1{\shogibanmain{1}{9}{1}{9}{1}{0}{#1}}

\def\SHOGIBAN#1{\shogibanmain{1}{9}{1}{9}{2}{0}{#1}}

\def\tsumeshogi#1#2#3#4#5{\shogibanmain{#1}{#2}{#3}{#4}{0}{1}{#5}}

\def\Tsumeshogi#1#2#3#4#5{\shogibanmain{#1}{#2}{#3}{#4}{1}{1}{#5}}

\def\TSUMESHOGI#1#2#3#4#5{\shogibanmain{#1}{#2}{#3}{#4}{2}{1}{#5}}

\newcommand{\shogibanmain}[7]{
%% 筋#1から#2、段#3から#4の将棋盤を作る
%% 原点 (0,0): 桝目９九の左下座標
%% (\cx,\cy): 桝目#2#4の左下座標, \cxx=\cx-10, \cyy=\cy-10
%% (\cw-\cx,\ch-\cy): 桝目#1#3の右上座標, \cww=\cw+20, \chh=\ch+20
%% \cmochi: 自分の持駒数  \cmochii: 相手の持駒数
%% (\cmochix,\cmochiy): 自分の持駒表示座標
%% (\cmochixx,\cmochiyy): 相手の持駒表示座標
%% #5: 0/小 1/中 2/大
%% #6: 0/全盤面 1/詰め将棋盤面
%% #7: 駒位置、持ち駒
\ifcase#5			% #5==0/小
  \unitlength=0.1mm
  \def\axissize{8} \def\mochigomasize{9} \def\komasize{12}
  \thinaxis=0.1mm \thickaxis=0.3mm
\or				% #5==1/中
  \unitlength=0.2mm
  \def\axissize{14} \def\mochigomasize{20} \def\komasize{25}
  \thinaxis=0.2mm \thickaxis=0.5mm
\else				% #5>=2/大
  \unitlength=0.3mm
  \def\axissize{17} \def\mochigomasize{25} \def\komasize{36}
  \thinaxis=0.3mm \thickaxis=0.8mm
\fi
\cx=9 \advance\cx by -#2 \multiply\cx by 50
\cxx=\cx
\cy=9 \advance\cy by -#4 \multiply\cy by 50
\cyy=\cy
\cw=#2 \advance\cw by -#1 \advance\cw by 1 \multiply\cw by 50
\cww=\cw \advance\cww by 100
\ifnum#6=0 \advance\cxx by -50\advance\cww by 50\fi
\ch=#4 \advance\ch by -#3 \advance\ch by 1 \multiply\ch by 50
\chh=\ch \advance\chh by 50
\ifnum#1>1 \advance\cww by 10 \fi
\ifnum#2=9
  \ifnum#1>1 \advance\cxx by -50 \fi
\else 
  \advance\cww by 10 \advance\cxx by -10
\fi
\ifnum#3>1 \advance\chh by 10 \fi
\ifnum#4=9
  \ifnum#3>1 \advance\chh by 40 \advance\cyy by -50 \fi
\else
  \advance\chh by 10 \advance\cyy by -10
\fi
\begin{picture}(\cww,\chh)(\cxx,\cyy)
%% 盤面表示
\x=\cx \y=\cy \w=\cw \h=\ch
\ifnum#1>1 \advance\w by 10 \fi
\ifnum#2<9 \advance\w by 10 \advance\x by -10 \fi
\ifnum#3>1 \advance\h by 10 \fi
\ifnum#4<9 \advance\h by 10 \advance\y by -10 \fi
\z=#2 \advance\z by 2
{\loop\ifnum\z>#1
  \linethickness{
    \ifnum\z=11 \thickaxis\else\ifnum\z=2 \thickaxis\else\thinaxis\fi\fi}
  \put(\cx,\y){\line(0,1){\h}}
  \advance\cx by 50 \advance\z by -1
\repeat}
\z=#4 \advance\z by 2
{\loop\ifnum\z>#3
  \linethickness{
    \ifnum\z=11 \thickaxis\else\ifnum\z=2 \thickaxis\else\thinaxis\fi\fi}
  \put(\x,\cy){\line(1,0){\w}}
  \advance\cy by 50 \advance\z by -1
\repeat}
\put(0,0){\line(0,1){0}}
%% 座標表示
\shsize{\axissize}
{
\advance\cx by 25
\ifnum#4<9
  \advance\cy by\ch \advance\cy by 15
\else\ifnum#3=1
  \advance\cy by\ch \advance\cy by 15
\else
  \advance\cy by -30
\fi\fi
\z=#2 \advance\z by 1
\loop\ifnum\z>#1
  \advance\z by -1
  \put(\cx,\cy){\makebox[0mm]{\num\z}}
  \advance\cx by 50
\repeat
}{
\advance\cy by 15
\ifnum#2<9
  \advance\cx by\cw \advance\cx by 30
\else\ifnum#1=1
  \advance\cx by\cw \advance\cx by 30
\else
  \advance\cx by -25
\fi\fi
\z=#4 \advance\z by 1
\loop\ifnum\z>#3
  \advance\z by -1
  \put(\cx,\cy){\makebox[0mm]{\jnum\z}}
  \advance\cy by 50
\repeat
}
%% 「持駒」表示
\shsize{\mochigomasize}
\cmochix=\cx \advance\cmochix by\cw \advance\cmochix by 40
\cmochixx=\cx \advance\cmochixx by -30
\ifnum#2<9
  \advance\cmochix by 40
\else\ifnum#1=1
  \advance\cmochix by 40
\else
  \advance\cmochixx by -40
\fi\fi
\cmochiy=\cy \advance\cmochiy by\ch
\ifnum\ch>400
  \advance\cmochiy by -50
\fi
\put(\cmochix,\cmochiy){\makebox[0mm]{\kurokoma}}
%\advance\cmochiy by -35
%\put(\cmochix,\cmochiy){\makebox[0mm]{\mochi}}
%\advance\cmochiy by -35
%\put(\cmochix,\cmochiy){\makebox[0mm]{\goma}}
\advance\cmochiy by -50
\cmochiyy=\cy \advance\cmochiyy by 30
\ifnum#6=0
  \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Sirokoma}}
%  \advance\cmochiyy by 35
%  \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Mochi}}
%  \advance\cmochiyy by 35
%  \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Goma}}
  \advance\cmochiyy by 50
\fi
\cmochiybase=\cmochiy \cmochiyybase=\cmochiyy
\cmochi=0 \cmochii=0
%% 駒配置と持ち駒表示
#7
%% 「なし」表示
\shsize{\mochigomasize}
%\ifnum\cmochi=0
%  \put(\cmochix,\cmochiy){\makebox[0mm]{\na}}
%  \advance\cmochiy by -40
%  \put(\cmochix,\cmochiy){\makebox[0mm]{\si}}
%\fi
%\ifnum#6=0\ifnum\cmochii=0
%  \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Na}}
%  \advance\cmochiyy by 40
%  \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Si}}
%\fi\fi
\end{picture}}

\def\koma#1#2#3{
	\shsize{\komasize}
	\x=9 \advance\x by -#1 \multiply\x by 50 \advance\x by 25
	\y=9 \advance\y by -#2 \multiply\y by 50 \advance\y by 10
	\put(\x,\y){\makebox[0mm]{#3}}
}

\def\mochigoma{\@ifnextchar [{\@mochigoma}{\@mochigoma[1]}}

\def\@mochigoma[#1]#2{
\shsize{\komasize}
{
\global\z=1
\ifx#2\Hi\global\z=0 \else
\ifx#2\Ka\global\z=0 \else
\ifx#2\Ki\global\z=0 \else
\ifx#2\Gi\global\z=0 \else
\ifx#2\Ke\global\z=0 \else
\ifx#2\Ky\global\z=0 \else
\ifx#2\Fu\global\z=0 \fi\fi\fi\fi\fi\fi\fi
}
\ifnum\z=0\relax
  \advance\cmochii by 1
  \w=\cy \advance\w by\ch
  \ifnum\cmochiyy>\w
    \cmochiyy=\cmochiyybase
    \advance\cmochixx by -50
  \fi
  \put(\cmochixx,\cmochiyy){\makebox[0mm]{#2}}
  \ifnum#1>1
    \advance\cmochiyy by 40
    \shsize{\axissize}
    \ifnum#1>9{
      \y=#1\advance\y-10\relax
      \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Num\y\Num1}}}
    \else{
      \advance\cmochixx by 2
      \put(\cmochixx,\cmochiyy){\makebox[0mm]{\Num#1}}}
    \fi
  \fi
  \advance\cmochiyy by 45
\else
  \advance\cmochi by 1
  \ifnum\cmochiy<\cy
    \cmochiy=\cmochiybase
    \advance\cmochix by 50
  \fi
  \put(\cmochix,\cmochiy){\makebox[0mm]{#2}}
  \ifnum#1>1
    \advance\cmochiy by -30
    \shsize{\axissize}
    \ifnum#1>9{
      \y=#1\advance\y-10\relax
      \put(\cmochix,\cmochiy){\makebox[0mm]{\num1\num\y}}}
    \else
      \put(\cmochix,\cmochiy){\makebox[0mm]{\num#1}}
    \fi
  \fi
  \advance\cmochiy by -45
\fi
}

%% 平手の駒配置
\def\komainit{
\koma11\Ky\koma21\Ke\koma31\Gi\koma41\Ki\koma51\Ou\koma61\Ki\koma71\Gi\koma81\Ke\koma91\Ky
\koma22\Ka\koma82\Hi
\koma13\Fu\koma23\Fu\koma33\Fu\koma43\Fu\koma53\Fu\koma63\Fu\koma73\Fu\koma83\Fu\koma93\Fu
\koma19\KY\koma29\KE\koma39\GI\koma49\KI\koma59\GY\koma69\KI\koma79\GI\koma89\KE\koma99\KY
\koma28\HI\koma88\KA
\koma17\FU\koma27\FU\koma37\FU\koma47\FU\koma57\FU\koma67\FU\koma77\FU\koma87\FU\koma97\FU
}
\let\hirate=\komainit

\ifJTEX
\input{OhTeX-jp.sty}
\fi
