I'm trying to draw diagrams for the board game Go in TikZ. To reuse board positions in subsequent variations I need a way to store the current board position. I learned from this question that two of my options are using \csname ... \endcsname or pgfkeys. As I am using pgfkeys for other things anyways, my question is:

How would one implement a two-dimensional array with pgfkeys?

I'm open towards solutions not using pgfkeys, if you think that's a bad idea. However I would prefer not to use expl3, as one of my end goals is to be compatible to Plain TeX, LaTeX and ConTeXt (just like TikZ is)

  • 2
    Not directly related to the question, but it's worth mentioning that expl3 is usable with plain and ConTeXt as well as with LaTeX.
    – Joseph Wright
    Apr 30, 2017 at 15:52
  • 1
    I would use expl3. pgfkeys is ok for user interface but imho not to implement a low-level data structure. Are you sure that a two-dimensional is enough and that you don't need something to store move numbers and perhaps markers? Apr 30, 2017 at 15:58
  • @UlrikeFischer I plan to have two "arrays". One mapping coordinates to stone color and one mapping coordinates to markers/move numbers. I personally dislike the expl3 syntax, but I will give it another look.
    – mdm
    Apr 30, 2017 at 16:14
  • I think you will begin to love when you start to write commands to loop over your arrays. expl3 has so many useful tools there. I wished it existed already in the current form when I wrote chessboard and xskak. Apr 30, 2017 at 16:42
  • I would just like to point out that 'sgf2dg' is a very powerful tool to draw Go diagrams. It does not exactly do what you ask about here, but it will surely be easier to start from there.
    – fborchers
    Feb 2, 2020 at 18:56

1 Answer 1


Although you gave a preference for pgfkeys, I suspect that is overkill here even if you have pgf loaded for other reasons.

This makes a log of

A1 is black and B14 is white

from the plain tex

\def\setpos#1#2#3{\expandafter\def\csname GO-#1-#2-\endcsname{#3}}
\def\getpos#1#2{\csname GO-#1-#2-\endcsname}


\immediate\write20{A1 is \getpos{A}{1} and B14 is \getpos{B}{14}}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.