10

If you know, how to work with chess in LaTeX, please help!

I want to make an alone pawn to go.

This code works, but shows lots of other pieces:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{chessboard, skak}
\begin{document}
    \begin{frame}
        \newgame\setchessboard{markstyle=border,color=blue}
        \only<1>{\mainline{1.a4}}
        \only<2>{\hidemoves{1.a4}}
        \chessboard
    \end{frame}
\end{document}

This code shall work for an alone pawn, but it doesn't moves:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{chessboard, skak}
\begin{document}
    \begin{frame}
        \newgame\setchessboard{markstyle=border,color=blue}
        \only<1>{\mainline{1.a4}}
        \only<2>{\hidemoves{1.a4}}
        \chessboard[setpieces = {Pa2}] % Pawn
    \end{frame}
\end{document}

Documentation for the lib

iskhakovt
  • 201
  • Welcome to TeX.sx! Your post was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Oct 16 '12 at 21:56

2 Answers2

12

I am not sure if something like this is what you are trying to achieve:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{chessboard, skak}
\begin{document}
    \begin{frame}
        \newgame\setchessboard{markstyle=border,color=blue}
        \only<1>{\chessboard[setpieces = {Pa2}]}
        \only<2>{\chessboard[setpieces = {Pa4}]}
    \end{frame}
\end{document}

enter image description here

Gonzalo Medina
  • 505,128
6

You can set a startposition with the \fenboard command. With xskak it is easier, there you can fill the board with pieces. Using only a white piece doesn't make much sense, \mainline will not like it if black can't move. But you could e.g. use the key hideblack to hide the black piece:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{chessboard, xskak}
\begin{document}
\setchessboard{markstyle=border,color=blue}
    \begin{frame}
        \newchessgame[setpieces={Pa2,ph7}]
        \only<1>{Startposition}
        \only<2>{\mainline{1.a4}}
        \only<3>{\hidemoves{1.a4 h5}\mainline{2.a5}}
        \only<4>{\hidemoves{1.a4 h5 2.a5 h4}\mainline{3.a6}}
        \only<5>{\hidemoves{1.a4 h5 2.a5 h4 3.a6 h3}\mainline{4.a7}}
        \only<6>{\hidemoves{1.a4 h5 2.a5 h4 3.a6 h3 4.a7 h2}\mainline{5.a8=Q}}

        \chessboard[hideblack]
    \end{frame}
\end{document}
Ulrike Fischer
  • 327,261