2

enter image description here

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

How to separate out the sub figures as shown in the image. (Also, to align the two figures side-by-side).

enter image description here

Bernard
  • 271,350
  • 1
    Subfigures are just minipages with captions (@captype). See https://tex.stackexchange.com/questions/186615/how-can-i-arrange-multiple-figures-in-rows-of-3-in-a-two-column-document – John Kormylo May 26 '22 at 14:28
  • @JohnKormylo I don't think OP is using "subfigure" in that sense. – Teepeemm May 26 '22 at 16:29

2 Answers2

2

You can make the figures with the TikZ positioning library.

enter image description here

I put the figure into a macro called \abcsquare that takes an optional argument providing the distance between the squares. (The default value is -.4pt, which accounts for the line thickness so the node boundaries overlap. The lengths of a, b and c are controlled globally by \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] \nodedraw, minimum width=\alen, minimum height=\alen{}; \nodedraw, right=of a, minimum width=\blen, minimum height=\alen{}; \nodedraw, right=of b, minimum width=\clen, minimum height=\alen{}; \nodedraw, above=of c, minimum width=\clen, minimum height=\blen{}; \nodedraw, left=of d, minimum width=\blen, minimum height=\blen{}; \nodedraw, left=of e, minimum width=\alen, minimum height=\blen{}; \nodedraw, above=of f, minimum width=\alen, minimum height=\clen{}; \nodedraw, right=of g, minimum width=\blen, minimum height=\clen{}; \nodedraw, right=of h, minimum width=\clen, minimum height=\clen{}; \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}

If you want you can to add labels to the squares themselves:

enter image description here

\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$};
Sandy G
  • 42,558
  • In the left figure, is it possible (without disturbing the right figure) to dash the lines residing inside of the square – user270610 May 26 '22 at 21:59
1

This is a long comment that you can adapt to your situation. The last frame is a way to horizontally align the left and the right parts of the figure using appropriate shifts \sep. The code of all frames/figures is simple, mostly copying and pasting.

Also see the last part of this answer for the cubed power, projection, and squared power.

enter image description here

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

Black Mild
  • 17,569