Last active
October 9, 2019 18:55
-
-
Save michal-h21/293d567ce11e1f1eba0112d908a26245 to your computer and use it in GitHub Desktop.
tex4ht configuraton file for xskak.sty. compile with `make4ht sample.tex svg`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[12pt]{article} | |
\ifdefined\HCode | |
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def} | |
\fi | |
\usepackage{xskak} | |
\begin{document} | |
\newchessgame[id=main] | |
\chessboard | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\NewConfigure{chessboard}{2} | |
% this should put configurable hooks around \newchessgame | |
% contents printed by this command should be printed to image | |
% \newcommand\:tempaboard[1][]{\a:chessboard\o:newchessgame:[#1]\b:chessboard} | |
\newcommand\Save:TikzPict{\let\old:a:tikzpicture\a:tikzpicture\let\old:b:tikzpicture\b:tikzpicture\let\a:tikzpicture\relax\let\b:tikzpicture\relax} | |
\newcommand\Restore:TikzPict{\let\a:tikzpicture\old:a:tikzpicture\let\b:tikzpicture\old:b:tikzpicture} | |
\newcommand\:tempaboard[1][]{\a:chessboard\o:chessboard:[#1]\b:chessboard} | |
% | |
\HLet\chessboard\:tempaboard | |
\Configure{chessboard}{\Picture*{}\Save:TikzPict}{\Restore:TikzPict\EndPicture} | |
\Hinput{chessboard} |
I think I've found a solution:
\NewConfigure{chessboard}{2}
% this should put configurable hooks around \newchessgame
% contents printed by this command should be printed to image
% \newcommand\:tempaboard[1][]{\a:chessboard\o:newchessgame:[#1]\b:chessboard}
\newcommand\:tempaboard[1][]{\a:chessboard\o:chessboard:[#1]\b:chessboard}
%
\HLet\chessboard\:tempaboard
\Configure{chessboard}{\typeout{patching works}\Picture*{}}{\EndPicture}
\Hinput{chessboard}
The strange thing is that I tried to patch the \chesboard
command first and it failed.
The chessboard looks fine now. But when I add "decoration" there is a displacement:
The code is
\documentclass[12pt]{article}
\ifdefined\HCode
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
\fi
\usepackage{xskak}
\begin{document}
\def\pawnranks{a2-h2,h7-a7}
\chessboard[inverse,%
pgfstyle=border,%
markregions={\pawnranks},%
color=red,padding=0.3ex,
linewidth=0.1ex,%
backregions={\board,d4-e5},%
pgfstyle=text,%
text=$\leftarrow$%
\currentbk\currentwq
$\rightarrow$,%
markregion=a3-h3,%
pgfstyle={[rotate=45]text},%
backregion=h8-a1%
]
\end{document}
When I process directly with dvisvgm (with dvisvgm
as document option) it looks ok (but the red color is gone).
It seems that this may be used by nested \Picture*
commands, as they are used by the configuration for tikzpicture as well. Turning off this configuration seems to do the trick:
\NewConfigure{chessboard}{2}
% this should put configurable hooks around \newchessgame
% contents printed by this command should be printed to image
% \newcommand\:tempaboard[1][]{\a:chessboard\o:newchessgame:[#1]\b:chessboard}
\newcommand\Save:TikzPict{\let\old:a:tikzpicture\a:tikzpicture\let\old:b:tikzpicture\b:tikzpicture\let\a:tikzpicture\relax\let\b:tikzpicture\relax}
\newcommand\Restore:TikzPict{\let\a:tikzpicture\old:a:tikzpicture\let\b:tikzpicture\old:b:tikzpicture}
\newcommand\:tempaboard[1][]{\a:chessboard\o:chessboard:[#1]\b:chessboard}
%
\HLet\chessboard\:tempaboard
\Configure{chessboard}{\Picture*{}\Save:TikzPict}{\Restore:TikzPict\EndPicture}
\Hinput{chessboard}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can create working svg files with dvisvgm with the command
dvisvgm --no-fonts sample.dvi
, but I don't know how to pass theno-fonts
option through make4ht.