Adding chess diagrams to org-mode documents

Example1 using FEN (Forsyth–Edwards Notation):

#+property: header-args:latex+ :headers '("\\usepackage{chessboard}\\usepackage{xskak}\\usepackage{chessfss}") :border 1pt

#+header: :imagemagick "t"
#+header: :results file raw
#+header: :exports results
#+header: :fit yes :border 0.5cm
#+header: :iminoptions -density 600 :imoutoptions -geometry 600
#+begin_src latex :file alburt_vs_kasparov_1978.png
\setchessboard{normalboard, showmover=false, moverstyle=triangle, label=false}
\fenboard{6k1/5p2/6p1/8/7p/8/6PP/6K1 b - - 0 0} \chessboard

# Local Variables:
# org-latex-pdf-process: ("xelatex -shell-escape -interaction=nonstopmode -output-directory=%o %f"
#                         "xelatex -shell-escape -interaction=nonstopmode -output-directory=%o %f"
#                         "xelatex -shell-escape -interaction=nonstopmode -output-directory=%o %f")
# End:

Note that you need to set the \(LaTeX\) engine to xelatex. This is done via a file-local variable2 in the above example. To apply this variable, run M-x normal-mode.

The output of the above will look like:


  1. Lev Alburt vs Garry Kasparov (1978) ↩︎

  2. Emacs manual: Specifying File Variables ↩︎

See also