arrayjobx 배열에서 tikz 노드 이름 가져오기

arrayjobx 배열에서 tikz 노드 이름 가져오기

저는 두 명의 플레이어가 있고 각 플레이어에 대한 다양한 작업 세트가 있는 일반 형식 게임을 조판하기 위한 명령을 만들려고 합니다. 지금까지 다음 코드가 있습니다.

\documentclass{article}
\usepackage{tikz}
\usepackage{arrayjobx}

\newcommand \Length [1] {%
  \csname total@#1\endcsname
}

\newcommand{\nfgrid}[2]{
\newarray\row
\readarray{row}{#1}
\newarray\col
\readarray{col}{#2}
\draw[-,very thick] (0,0) to (2*\Length{col},0);
\foreach \i in {1,2,...,\Length{row}}{
        \draw[-,very thick] (0,2*\i) to (2*\Length{col},2*\i);
        \node (A) at (-1,2*\i-1) {\row(\the\numexpr\Length{row}-\i+1\relax)};
    }
\draw[-,very thick] (0,0) to (0,2*\Length{row});
\foreach \i in {1,2,...,\Length{col}}{
        \draw[-,very thick] (2*\i,0) to (2*\i,2*\Length{row});
        \node (A) at (2*\i-1,2*\Length{row}+1) {\col(\the\numexpr\i\relax)};
    }
\foreach \i in {1,2,...,\Length{row}}{
    \foreach \j in {1,2,...,\Length{col}}{
        \node (A) at (2*\j-1.5,2*\i-1.5) {R\row(\the\numexpr\Length{row}-\i+1\relax)\col(\the\numexpr \j\relax)};
        \node (A) at (2*\j-0.5,2*\i-0.5) {C\row(\the\numexpr\Length{row}-\i+1\relax)\col(\the\numexpr \j\relax)};
        \draw[-,very thin] (2*\j,2*\i-2) to (2*\j-2,2*\i);
        }
    }
}

\begin{document}
\begin{tikzpicture}
\nfgrid{A&B&C}{W&X&Y&Z}
\end{tikzpicture}
\end{document}

다음 그림이 생성됩니다. 3개의 행과 4개의 열로 구성된 그리드 그림입니다. 열은 W,X,Y,Z로 색인화됩니다. 행은 A, B, C로 색인화됩니다. 그리드의 각 사각형은 대각선으로 절반으로 분할됩니다. 왼쪽 하단 절반은 R로 표시되고 행과 열은 레이블이 지정되며 오른쪽 상단 절반도 C로 시작하여 유사하게 표시됩니다.

보상을 설정하는 다른 명령을 만들고 싶습니다. 즉, 현재 RAW, CAW 등으로 레이블이 지정된 노드의 레이블을 의미합니다. 이를 위해 현재 레이블로 설정한 문자열을 해당 노드의 이름으로 지정하고 싶습니다. 본질적으로 나는 이 코드를 22-23행에서 사용하기를 바랐습니다(작동하지 않음).

\node (R\row(\the\numexpr#1-\i+1\relax)\col(\the\numexpr \j\relax)) at (2*\j-1.5,2*\i-1.5) {};
\node (C\row(\the\numexpr#1-\i+1\relax)\col(\the\numexpr \j\relax)) at (2*\j-0.5,2*\i-0.5) {};

그러나 내가 시도한 어떤 것도 arrayjobx 배열 값을 tikz 노드의 이름으로 사용하는 것을 허용하지 않았습니다. 해결 방법이 있나요? 명령 입력에서 행/열 이름의 배열을 쉽게 읽을 수 있다면 arrayjobx가 아닌 다른 패키지를 사용할 수 있습니다.

답변1

아래 그림과 같이 (R\row(\the\numexpr#1-\i+1\relax)\col(\the\numexpr \j\relax))이름에 대해 제안된 코드는 확장이 불가능 \node하므로 작동하지 않습니다 .\row(1)

\documentclass[border=6pt]{standalone}
\usepackage{arrayjobx}
\begin{document}
\newarray\row
\readarray{row}{a&b&c}
\def\testA{\row(1)}%\def works but \edef does not work
\testA
\end{document}

아래 코드 expl3는 대신 arrayjobx.

프레임은 단일 grid.

이 명령은 \seq_map_indexed_inline:Nn시퀀스를 반복하고 인덱스를 추적하는 데 사용됩니다.

\documentclass[border=6pt]{standalone}
\usepackage{tikz}
\ExplSyntaxOn
\seq_new:N \l__Chip_row_seq
\seq_new:N \l__Chip_column_seq
\NewDocumentCommand \nfgrid { m m }
  {
    \seq_set_from_clist:Nn \l__Chip_row_seq {#1}
    \seq_set_from_clist:Nn \l__Chip_column_seq {#2}
    \draw [ very~thick , step = 2 ] ( 0 , 0 ) grid ( 2 * \seq_count:N \l__Chip_column_seq , 2 * \seq_count:N \l__Chip_row_seq ) ;
    \seq_map_indexed_inline:Nn \l__Chip_row_seq
      {
        \node (##2) at ( -1 , { 2 * ( \seq_count:N \l__Chip_row_seq - ##1 ) + 1 } ) {##2};
      }
    \seq_map_indexed_inline:Nn \l__Chip_column_seq
      {
        \node (##2) at ( 2 * ##1 - 1 , 2 * \seq_count:N \l__Chip_row_seq + 1 ) {##2};
      }
    \seq_map_indexed_inline:Nn \l__Chip_row_seq
      {
        \seq_map_indexed_inline:Nn \l__Chip_column_seq
          {
            \node ( R ##2 ####2 ) at ( 2 * ####1 - 1.5 , { 2 * ( \seq_count:N \l__Chip_row_seq - ##1 ) + 0.5 } ) { R ##2 ####2 };
            \node ( C ##2 ####2 ) at ( 2 * ####1 - 0.5 , { 2 * ( \seq_count:N \l__Chip_row_seq - ##1 ) + 1.5 } ) { C ##2 ####2 };
            \draw [ very~thin ] ( 2 * ####1 - 2 , 2 * ##1 ) -- ++ ( 2 , -2 ) ;
          }
      }
  }
\ExplSyntaxOff
\begin{document}
\begin{tikzpicture}
\nfgrid{A,B,C}{W,X,Y,Z}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보