2023/03/07
昔、作った LaTeX での 盤面表示 (承前)
前回は、サワリだけだったが、コンパイル出来るものを載せておこう。昔のママなのですこしく改良は必要だ。
盤面は、2種類用意してあるようだ。
また、持駒の表示は \shortstack を使い簡潔に行っている。
縦中横は \moti{P{18}} とする。
picture 環境を使っているので、描画の方法は、
\put(\thesuji,#2){\makebox(11,12){\sgtrans{\templist}}}%
なので、風さんのとそっくりだ。
\documentclass[twoside]{jbook}
\usepackage{multicol}
\usepackage{graphicx}
\textwidth=18cm
\textheight=25.5cm
%\textwidth=26cm
%\textheight=18cm
\setlength{\xkanjiskip}{0zw}
\oddsidemargin=-0.5cm
\evensidemargin=-1.5cm
\topmargin=-2.0cm
\renewcommand{\baselinestretch}{0.9}
\newcommand{\king}{\rotatebox[origin=c]{180}{玉}}
\newcommand{\rook}{\rotatebox[origin=c]{180}{飛}}
\newcommand{\dragon}{\rotatebox[origin=c]{180}{龍}}
\newcommand{\bishop}{\rotatebox[origin=c]{180}{角}}
\newcommand{\ma}{\rotatebox[origin=c]{180}{馬}}
\newcommand{\gold}{\rotatebox[origin=c]{180}{金}}
\newcommand{\silver}{\rotatebox[origin=c]{180}{銀}}
\newcommand{\prsilver}{\rotatebox[origin=c]{180}{全}}
\newcommand{\knight}{\rotatebox[origin=c]{180}{桂}}
\newcommand{\prknight}{\rotatebox[origin=c]{180}{圭}}
\newcommand{\lancer}{\rotatebox[origin=c]{180}{香}}
\newcommand{\prlancer}{\rotatebox[origin=c]{180}{杏}}
\newcommand{\pawn}{\rotatebox[origin=c]{180}{歩}}
\newcommand{\tokin}{\rotatebox[origin=c]{180}{と}}
\newcommand{\King}{玉}
\newcommand{\Rook}{飛}
\newcommand{\Dragon}{龍}
\newcommand{\Bishop}{角}
\newcommand{\Ma}{馬}
\newcommand{\Gold}{金}
\newcommand{\Silver}{銀}
\newcommand{\PrSilver}{全}
\newcommand{\Knight}{桂}
\newcommand{\PrKnight}{圭}
\newcommand{\Lancer}{香}
\newcommand{\PrLancer}{杏}
\newcommand{\Pawn}{歩}
\newcommand{\Tokin}{と}
\newcommand{\Space}{ }
\newcommand{\sgtrans}[1]{%
\if#1-\Space \fi%
\if#1k\king \fi%
\if#1r\rook \fi%
\if#1b\bishop \fi%
\if#1g\gold \fi%
\if#1s\silver \fi%
\if#1n\knight \fi%
\if#1l\lancer \fi%
\if#1p\pawn \fi%
\if#1d\dragon \fi%
\if#1m\ma \fi%
\if#1z\prsilver \fi%
\if#1y\prknight\fi%
\if#1x\prlancer \fi%
\if#1t\tokin \fi%
\if#1K\King \fi%
\if#1R\Rook \fi%
\if#1B\Bishop \fi%
\if#1G\Gold \fi%
\if#1S\Silver \fi%
\if#1N\Knight \fi%
\if#1L\Lancer \fi%
\if#1P\Pawn \fi%
\if#1D\Dragon \fi%
\if#1M\Ma \fi%
\if#1Z\PrSilver \fi%
\if#1Y\PrKnight\fi%
\if#1X\PrLancer \fi%
\if#1T\Tokin \fi%
}
\makeatletter
\newcounter{suji}
\newcommand{\sgd}[2]{%
\setcounter{suji}{0}%
\expandafter\@tfor\expandafter\templist\expandafter:\expandafter=#1%
\do{%
\put(\thesuji,#2){\makebox(11,12){\sgtrans{\templist}}}%
\addtocounter{suji}{11}%
}}%
\newcommand{\transmoti}[1]{%
\if#1P\Pawn%
\else \if#1L\Lancer%
\else \if#1N\Knight%
\else \if#1S\Silver%
\else \if#1G\Gold%
\else \if#1R\Rook%
\else \if#1B\Bishop%
\else #1%
\fi\fi\fi\fi\fi\fi\fi%
}
\newcommand{\sgm}[1]{%
\expandafter\@tfor\expandafter\tlist\expandafter:\expandafter=#1%
\do{%
\transmoti{\tlist}\\%
}}%
\newcommand{\sgb}[9]{%
\fontsize{14pt}{14pt}
\selectfont
\sgd{#1}{96}%
\sgd{#2}{84}%
\sgd{#3}{72}%
\sgd{#4}{60}%
\sgd{#5}{48}%
\sgd{#6}{36}%
\sgd{#7}{24}%
\sgd{#8}{12}%
\sgd{#9}{0}%
}
\newcommand{\moti}[1]{%
\fontsize{12pt}{12pt}
\selectfont
\put(101,0){\shortstack{\sgm{#1}}}%
}%
\newcommand{\sgframe}{%
\thicklines
\put(0,0){\framebox(99,108){}}
\thinlines
\multiput(11,0)(11,0){8}{\line(0,1){108}}
\multiput(0,12)(0,12){8}{\line(1,0){99}}
}
\newcommand{\sgdsmall}[2]{%
\setcounter{suji}{0}%
\expandafter\@tfor\expandafter\templist\expandafter:\expandafter=#1%
\do{%
\put(\thesuji,#2){\makebox(8,9){\sgtrans{\templist}}}%
\addtocounter{suji}{8}%
}}%
\newcommand{\sgbsmall}[9]{%
\fontsize{8pt}{8pt}
\selectfont
\sgdsmall{#1}{63}%
\sgdsmall{#2}{55}%
\sgdsmall{#3}{47}%
\sgdsmall{#4}{39}%
\sgdsmall{#5}{31}%
\sgdsmall{#6}{23}%
\sgdsmall{#7}{15}%
\sgdsmall{#8}{7}%
\sgdsmall{#9}{-1}%
}
\newcommand{\motismall}[1]{%
\fontsize{7pt}{7pt}
\selectfont
\put(73,0){\shortstack{\sgm{#1}}}%
}%
\newcommand{\sgframesmall}{%
\thicklines
\put(0,0){\framebox(72,72){}}
\thinlines
\multiput(8,0)(8,0){8}{\line(0,1){72}}
\multiput(0,8)(0,8){8}{\line(1,0){72}}
}
\makeatother%
\begin{document}
%\small
\setlength{\unitlength}{0.45mm}
\begin{picture}(120,120)
\sgframe
\sgb
{-------z-}
{-L-tzzz-t}
{-pP----pt}
{kPt-PPPPt}
{tNTTN--Tx}
{gTG--m-N-}
{Ng-------}
{--D----L-}
{--L-MGR--}
\moti{なし}
\end{picture}
\end{document}