Org mode: describe the chess position and automatically generate the chessboard image

I am writing articles about chess. I often have to describe a chess position using a standard format called FEN and would like it to be automatically converted to a png image, and when I export the org document as LaTeX or html the image should be inline. I think it can be done because dita seems to work in a similar way.

For example, when I enter the line FEN "8 / pppr1kpp / 8/8/8 / 5P2 / PPP1RKPP / 8 w - - 0 1" I create a tex file called chessboard.tex:

\documentclass[border={0 0 3 0}, convert={density=150}]{standalone}

\setchessboard{normalboard, showmover=true, moverstyle=triangle, label=false}

\fenboard{8/pppr1kpp/8/8/8/5P2/PPP1RKPP/8 w - - 0 1} \chessboard



which with shell command $> xelatex -shell-escape chessboard.tex creates the following png image (thanks to using a separate package). enter image description here

How can I automate this process so that I can add something like

#+BEGIN_SRC chessfen
8/pppr1kpp/8/8/8/5P2/PPP1RKPP/8 w - - 0 1


and automate this process above?


source to share

1 answer

Something like that?

#+title: Chess
#+startup: inlineimages
#+property: header-args:latex+ :imagemagick yes :iminoptions -density 300 -resize 400
#+property: header-args:latex+ :headers '("\\usepackage{chessboard}\\usepackage{xskak}\\usepackage{chessfss}") :border 1pt

* Chess

#+begin_src latex :file chess.png :results raw
\setchessboard{normalboard, showmover=true, moverstyle=triangle, label=false}
\fenboard{8/pppr1kpp/8/8/8/5P2/PPP1RKPP/8 w - - 0 1} \chessboard 




All Articles