2

I'm quite new to LaTeX and I'm trying to replicate this using Tikz:

Possible ways to place 4 queens on a 4 x 4 chessboard

I know there is some chess-related things I can include, but it diesn't seems to be adapted for something like this.

\documentclass{book}

\usepackage[utf8]{inputenc}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture} \draw[xstep=0.75cm,ystep=0.5,color=gray] (0,0) grid (3,2); \matrix[matrix of nodes, inner sep=0pt, anchor=south west, nodes={inner sep=0pt,text width=.75cm,align=center,minimum height=.5cm} ]{ & ♕ & & \ & & & ♕ \ ♕& & & \ & & ♕ & \ }; \end{tikzpicture}

\end{document}

This is my best attempt while trying to reproduce it. However this yield an error because the unicode character of the queen is not included in the utf-8 inputenc I guess, and I couldn't find how to include a special character or a picture in a Tikz grid...

I am not english and I am new to this forum, so the post might contain few mistakes. Sorry for the inconvenience, and thanks in advance for your help !

Sebastiano
  • 54,118
  • 3
    Let's break it down. First, you need to use \DeclareUnicodeCharacter to declare that you are going to use the unicode character in your document. Say you map to a command \KelkunQueen. Then you want to define KelkunQueen to be a command that enters a tikzpicture and draws a queen. – Symbol 1 Jul 28 '21 at 21:00

1 Answers1

3

So I finally found how to solve the problem after some additionnal searches on special characters. For anyone who would have the same problem, the package skak seems to be perfect:

\documentclass{book}

\usepackage{skak} \usepackage{tikz} \usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture} \draw[step=0.5cm,color=gray] (-1,-1) grid (1,1); \matrix[matrix of nodes,nodes={inner sep=0pt,text width=.5cm,align=center,minimum height=.5cm}]{ & \symqueen & & \ & & & \symqueen \ \symqueen & & & \ & & \symqueen & \}; \end{tikzpicture}

\end{document}

Thanks for the replies!

enter image description here

Sebastiano
  • 54,118
  • 5
    \symqueen is provided by the chessfss package (which is loaded by skak), so \usepackage{chessfss} will work too. – Ulrike Fischer Jul 28 '21 at 21:20
  • Somewhat related: https://tex.stackexchange.com/questions/168281/how-to-draw-a-chessboard-with-numbers/168304?r=SearchResults&s=1|50.3944#168304 and https://tex.stackexchange.com/questions/140324/chess-opening-document/140351?r=SearchResults&s=2|9.8705#140351 – John Kormylo Jul 29 '21 at 00:26