我正在修改 Scid vs PC 的 Latex 输出。在此过程中,我应用了 Fischer 的 xskakloop 解决方案,使游戏逐个显示。
这是我为 Morphy 著名游戏编写的代码。
我不明白为什么第一个显示图与另一个图不对齐。
我还想知道如何突出显示方格。例如,1e4。我希望 e4 方格以黄色突出显示。
\documentclass[10pt,DIV=20]{scrreprt}
% This is a LaTeX file generated by Scid.
% You must have the skak, KOMAScript and pstricks packages installed to typeset this file.
\usepackage{scrpage2}
\usepackage{charter}
\usepackage[svgnames]{xcolor}
\usepackage{xskak}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{pstricks-add}
\usepackage{tabularx}
\usepackage{multicol}
\pagestyle{empty}
\usepackage{titlesec}
\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak, xskak,chessboard}
\newcommand\getmovestyle[1]{
\ifthenelse
{\equal{#1}{N}}
{\def\mymovestyle{[clockwise=false,style=knight]curvemove}}
{\ifthenelse
{\equal{#1}{}}
{\def\mymovestyle{curvemove}}
{\def\mymovestyle{straightmove}}}}
\newcommand\mychessloop[1][]{%
\xskakloop[step=1]{%
\getmovestyle{\xskakget{piecechar}}%
\begin{tabular}{c}
\chessboard[boardfontfamily=alphadia,
boardfontencoding=LSBC4,
smallboard, showmover=false, label=false, pgfstyle=\mymovestyle, color=red,
markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,color=blue, markstyle=circle, markfield=\xskakget{movefrom},
emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen}]\\
\xskakget{opennr}
\xskakget{lan}
\xskakget{nag}
\par
\end{tabular}\quad
}}%
\begin{document}
\xskakset{style=UF}
\fontsize{10pt}{14pt}\selectfont
\font\sachy=SkakNew-Diagram at 10pt
\newdimen\muj \muj=-0.32ex
\makeatletter
\xskaknewstyleitem[%
whiteopen={.~},
blackopen={.\,\space\ldots},
beforewhite={},%\space,
beforeblack=\space,%\space,
afterwhite=,%\space,
afterblack={\space\,},%\space,
]{styleD}
\makeatother
\makeatletter
\providecommand\xskak@beforecomment{}
\makeatother
%********************* GAME ONE ***************************
\onecolumn\begin{multicols}{2}
{
\begin{tabularx}{0.9\textwidth}{rllXr}
White: & Morphy & & & \\
Black: & Duke/Count of Brunswick & & & Paris\\
Opening ECO: & C41 & & & 1858\\
Result: & 1-0\\
\end{tabularx}
}
\end{multicols}
\setfigstyle{\normalfont}
\setboardfontcolors{blackfieldmask=gray!40}
\newchessgame
\mainline
{1. e4 e5 2.Nf3 d6 3.d4 Bg4 4.dxe5 Bxf3 5.Qxf3 dxe5 6.Bc4 Nf6 7.Qb3 Qe7 8.Nc3 c6 9.Bg5 b5 10.Nxb5 cxb5 11.Bxb5+ Nbd7 12.O-O-O Rd8 13.Rxd7 Rxd7 14.Rd1 Qe6 15.Bxd7+ Nxd7 16.Qb8+ Nxb8 17.Rd8# }
\mychessloop
\end{document}
答案1
添加 \noindent 以避免段落开头的缩进。要使字段变为黄色,请为字段掩码着色:
\documentclass[10pt,DIV=20]{scrreprt}
% This is a LaTeX file generated by Scid.
% You must have the skak, KOMAScript and pstricks packages installed to typeset this file.
\usepackage{scrpage2}
\usepackage{charter}
\usepackage[svgnames]{xcolor}
\usepackage{xskak}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
%\usepackage{pstricks-add}
\usepackage{tabularx}
\usepackage{multicol}
\pagestyle{empty}
\usepackage{titlesec}
\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak, xskak,chessboard}
\newcommand\getmovestyle[1]{
\ifthenelse
{\equal{#1}{N}}
{\def\mymovestyle{[clockwise=false,style=knight]curvemove}}
{\ifthenelse
{\equal{#1}{}}
{\def\mymovestyle{curvemove}}
{\def\mymovestyle{straightmove}}}}
\newcommand\mychessloop[1][]{%
\xskakloop[step=1]{%
\getmovestyle{\xskakget{piecechar}}%
\noindent\begin{tabular}{c}
\chessboard[boardfontfamily=alphadia,
boardfontencoding=LSBC4,
smallboard, showmover=false, label=false, pgfstyle=\mymovestyle, color=red,
markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,color=blue, markstyle=circle, markfield=\xskakget{movefrom},
emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen},
coloremph=true,
whitefieldmaskcolor=yellow,blackfieldmaskcolor=yellow,emphfield=\xskakget{moveto},
]\\
\xskakget{opennr}
\xskakget{lan}
\xskakget{nag}
\par
\end{tabular}\quad
}}%
\begin{document}
\xskakset{style=UF}
\fontsize{10pt}{14pt}\selectfont
\font\sachy=SkakNew-Diagram at 10pt
\newdimen\muj \muj=-0.32ex
\makeatletter
\xskaknewstyleitem[%
whiteopen={.~},
blackopen={.\,\space\ldots},
beforewhite={},%\space,
beforeblack=\space,%\space,
afterwhite=,%\space,
afterblack={\space\,},%\space,
]{styleD}
\makeatother
\makeatletter
\providecommand\xskak@beforecomment{}
\makeatother
%********************* GAME ONE ***************************
\onecolumn\begin{multicols}{2}
{
\begin{tabularx}{0.9\textwidth}{rllXr}
White: & Morphy & & & \\
Black: & Duke/Count of Brunswick & & & Paris\\
Opening ECO: & C41 & & & 1858\\
Result: & 1-0\\
\end{tabularx}
}
\end{multicols}
\setfigstyle{\normalfont}
\setboardfontcolors{blackfieldmask=gray!40}
\newchessgame
\mainline
{1. e4 e5 2.Nf3 d6 3.d4 Bg4 4.dxe5 Bxf3 5.Qxf3 dxe5 6.Bc4 Nf6 7.Qb3 Qe7 8.Nc3 c6 9.Bg5 b5 10.Nxb5 cxb5 11.Bxb5+ Nbd7 12.O-O-O Rd8 13.Rxd7 Rxd7 14.Rd1 Qe6 15.Bxd7+ Nxd7 16.Qb8+ Nxb8 17.Rd8# }
\mychessloop
\end{document}
答案2
\mychessloop
如果删除(或注释掉)上面的空行,问题就很容易解决。
从表面上看,您将要显示多个游戏。我强烈建议您将代码分成子文件,其中主文件包含所有设置,其他 .tex 文件包含游戏。这将使代码更加清晰和简单。例如,创建一个game1.tex
文件并在其中包含以下内容:
\newchessgame
\mainline{
1.e4 e5
2.Nf3 d6
3.d4 Bg4
4.dxe5 Bxf3
5.Qxf3 dxe5
6.Bc4 Nf6
7.Qb3 Qe7
8.Nc3 c6
9.Bg5 b5
10.Nxb5 cxb5
11.Bxb5+ Nbd7
12.O-O-O Rd8
13.Rxd7 Rxd7
14.Rd1 Qe6
15.Bxd7+ Nxd7
16.Qb8+ Nxb8
17.Rd8#
}
\mychessloop
请注意,我已将每个动作插入到其自己的行中(这不是强制性的,但在您想要编辑某些内容时很有帮助,并且它在视觉上很有吸引力)。
对第 2、3 场比赛等进行同样的操作。感谢@Ulrike Fischer用于解决我从 :) 复制并粘贴的突出显示部分。然后,您的主文件将包含以下内容:
\documentclass[10pt,DIV=20]{scrreprt}
% This is a LaTeX file generated by Scid.
% You must have the skak, KOMAScript and pstricks packages installed to typeset this file.
\usepackage{scrpage2}
\usepackage{charter}
\usepackage[svgnames]{xcolor}
\usepackage{xskak}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{pstricks-add}
\usepackage{tabularx}
\usepackage{multicol}
\pagestyle{empty}
\usepackage{titlesec}
\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak, xskak,chessboard}
\newcommand\getmovestyle[1]{
\ifthenelse
{\equal{#1}{N}}
{\def\mymovestyle{[clockwise=false,style=knight]curvemove}}
{\ifthenelse
{\equal{#1}{}}
{\def\mymovestyle{curvemove}}
{\def\mymovestyle{straightmove}}}}
\newcommand\mychessloop[1][]{%
\xskakloop[step=1]{%
\getmovestyle{\xskakget{piecechar}}%
\begin{tabular}{c}
\chessboard[boardfontfamily=alphadia,
boardfontencoding=LSBC4,
smallboard, showmover=false, label=false, pgfstyle=\mymovestyle, color=red,
markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,color=blue, markstyle=circle, markfield=\xskakget{movefrom},
emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen},
coloremph=true,
whitefieldmaskcolor=yellow,blackfieldmaskcolor=yellow,emphfield=\xskakget{moveto},
]\\
\xskakget{opennr}
\xskakget{lan}
\xskakget{nag}
\par
\end{tabular}\quad
}}%
\xskakset{style=UF}
\fontsize{10pt}{14pt}\selectfont
\font\sachy=SkakNew-Diagram at 10pt
\newdimen\muj \muj=-0.32ex
\makeatletter
\xskaknewstyleitem[%
whiteopen={.~},
blackopen={.\,\space\ldots},
beforewhite={},%\space,
beforeblack=\space,%\space,
afterwhite=,%\space,
afterblack={\space\,},%\space,
]{styleD}
\makeatother
\makeatletter
\providecommand\xskak@beforecomment{}
\makeatother
\begin{document}
%********************* GAME ONE ***************************
\onecolumn\begin{multicols}{2}
{
\begin{tabularx}{0.9\textwidth}{rllXr}
White: & Morphy & & & \\
Black: & Duke/Count of Brunswick & & & Paris\\
Opening ECO: & C41 & & & 1858\\
Result: & 1-0\\
\end{tabularx}
}
\end{multicols}%
\setfigstyle{\normalfont}%
\setboardfontcolors{blackfieldmask=gray!40}
\input{Game1}
%********************* GAME TWO ***************************
%...
%...
%...
\end{document}