\begin{longtable}{|p{7cm}|p{10cm}|}
\hline
\begin{tikzpicture} %1
\coordinate[label = below:$A$] (A) at (0,0);
\coordinate[label = above:$B$] (B) at (0,3);
\coordinate[label = above:$C$] (C) at (6,3);
\coordinate[label = below:$D$] (D) at (6,0);
\draw[ultra thick] (A) -- (B) -- (C) -- (D) -- cycle;
\tkzLabelSegment[left](A,B){$3$};
\tkzLabelSegment[above](B,C){$6$};
\end{tikzpicture} & \\
\hline
\begin{center}
\begin{tikzpicture} %2
\coordinate[label = below:$A$] (A) at (0,0);
\coordinate[label = above:$B$] (B) at (0,3);
\coordinate[label = above:$C$] (C) at (3,3);
\coordinate[label = below:$D$] (D) at (3,0);
\draw[ultra thick] (A) -- (B) -- (C) -- (D) -- cycle;
\tkzMarkSegment[mark = |](A,B);
\tkzMarkSegment[mark = |](B,C);
\node at (1.5, 1.5){$P=36$};
\end{tikzpicture} \end{center}& \\
\hline
\end{longtable}
답변1
의 .{NiceTabular}
nicematrix
귀하의 코드를 가져왔습니다( 페이지 너비에 맞추기 위해 p{3cm}
대신 서문을 넣었습니다).p{10cm}
{longtable}
으로 교체했습니다 {NiceTabular}
.
숫자가 포함된 작은 사각형을 그리기 위해 \CodeAfter
환경에 Tikz 지침을 추가했습니다 .{NiceTabular}
\begin{tikzpicture}
\node at (1-|1) [below right] { 1 } ;
\draw (1-|1) rectangle ++(5mm,-5mm) ;
\node at (2-|1) [below right] { 2 } ;
\draw (2-|1) rectangle ++(5mm,-5mm) ;
\end{tikzpicture}
전체 코드는 다음과 같습니다.
\documentclass{article}
\usepackage{geometry}
\usepackage{nicematrix}
\usepackage{tikz,tkz-euclide}
\begin{document}
\begin{NiceTabular}{|p{7cm}|p{3cm}|}
\hline
\begin{tikzpicture} %1
\coordinate[label = below:$A$] (A) at (0,0);
\coordinate[label = above:$B$] (B) at (0,3);
\coordinate[label = above:$C$] (C) at (6,3);
\coordinate[label = below:$D$] (D) at (6,0);
\draw[ultra thick] (A) -- (B) -- (C) -- (D) -- cycle;
\tkzLabelSegment[left](A,B){$3$};
\tkzLabelSegment[above](B,C){$6$};
\end{tikzpicture} & \\
\hline
\begin{center}
\begin{tikzpicture} %2
\coordinate[label = below:$A$] (A) at (0,0);
\coordinate[label = above:$B$] (B) at (0,3);
\coordinate[label = above:$C$] (C) at (3,3);
\coordinate[label = below:$D$] (D) at (3,0);
\draw[ultra thick] (A) -- (B) -- (C) -- (D) -- cycle;
\tkzMarkSegment[mark = |](A,B);
\tkzMarkSegment[mark = |](B,C);
\node at (1.5, 1.5){$P=36$};
\end{tikzpicture} \end{center}& \\
\hline
\CodeAfter
\begin{tikzpicture}
\node at (1-|1) [below right] { 1 } ;
\draw (1-|1) rectangle ++(5mm,-5mm) ;
\node at (2-|1) [below right] { 2 } ;
\draw (2-|1) rectangle ++(5mm,-5mm) ;
\end{tikzpicture}
\end{NiceTabular}
\end{document}
답변2
제가 보기에 사진에서 볼 수 있듯이 테이블은 필요하지 않고 tikzpicture
두 개의 가 있는 테이블만 필요하며 scopes
각 테이블은 scope
셀 역할을 합니다.
원점을 각 '셀'의 중앙에 두는 것이 더 간단하다고 생각하여 좌표를 변경했습니다.
아이디어는 다음과 같습니다.
\documentclass{article}
\usepackage{lipsum} % dummy text
\usepackage{tikz,tkz-euclide}
\begin{document}
\lipsum[1][1-2]
\begin{figure}[ht]\centering
\begin{tikzpicture}[scale=0.75]
\def\sepx{8}
\def\sepy{6}
\foreach\x in {1,2} \foreach\y in {1,2,3}
{
\pgfmathtruncatemacro\n{3*\x+\y-3}
\draw (\x*\sepx-\sepx+0.8,-\y*\sepy+\sepy) |-++ (-0.8,-0.8);
\node at (\x*\sepx-\sepx+0.4,-\y*\sepy+\sepy-0.4) {$\n$};
}
\draw (0,0) grid[xstep=\sepx,ystep=\sepy] (16,-18);
%1
\begin{scope}[shift={(0.5*\sepx,-0.5*\sepy)}]
\coordinate[label = below:$A$] (A) at (-3,-1.5);
\coordinate[label = above:$B$] (B) at (-3,1.5);
\coordinate[label = above:$C$] (C) at (3,1.5);
\coordinate[label = below:$D$] (D) at (3,-1.5);
\draw[ultra thick] (A) -- (B) -- (C) -- (D) -- cycle;
\tkzLabelSegment[left](A,B){$3$};
\tkzLabelSegment[above](B,C){$6$};
\end{scope}
%2
\begin{scope}[shift={(1.5*\sepx,-0.5*\sepy)}]
\coordinate[label = below:$A$] (A) at (-1.5,-1.5);
\coordinate[label = above:$B$] (B) at (-1.5,1.5);
\coordinate[label = above:$C$] (C) at (1.5,1.5);
\coordinate[label = below:$D$] (D) at (1.5,-1.5);
\draw[ultra thick] (A) -- (B) -- (C) -- (D) -- cycle;
\tkzMarkSegment[mark = |](A,B);
\tkzMarkSegment[mark = |](B,C);
\node at (0,0){$P=36$};
\end{scope}
%3
\begin{scope}[shift={(0.5*\sepx,-1.5*\sepy)}]
\draw[ultra thick] (0,0) circle (2);
\end{scope}
\end{tikzpicture}
\end{figure}
\lipsum[2][1-3]
\end{document}