7

I wonder which module you can use to draw chessboards in ConTeXt. When I was using LaTeX, skak is fine but now I a bit stuck.

In LaTeX the code looks like:

\documentclass{minimal}
\usepackage{skak}

\begin{document}
    \newgame
    \mainline{1.b4 b6} \\
    \showboard
\end{document}
  • 3
    I don't think that there is a chess module for context (and I certainly don't plain to write one). – Ulrike Fischer Nov 28 '18 at 19:31
10

AFAIK, there isn't any package dedicated to chess. Depending on what you want, you can actually piggyback on skak:

\usemodule[filter]

\defineexternalfilter
    [chess]
    [filter=pdflatex,
     output=\externalfilterbasefile.pdf,
     readcommand=\readPDFfile,
     purge=no,
     bufferbefore=chessbefore,
     bufferafter=chessafter,
    ]

\def\readPDFfile#1{\externalfigure[#1]}

\startbuffer[chessbefore]
  \documentclass{minimal}
  \usepackage{skak}
  \usepackage[active,tightpage]{preview}

  \begin{document}
  \begin{preview}
  \newgame
  \hidemoves{
\stopbuffer

\startbuffer[chessafter]
  }
  \showboard
  \end{preview}
  \end{document}
\stopbuffer

\starttext
\startchess
  1. b4 b6
\stopchess

\stoptext

which gives

enter image description here

  • 2
    wow, context using latex to get something working ;-). But I guess it wouldn't work in a context standalone, or can context find an existing texlive? Btw: you are missing the rank numbers. – Ulrike Fischer Nov 29 '18 at 17:55
  • @UlrikeFischer: Not sure why the rank numbers got cropped. Either preview package in LaTeX or \startTEXpage in ConTeXt is being too aggressive. Regarding context standalone finding texlive, that depends on the path. One can pass a PATH setup to the filter command (at least on linux) to make sure everything works. Even without munging with the path, simply calling pdflatex usually works as long as pdflatex does not call a binary that is provided by context standalone (e.g., bibtex). – Aditya Nov 29 '18 at 22:30
  • the number are cropped as they are not inside the bounding box. You need to setup some border (this would be easier with chessboard, it has keys for this). – Ulrike Fischer Nov 29 '18 at 22:51

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.