# 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}
\usepackage{xskak}
\usepackage{chessboard}
\usepackage{chessfss}
\usepackage{fontspec}
\begin{document}

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

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

\end{document}




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

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
#+END_SRC




and automate this process above?

+3

source to share

Something like that?

#+title: Chess
#+startup: inlineimages
#+property: header-args:latex+ :imagemagick yes :iminoptions -density 300 -resize 400

* 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
#+end_src



+2

source

All Articles