我怎样才能按照这种特定的排列方式绘制带有箭头的平铺图像?

我怎样才能按照这种特定的排列方式绘制带有箭头的平铺图像?

在此处输入图片描述

斐波那契定理的平铺解释

这是我必须说明平铺图像的基本代码大纲。我可以修改代码以采用任何颜色或大小,但我对对齐感到困惑。如何按照给定图像中所示的特定对齐方式用箭头和下标表示我的平铺?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{array}
\usepackage{mathtools}
\usepackage{xparse}
\usepackage{bigstrut}

\usepackage[table, svgnames]{xcolor} 
\usepackage{boldline} 
\DeclareExpandableDocumentCommand{\colourcells}{O{2}m}{\multicolumn{#1}{c|}{\cellcolor{#2}\bigstrut}}
\newcommand{\redcell}{\cellcolor{Red}\strut}
\newcommand{\mathcell}[1]{\multicolumn{1}{c}{\boldmath$#1$\bigstrut}}

\begin{document}

\begin{table}\itshape
\setlength{\arrayrulewidth}{2pt}
\setlength{\bigstrutjot}{2.2ex}
\begin{tabular}{*{8}{p{0.7cm}|}}
    \hline
& & & & & \colourcells{NavyBlue} & \redcell \\
\hline
\multicolumn{3}{c}{} & \mathcell{n{-}1} & \mathcell{n} & \mathcell{n {+} 1} & \mathcell{n {+} 2} & \mathcell{n {+} 3} \\
\hline
 & & & & &\redcell & \colourcells{NavyBlue}
  \\
 \hline
\multicolumn{3}{c}{} & \mathcell{n{-}1} & \mathcell{n} & \mathcell{n {+} 1} & \mathcell{n {+} 2} & \mathcell{n {+} 3} \\
\hline
 & & & & &\redcell &\redcell &\redcell\rule[-4.5ex]{1pt}{0ex} \\
 \hline
\multicolumn{3}{c}{} & \mathcell{n{-}1} & \mathcell{n} & \mathcell{n {+} 1} & \mathcell{n {+} 2} & \mathcell{n {+} 3} \\
\hline
 & & & &
  \colourcells{NavyBlue} &\colourcells{NavyBlue} \\
 \hline
\multicolumn{3}{c}{} & \mathcell{n{-}1} & \mathcell{n} & \mathcell{n {+} 1} & \mathcell{n {+} 2} & \mathcell{n {+} 3} \\
\hline
 & & & &
  \colourcells{NavyBlue} & \redcell & \redcell \\
 \hline
\multicolumn{3}{c}{} & \mathcell{n{-}1} & \mathcell{n} & \mathcell{n {+} 1} & \mathcell{n {+} 2} & \mathcell{n {+} 3}
\end{tabular}
\end{table}

\end{document} 

答案1

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\newcommand{\Domino}[2]{%
\foreach  \X/\Y [count=\Z] in {#1}
{\ifnum\Z=1
\draw[thick,fill=\Y] (0,0) rectangle (\X,1);
\draw[thick,latex-latex] (0,0.5) -- (\X,0.5) node[midway,fill=\Y]{#2};
\xdef\lastX{\X}
\else
\draw[thick,fill=\Y] (\lastX,0) rectangle ({\lastX+\X},1);
\pgfmathsetmacro{\lastX}{\lastX+\X}
\xdef\lastX{\lastX}
\fi
}}
\begin{tikzpicture}[font=\sffamily,fat arrow/.style={->,ultra thick,shorten
>=2pt, shorten <=2pt}]
\begin{scope}[local bounding box=left tiling]
\Domino{5/white}{$n$-tiling}
\end{scope}
\begin{scope}[xshift=6.5cm]
 \begin{scope}[yshift=2cm,local bounding box=tiling 1]
  \Domino{7/white,1/blue,1/blue}{$n$-tiling}
 \end{scope}
 \node[anchor=north east] at (tiling 1.south east){Add a domino};
 \begin{scope}[local bounding box=tiling 2]
  \Domino{7/white,1/red,1/red}{$n$-tiling}
 \end{scope}
 \node[anchor=north east] at (tiling 2.south east){Add two squares};
 \begin{scope}[yshift=-2cm,local bounding box=tiling 3]
  \Domino{6/white,1/blue,1/blue,1/white}{$(n-1)$-tiling}
 \end{scope}
 \node[anchor=north east] at (tiling 3.south east){Insert domino before squares};
 \begin{scope}[yshift=-4cm,local bounding box=tiling 4]
  \Domino{5/white}{$(n-2)$-tiling}
 \end{scope}
 \node[anchor=north east] at (tiling 4.south east -|tiling 3.south east)
 {Remove domino};
\end{scope}
\draw[decorate,very thick,decoration={brace}] ([xshift=-2pt]tiling 4.south west) --
([xshift=-2pt]tiling 3.north west) coordinate[midway,left=3pt] (X);
\draw[fat arrow] (left tiling) -- (tiling 1.west);
\draw[fat arrow] (left tiling) -- (tiling 2.west);
\draw[fat arrow] (left tiling) -- (X);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容