a+b+c 整数平方中子图形的分离

a+b+c 整数平方中子图形的分离

在此处输入图片描述

\documentclass{standalone}
\usepackage   {tikz}
\usepackage   {tkz-euclide}

\begin{document}

\newcommand{\length}{6}
\newcommand{\Width}{6}

\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (1,0);
\coordinate (c) at (3,0);
\coordinate (d) at (6,0);
\coordinate (e) at (0,1);
\coordinate (f) at (1,1);
\coordinate (g) at (3,1);
\coordinate (h) at (6,1);
\coordinate (i) at (0,3);
\coordinate (j) at (1,3);
\coordinate (k) at (3,3);
\coordinate (l) at (6,3);
\coordinate (m) at (0,6);
\coordinate (n) at (1,6);
\coordinate (o) at (3,6);
\coordinate (p) at (6,6);

\draw (a) -- (d) -- (p) -- (m) -- cycle;
\draw (e) -- (h);
\draw (i) -- (l);
\draw (b) -- (n);
\draw (c) -- (o);

\draw[|-|] ($(a)!2.5mm!-90:(b)$)--node[fill=white] {$a$} ($(b)!2.5mm!90:(a)$);
\draw[|-|] ($(b)!2.5mm!-90:(c)$)--node[fill=white] {$b$} ($(c)!2.5mm!90:(b)$);
\draw[|-|] ($(c)!2.5mm!-90:(d)$)--node[fill=white] {$c$} ($(d)!2.5mm!90:(c)$);
\draw[|-|] ($(a)!2.5mm!90:(e)$)--node[fill=white] {$a$} ($(e)!2.5mm!-90:(a)$);
\draw[|-|] ($(e)!2.5mm!90:(i)$)--node[fill=white] {$b$} ($(i)!2.5mm!-90:(e)$);
\draw[|-|] ($(i)!2.5mm!90:(m)$)--node[fill=white] {$c$} ($(m)!2.5mm!-90:(i)$);

\end{tikzpicture}

\end{document}

如何分离图像中所示的子图形。(此外,还要将两个图形并排对齐)。

在此处输入图片描述

答案1

您可以使用 TikZ 库制作图形positioning

在此处输入图片描述

我将图形放入一个名为的宏中,\abcsquare该宏接受一个可选参数来提供方块之间的距离。(默认值为,它考虑了线条的粗细,因此节点边界重叠。a、b 和 c 的长度由、、-.4pt全局控制。\alen\blen\clen

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\newcommand{\alen}{.7cm}
\newcommand{\blen}{1.5cm}
\newcommand{\clen}{2.4cm}

\newcommand{\abcsquare}[1][-.4pt]{
    \begin{tikzpicture}[baseline, node distance=#1]
    \node[draw, minimum width=\alen, minimum height=\alen](a){};
    \node[draw, right=of a, minimum width=\blen, minimum height=\alen](b){};
    \node[draw, right=of b, minimum width=\clen, minimum height=\alen](c){};
    \node[draw, above=of c, minimum width=\clen, minimum height=\blen](d){};
    \node[draw, left=of d, minimum width=\blen, minimum height=\blen](e){};
    \node[draw, left=of e, minimum width=\alen, minimum height=\blen](f){};
    \node[draw, above=of f, minimum width=\alen, minimum height=\clen](g){};
    \node[draw, right=of g, minimum width=\blen, minimum height=\clen](h){};
    \node[draw, right=of h, minimum width=\clen, minimum height=\clen](i){};
    \draw[|-|]([yshift=-3mm]a.south west) -- node[fill=white]{$a$}([yshift=-3mm]a.south east);
    \draw[|-|]([yshift=-3mm]b.south west) -- node[fill=white]{$b$}([yshift=-3mm]b.south east){};
    \draw[|-|]([yshift=-3mm]c.south west) -- node[fill=white]{$c$}([yshift=-3mm]c.south east){};
    \draw[|-|]([xshift=-3mm]a.south west){} -- node[fill=white]{$a$}([xshift=-3mm]a.north west){};
    \draw[|-|]([xshift=-3mm]f.south west){} -- node[fill=white]{$b$}([xshift=-3mm]f.north west){};
    \draw[|-|]([xshift=-3mm]g.south west){} -- node[fill=white]{$c$}([xshift=-3mm]g.north west){};
    \end{tikzpicture}}

\begin{document}
\[
\abcsquare\hspace{2cm}\abcsquare[3mm]
\]
\end{document}

如果你愿意,你可以给方块本身添加标签:

在此处输入图片描述

\node[draw, right=of a, minimum width=\blen, minimum height=\alen](b){$ab$};
\node[draw, right=of b, minimum width=\clen, minimum height=\alen](c){$ac$};
\node[draw, above=of c, minimum width=\clen, minimum height=\blen](d){$bc$};
\node[draw, left=of d, minimum width=\blen, minimum height=\blen](e){$b^2$};
\node[draw, left=of e, minimum width=\alen, minimum height=\blen](f){$ab$};
\node[draw, above=of f, minimum width=\alen, minimum height=\clen](g){$ac$};
\node[draw, right=of g, minimum width=\blen, minimum height=\clen](h){$bc$};
\node[draw, right=of h, minimum width=\clen, minimum height=\clen](i){$c^2$};

答案2

这是一个很长的注释,您可以根据自己的情况进行调整。最后一帧是使用适当的移位水平对齐图形左右部分的方法\sep。所有帧/图形的代码都很简单,主要是复制和粘贴。

另请参阅这个答案用于立方功率、投影和平方功率。

在此处输入图片描述

\documentclass{beamer}
\usepackage{tikz}
\title{$a + b$ whole squared}
%\author{Le Huy Tien}
%\date{May 2022}
\begin{document}
\maketitle
\begin{frame}{What is this ?}
\begin{center}
\begin{tikzpicture}
\def\a{1.5}
\def\b{3.5}
\draw 
(\a,0)--(\a,\a+\b) (0,\b)--(\a+\b,\b)
(0,0) rectangle (\a+\b,\a+\b)
;
\end{tikzpicture}    
\end{center}
\end{frame}
\begin{frame}{What is this ?}
\begin{center}
\begin{tikzpicture}
\def\a{1.5}
\def\b{3.5}
\colorlet{colora}{cyan!50}
\colorlet{colorb}{yellow!50}
\fill[colora] (0,\b) rectangle (\a,\a+\b);
\fill[colorb] (\a,0) rectangle (\a+\b,\b);
\fill[colora!50!colorb] 
(0,0) rectangle (\a,\b) rectangle (\a+\b,\a+\b);
\end{tikzpicture}    
\end{center}
\end{frame}
\begin{frame}{$(a+b)^2=a^2+2ab+b^2$}
\begin{center}
\begin{tikzpicture}[nodes={midway}]
\def\a{1.5}
\def\b{3.5}
\colorlet{colora}{cyan!50}
\colorlet{colorb}{yellow!50}
\draw[fill=colora] (0,\b) rectangle (\a,\a+\b) node{$a^2$};
\draw[fill=colorb] (\a,0) rectangle (\a+\b,\b) node{$b^2$};
\draw[fill=colora!50!colorb] (0,0) 
rectangle (\a,\b) node{$ab$}
rectangle (\a+\b,\a+\b) node{$ab$};
\draw[|-|,shift={(-.5,0)},gray] 
(0,0)--(0,\b) node[fill=white,midway]{$b$};
\draw[-|,shift={(-.5,0)},gray] (0,\b)--(0,\a+\b) node[fill=white,midway]{$a$}; 
\draw[|-|,shift={(0,.5)},gray] 
(0,\a+\b)--(\a,\a+\b) node[fill=white,midway]{$a$};
\draw[-|,shift={(0,.5)},gray] 
(\a,\a+\b)--(\a+\b,\a+\b) node[fill=white,midway]{$b$};
\end{tikzpicture}    
\end{center}
\end{frame}
\begin{frame}{}
\begin{center}
\begin{tikzpicture}[nodes={midway}]
\def\a{1}
\def\b{2.5}
\colorlet{colora}{cyan!50}
\colorlet{colorb}{yellow!50}
\draw[fill=colora] (0,\b) rectangle (\a,\a+\b) node{$a^2$};
\draw[fill=colorb] (\a,0) rectangle (\a+\b,\b) node{$b^2$};
\draw[fill=colora!50!colorb] (0,0) 
rectangle (\a,\b) node{$ab$}
rectangle (\a+\b,\a+\b) node{$ab$};
\draw[|-|,shift={(-.5,0)},gray] 
(0,0)--(0,\b) node[fill=white,midway]{$b$};
\draw[-|,shift={(-.5,0)},gray] (0,\b)--(0,\a+\b) node[fill=white,midway]{$a$}; 
\draw[|-|,shift={(0,.5)},gray] 
(0,\a+\b)--(\a,\a+\b) node[fill=white,midway]{$a$};
\draw[-|,shift={(0,.5)},gray] 
(\a,\a+\b)--(\a+\b,\a+\b) node[fill=white,midway]{$b$};

\def\sep{.3}  % for shifts
\begin{scope}[shift={(5,0)}]
\draw[fill=colora,shift={(0,\sep)}] (0,\b) rectangle (\a,\a+\b) node{$a^2$};
\draw[fill=colorb,shift={(\sep,0)}] (\a,0) rectangle (\a+\b,\b) node{$b^2$};
\draw[fill=colora!50!colorb] 
(0,0) rectangle (\a,\b) node{$ab$};
\draw[fill=colora!50!colorb,shift={(\sep,\sep)}]
(\a,\b) rectangle (\a+\b,\a+\b) node{$ab$};
\end{scope}
\end{tikzpicture}    
\end{center}
\end{frame}

\end{document}

相关内容