Rework chessboard support

* Use a module rather than a layout, since this package can be used with
  any class
* Do not hardcode options and settings. The package is very flexible,
  there is no need to limit this in LyX
This commit is contained in:
Juergen Spitzmueller 2018-09-23 12:26:43 +02:00
parent 33d6499bbc
commit 9c33bbed10
6 changed files with 229 additions and 330 deletions

View File

@ -2169,7 +2169,7 @@ dist_layouts_DATA =\
layouts/bxjsslide.layout \
layouts/changebars.module \
layouts/chess.layout \
layouts/chessboard.layout \
layouts/chessboard.module \
layouts/cl2emult.layout \
layouts/copernicus.layout \
layouts/ctex-article.layout \

View File

@ -297,6 +297,8 @@
\TestPackage{cancel}
\TestPackage{chapterbib}
\TestPackage{chemgreek}
\TestPackage{chessboard}
\TestPackage{chessfss}
\TestPackage{chicago}
\TestPackage{color} % this one should be there if graphics.sty is there.
\TestPackage{covington}
@ -397,6 +399,7 @@
\TestPackage[xetex.def]{xetex-def}
\TestPackage{xkeyval}
\TestPackage{xltabular}
\TestPackage{xskak} % required by chessboard
% Packages used by LyX's documentation files
\TestPackage{arydshln}

View File

@ -1,17 +1,22 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 563
\lyxformat 564
\begin_document
\begin_header
\save_transient_properties true
\origin /systemlyxdir/examples/
\textclass chessboard
\textclass article
\begin_preamble
\usepackage{multicol}
\AtBeginDocument{%
\columnsep 0.25in
\columnseprule 0.4pt
\hyphenpenalty 10000
}
\end_preamble
\use_default_options true
\begin_modules
chessboard
multicol
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
@ -51,10 +56,9 @@
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine biblatex-natbib
\cite_engine_type authoryear
\biblatex_bibstyle authoryear
\biblatex_citestyle authoryear
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
@ -72,14 +76,14 @@
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip medskip
\defskip smallskip
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\paperpagestyle empty
\tracking_changes false
\output_changes false
\html_math_output 0
@ -116,37 +120,25 @@ Game start 05/29/2001
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_inset Flex Multiple Columns
status open
\begin_layout Plain Layout
\backslash
begin{multicols}{2}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
The following game was played at the IECC (International Email Chess Club).
It is presented as an example of the fun you can have with \SpecialChar LyX
's new chessboard
layout (based on the
\begin_inset Quotes eld
\end_inset
xskak.sty
\begin_inset Quotes erd
\end_inset
package from CTAN
module (using the
\family sans
xskak
\family default
and
\family sans
chessboard
\family default
packages).
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\begin_inset CommandInset line
LatexCommand rule
offset "0.5ex"
@ -158,7 +150,7 @@ height "1pt"
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\noun on
Sylvan, Kayvan
@ -178,7 +170,7 @@ Wakeham, Marc
(1639)
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\noindent
\begin_inset CommandInset line
LatexCommand rule
@ -191,7 +183,24 @@ height "1pt"
\end_layout
\begin_layout Standard
\begin_layout NewChessGame
\end_layout
\begin_layout Plain Layout
\begin_inset Flex SetChessBoard
status open
\begin_layout Plain Layout
pgfstyle=straightmove,arrow=to,linewidth=0.1em,smallboard
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Flex Mainline
status open
@ -207,12 +216,6 @@ outvar
\end_inset
\begin_inset Argument 2
status open
\begin_layout Plain Layout
1.
e4 c5 2.
Nc3 d6 3.
@ -226,57 +229,35 @@ status open
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_layout ChessBoard
\noindent
\align center
\begin_inset Flex ChessBoard
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Argument 1
status open
\begin_layout Plain Layout
d2-d4
markmoves={d2-d4},pgfstyle=knightmove,markmove={g1-e2},pgfstyle=circle,markfield
s={d4,f4}
\end_layout
\end_inset
\begin_inset Argument 3
status open
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
d4,f4
\end_layout
\end_inset
\begin_inset Argument 2
status open
\begin_layout Plain Layout
g1-e2
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\noindent
\align block
So far, so good.
@ -285,13 +266,8 @@ So far, so good.
The diagrammed position has been reached before in hundreds of GM games.
\end_layout
\begin_layout Standard
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
\begin_inset Argument 2
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
@ -305,12 +281,7 @@ status open
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\noindent
\align block
\begin_inset Flex Variation
@ -328,20 +299,9 @@ invar
\end_inset
\begin_inset Argument 2
status open
\begin_layout Plain Layout
5...
Ng7
\end_layout
\end_inset
\begin_inset Argument 3
\begin_inset Argument post:1
status open
\begin_layout Plain Layout
@ -361,7 +321,7 @@ equal{} was better
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\begin_inset Flex Mainline
status open
@ -377,12 +337,6 @@ outvar
\end_inset
\begin_inset Argument 2
status open
\begin_layout Plain Layout
6.
d4 cxd4 7.
Nxd4 a6
@ -393,21 +347,16 @@ status open
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
With 7...
a6, we are back in the well-trodden theory of this opening.
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Flex ChessBoard
status open
status collapsed
\begin_layout Plain Layout
@ -418,13 +367,8 @@ status open
\end_layout
\begin_layout Standard
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
\begin_inset Argument 2
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
@ -442,24 +386,21 @@ status open
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_layout ChessBoard
\noindent
\align center
\begin_inset Flex ChessBoard
status open
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Argument 1
status open
\begin_layout Plain Layout
a1-d1
markmoves={a1-d1}
\end_layout
\end_inset
@ -472,29 +413,19 @@ a1-d1
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
White continues to develop pieces and also sets a trap for Black.
\end_layout
\begin_layout Standard
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
\begin_inset Argument 2
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
12...
O-O?
\end_layout
\end_inset
\begin_inset Argument 3
\begin_inset Argument post:1
status open
\begin_layout Plain Layout
@ -512,11 +443,11 @@ This move loses instantly.
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
The following was better, even though white retains the upper hand.
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\begin_inset Flex Variation
status open
@ -532,22 +463,11 @@ invar
\end_inset
\begin_inset Argument 2
status open
\begin_layout Plain Layout
12...
e5 13.
Be3 Qc7 14.
Na4 O-O
\end_layout
\end_inset
\begin_inset Argument 3
\begin_inset Argument post:1
status open
\begin_layout Plain Layout
@ -567,7 +487,7 @@ wbetter
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\begin_inset Flex Mainline
status open
@ -583,12 +503,6 @@ outvar
\end_inset
\begin_inset Argument 2
status open
\begin_layout Plain Layout
13.
e5!
\end_layout
@ -598,23 +512,13 @@ status open
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
Black's knight and bishop form a bumbling pair here.
The bishop is doomed.
\end_layout
\begin_layout Standard
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
\begin_inset Argument 2
\begin_inset Flex Mainline
status open
\begin_layout Plain Layout
@ -626,12 +530,7 @@ status open
Bxd6 Rfd8 17.
Bc7 Rd7 18.
Bf4
\end_layout
\end_inset
\begin_inset Argument 3
\begin_inset Argument post:1
status open
\begin_layout Plain Layout
@ -649,11 +548,11 @@ status open
\end_layout
\begin_layout Standard
\begin_layout Plain Layout
\noindent
\align center
\begin_inset Flex ChessBoard
status open
status collapsed
\begin_layout Plain Layout
@ -664,17 +563,6 @@ status open
\end_layout
\begin_layout Standard
\begin_inset ERT
status collapsed
\begin_layout Plain Layout
\backslash
end{multicols}
\end_layout
\end_inset

View File

@ -1,133 +0,0 @@
#% Do not delete the line below; configure depends on this
# \DeclareLaTeXClass[scrartcl]{Chessboard}
# \DeclareCategory{Articles}
# chessboard article textclass definition file.
Format 69
Requires chessfss
ClassOptions
Other "parskip"
End
Preamble
\usepackage{xskak}
\pagestyle{empty}
\AtBeginDocument{
\newchessgame
\setchessboard{pgfstyle=straightmove, arrow=to,linewidth=0.1em, smallboard}
}
EndPreamble
Style Standard
Align Block
AlignPossible Block, Left, Right, Center
End
Input stdsections.inc
Input stdtitle.inc
InsetLayout Flex:Mainline
LyXType custom
LatexType Command
LatexName mainline
Decoration Classic
LabelString "Mainline:"
PassThru 1
ParbreakIsNewline 1
LabelFont
Color blue
Series bold
EndFont
Font
Color blue
EndFont
Argument 1
LabelString id
ToolTip "'invar' or 'outvar'"
Decoration Conglomerate
EndArgument
Argument 2
Mandatory 1
LabelString "Moves"
PassThru 1
Decoration Conglomerate
EndArgument
Argument 3
LabelString "Comment"
Mandatory 1
LeftDelim "{ "
Font
Color Green
EndFont
Decoration Conglomerate
EndArgument
End
InsetLayout Flex:Variation
CopyStyle Flex:Mainline
LatexName variation
LabelString Variation
End
InsetLayout Flex:ChessBoard
LyXType custom
LatexType Command
LatexName chessboard
LabelString "[chessboard]"
Decoration Classic
KeepEmpty 1
LabelFont
Color Red
EndFont
Argument 1
LabelString "Arrows"
ToolTip "Comma separated list of the form from-to (like d2-d4)"
LeftDelim "[pgfstyle=straightmove,markmoves={"
RightDelim "},"
DefaultArg " "
PassThru 1
Decoration Conglomerate
EndArgument
Argument 2
LabelString "Knigt"
ToolTip "List of knight moves (crooked arrows) g1-e2, g1-h3"
LeftDelim "pgfstyle=knightmove,markmove={"
RightDelim "},"
Decoration Conglomerate
EndArgument
Argument 3
LabelString "Mark"
ToolTip "Comma separated list of fields to be marked with a circle (like d4,f4,c7)"
DefaultArg " "
LeftDelim "pgfstyle=circle,markfields={"
RightDelim "}]"
Decoration Conglomerate
EndArgument
End
InsetLayout Flex:ChessBoardStore
CopyStyle Flex:ChessBoard
ResetArgs 1
LabelString "StoreChessboard"
Argument 1
LabelString "Store FEN"
ToolTip "Store the 'FEN' under the given name"
LeftDelim "[print=false,storefen={"
RightDelim "}]"
EndArgument
End
InsetLayout Flex:ChessBoardRestore
CopyStyle Flex:ChessBoard
ResetArgs 1
LabelString "RestoreChessboard"
Argument 1
LabelString "Restore FEN"
ToolTip "Restore the 'FEN' to the version saved under the given name"
LeftDelim "[print=false,restorefen={"
RightDelim "}]"
EndArgument
End

View File

@ -0,0 +1,139 @@
#\DeclareLyXModule[chessboard.sty,chessfss.sty,xskak.sty]{Chessboard}
#DescriptionBegin
#Support for the chessboard package to print chess games
#See chessboard-article.lyx example file.
#DescriptionEnd
# Author: Kornel Benko <kornel@lyx.org>
# Jürgen Spitzmüller <spitz@lyx.org>
Format 69
#
# XSkak basics
#
Style NewChessGame
LatexType command
LatexName newchessgame
Margin Dynamic
LabelType Static
LabelSep XX
LabelString "[Start New Chess Game]"
LabelFont
Family typewriter
Series Medium
Size Normal
Color red
EndFont
KeepEmpty 1
Argument 1
LabelString "Options"
MenuString "Chessgame Options"
ToolTip "See xskak manual for a comprehensive list of keys and values"
PassThru 1
Font
Color latex
Family typewriter
EndFont
EndArgument
Requires xskak
End
InsetLayout Flex:Mainline
LyXType custom
LatexType command
LatexName mainline
Decoration classic
LabelString "Mainline:"
PassThru 1
ParbreakIsNewline 1
LabelFont
Color blue
EndFont
Font
Color blue
EndFont
Argument 1
LabelString "Options"
MenuString "Mainline Options"
ToolTip "See xskak manual for possible options"
Font
Color latex
Family typewriter
EndFont
EndArgument
Argument post:1
LabelString "Comment"
MenuString "Comment"
LeftDelim "<br/>"
RightDelim "%"
Font
Color green
EndFont
EndArgument
Requires xskak
End
InsetLayout Flex:Variation
CopyStyle Flex:Mainline
LatexName variation
LabelString Variation
End
#
# Chessboard additions
#
InsetLayout Flex:SetChessBoard
LyxType custom
Decoration classic
LatexType command
LatexName setchessboard
LabelString "Global Chessboard Settings"
Font
Color latex
Family typewriter
EndFont
LabelFont
Color blue
EndFont
Requires chessboard
End
InsetLayout Flex:SetBoardStoreStyle
CopyStyle Flex:SetChessBoard
LabelString "Set Chessboard Style"
Argument 1
Mandatory true
LabelString "Style Name"
MenuString "Chessboard Style Name"
ToolTip "Here you can store chessboard settings under a style name for later reuse. See chessboard manual for details."
AutoInsert true
Decoration conglomerate
EndArgument
End
InsetLayout Flex:ChessBoard
LyxType custom
Decoration classic
LatexType command
LatexType command
LatexName chessboard
LabelString "Chessboard"
Argument 1
LabelString "Options"
MenuString "Chessboard Options"
ToolTip "See chessboard manual for a comprehensive list of keys and values"
PassThru 1
Font
Color latex
Family typewriter
EndFont
EndArgument
Requires chessboard
End

View File

@ -999,7 +999,9 @@ char const * simplefeatures[] = {
"tablefootnote",
"afterpage",
"tabularx",
"xltabular"
"xltabular",
"chessboard",
"xskak"
};
char const * bibliofeatures[] = {