# Alone pawn: LaTeX

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

-

## migrated from stackoverflow.comOct 16 '12 at 21:54

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your post was migrated here from Stack Overflow. 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

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}


-
No, I want chess lib to make moves for me. :) –  iskhakovt Oct 17 '12 at 13:58

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}

-
And how to add \setchessboard command? It looks better... –  iskhakovt Oct 17 '12 at 13:53
What do you mean? There is a \setchessboard command in my code. –  Ulrike Fischer Oct 17 '12 at 14:00
Yes. But your variant doesn't look same. –  iskhakovt Oct 17 '12 at 14:03
I don't see any difference between the boards in your example and in mine (apart from the fact there are less pieces on my board). I also don't see any reason why they should be a difference. –  Ulrike Fischer Oct 17 '12 at 14:26
Well yes, I thought it would look better than to the left like in your code. If you don't like remove the empty line before \chessboard. Or use only \hidemoves and no \mainline. –  Ulrike Fischer Oct 17 '12 at 16:14