\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}