기사 투어 그림 다이어그램

기사 투어 그림 다이어그램

손으로 쓴 수업 노트를 LaTeX로 변환하고 있습니다. 그리고 tikz 패키지를 이용해서 만든 피규어도 있습니다. 말의 움직임을 표현한 아래의 피규어를 LaTeX로 변환하는 것이 가능한가요?무비멘토스 두 카발로

답변1

\foreach약간의 교대 및 회전이 포함된 루프를 기반으로 하는 또 다른 옵션입니다 .

\documentclass[tikz,border=2mm]{standalone}

\begin{document}
\begin{tikzpicture}[scale=0.7]
% checkerboard, remove it if you want
\begin{scope}
  \clip (1.7,1.7) rectangle (7.3,7.3);
  \foreach\i in {1,2,3,4} \foreach\j in {1,...,7}
    \fill[gray!30] ({2*\i-1+mod(\j,2)},\j) rectangle++ (1,1);
\end{scope}
% axes
\foreach[count=\ii from 0]\i in {x,y}
  \draw[-latex,thick,shift={(-1,-1)},rotate=90*\ii] (1,0) --++ (9,0) 
   node[midway,shift={(-0.5*\ii,0.5*\ii-0.5)}] {$\i$};
% rectangles
\foreach\i in {0,4}
  \draw[thick] (\i,\i) rectangle (9-\i,9-\i);
% movements
\foreach\i in {0,90,180,270} \foreach\j in {-1,1}
  \draw[shift={(4.5,4.5)},rotate=\i] (0.5,0.25*\j) -|++ (1.5,0.75*\j)
   node[circle,fill,inner sep=0.5mm] {};
% (i,j)
\node at (7,-2.5) {$(i,j)$};
\end{tikzpicture}
\end{document}

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

답변2

이것이 출발점이 될 수 있습니다:

\documentclass[tikz, margin=5pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
  , thick
  , box/.style = {
    , minimum width = #1
    , minimum height = #1
    , draw
  }
  , end/.style = {
    , draw
    , circle
    , minimum width = 2
    , fill = black
    , inner sep = 0
  }
  , arr/.style = {
    , -latex
  }
]
  \node (outer) [box = 100] {}; % a node named outer (of size 100x100)
  \node (inner) [box = 10] {};  % a node named inner (of size 10x10)
  \draw (inner.20) -| ++ (20pt, 10pt) node [end] {}; % from 20 degree of inner
  \draw (inner.-20) -| ++ (20pt, -10pt) node [end] {};
  \draw (inner.20+90) |- ++ (-10pt, 20pt) node [end] {};
  \draw (inner.-20+90) |- ++ (10pt, 20pt) node [end] {};
  \draw (inner.20-90) |- ++ (10pt, -20pt) node [end] {};
  \draw (inner.-20-90) |- ++ (-10pt, -20pt) node [end] {};
  \draw (inner.20+180) -| ++ (-20pt, -10pt) node [end] {};
  \draw (inner.-20+180) -| ++ (-20pt, +10pt) node [end] {};

  \draw [arr] ([yshift = -10]outer.south west) -- ([yshift = -10]outer.south east) node [midway, below] {$x$};
  \draw [arr] ([xshift = -10]outer.south west) -- ([xshift = -10]outer.north west) node [midway, left] {$y$};

  % use the positioning library
  \node [below right = 60pt and 30pt of inner] {$(i,j)$};
  
\end{tikzpicture}%
\end{document}

결과

관련 정보