1

Does anyone know how to get these packages to work together.

Minimal example (test.tex).

\documentclass[12pt]{article}
\usepackage{xskak}
\begin{document}
\newchessgame[id=main]
\chessboard
\end{document}

The config file for tex4ebook is sample.cfg

\Preamble{xhtml}
\CutAt{section}
\begin{document}
\EndPreamble

Running tex4ebook -c sample test.tex gives an error

(c:\miktex29\tex\latex\pgf\compatibility\pgfcomp-version-0-65.sty
! Undefined control sequence.
\pgfsys@svg@newline ->\Hnewline

l.190   \pgfusepathqfill}

Is there any way to fix this.

Thank you.

1

The error you get is known issue. More interesting question is how to actually support xskak package. You will probably want to support at least two features: chess figures font and chess boards.

You can get support for chess figures with the following font definition file, SkakNew.htf:

SkakNew  32 121
'' ''     32
'!' ''     33
'”' ''     34
'#' ''  35
'$' ''  36
'%' ''  37
'&' ''  38
'’' ''     39
'(' ''  40
')' ''  41
'*' ''  42
'+' ''  43
',' ''  44
'-' ''  45
'.' ''  46
'/' ''     47
'0' ''  48
'1' ''  49
'2' ''  50
'3' ''  51
'4' ''  52
'5' ''  53
'6' ''  54
'7' ''  55
'8' ''  56
'9' ''  57
':' ''  58
';' ''  59
'¡' ''     60
'=' ''  61
'¿' ''     62
'?' ''  63
'@' ''  64
'→' ''  65
'♗' ''  66
'↑' ''  67
'⊙' ''  68
'△' ''  69
'□' ''  70
'⇗' ''  71
'⇔' ''  72
'⊞' ''  73
'╳' ''  74
'♔' ''  75
'⟂' ''  76
'≪' ''  77
'♘' ''  78
'≫' ''  79
'Ⅱ' ''  80
'♕' ''  81
'♖' ''  82
'>' ''  83
'⊕' ''  84
'○' ''  85
'⇆' ''  86
'W' ''  87
'×' ''  88
'Y' ''  89
'Z' ''  90
'[' ''  91
'“' ''     92
']' ''  93
'ˆ' ''     94
'˙' ''     95
'‘' ''     96
'⧉' ''  97
'⌓' ''  98
'±' ''  99
'⦂' ''  100
'∓' ''  101
'⩲' ''  102
'⩱' ''  103
'h' ''  I can't find it, it is plus followed by minus
'i' ''  minus followed by plus
'=' ''  106
'k' ''  107
'l' ''  108
'#' ''  109
'n' ''  110
'o' ''  111
'p' ''  112
'q' ''  113
'r' ''  114
's' ''  115
't' ''  116
'u' ''  117
'v' ''  118
'w' ''  119
'x' ''  120
'y' ''  121
SkakNew  32 121

slightly more difficult is support for chess boards. tex4ht can convert any LaTeX code to picture using \Picture*{} ... \EndPicture commands. We only need to redefine \chessboard command to incorporate them, which I wasn't successful in trying to do. Maybe Ulrike will know.

Anyway, as a workaround, we can define new command, let's say \mychessfigure, which will call \chessfigure with \Picture commands when the document is compiled with tex4ht.

Put in the document preamble:

\newcommand\mychessboard[1][]{\chessboard[#1]} 

and modify your sample.cfg:

\Preamble{xhtml}
\CutAt{section}
\begin{document}
\renewcommand\mychessboard[1][]{\HCode{<div class="chessboard">}\Picture*{}\chessboard[#1]\EndPicture\HCode{</div>}}
\EndPreamble

You need to change \chessboard commands to \mychessboard in your document:

\documentclass[12pt]{article}
\usepackage{xskak}
\newcommand\mychessboard[1][]{\chessboard[#1]}
\begin{document}
\newchessgame[id=main]
\mychessboard

\newchessgame
\mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6}
\xskakset{moveid=2w}

\mychessboard[setfen=\xskakget{nextfen}]\\[1ex]
 Position after 2.\,\xskakget{lan}
\end{document}

as I said, this isn't a best solution, only a workaround, this shoulf be handled in configuration for chessboard package, chessboard.4ht.

The result:

enter image description here

  • Thank you very much for your work and solution which works for me too. Is there any documentation that explains your hft file? Is it possible to improve the look/resolution of the board (the white diagonal blocks may be an optical illusion)? Running tex4ebook on Miktex/Windows gives an error "tidy command seems missing". The htm output looks like what you posted but the epub file is blank. How can I fix this? Thank you once again. – user41974 May 2 '16 at 0:20
  • @user41974 you can find some info about hft files here. the image conversion can be improved using some dvipng or dvisvgm. you can configure it in the make4ht build file. I don't get blank epub file, in the epub-viewer provided by Calibre. But there are some validation errors, so it is possible that some other viewers refuse to display. – michal.h21 May 2 '16 at 19:47
  • @Michael.h21 Thank you for your solutions. I changed the graphics conversion to your suggestion and it has helped. The ebook opens well in Calibre. The only problem is the figurine scaling in chess notation. If I view the generated html version of the book on Explorer and increase the magnification everything scales correctly. On the Calibre eviewer the figurine symbols do not scale while normal fonts do and the chess notation looks bad. Is there to fix this or to use normal letters like K for the king instead of the figurine? Thank you. – user41974 May 3 '16 at 3:32
  • @Michael.h21 I found another problem with the conversion. For the game score \mainline{1.e4 e5 2.Bc4 Nc6 3. Qh5 Nf6 4.Qxf7#}, this prints as expected if I generate a pdf file. With tex4ebook, the last move is printed as (Queen symbol)Xf7m. The X is upper case and # has printed as m. Is there a way to fix this? Thank you. – user41974 May 3 '16 at 6:49
  • @user41974 you can try to change middle columns with value '1' to just ''. The chess figures wouldn't be converted to pictures then, they would be output as Unicode instead. The problem is that viewer will need to have suitable fonts with these symbols, which I am not sure they will. – michal.h21 May 3 '16 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.