# How to write text in each subpart of box?

I want to write a letter in each box mentioned below. I also want to write a text on the top of the rectangle.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) -- (5,0);
\draw (5,0) -- (5,5);
\draw (0,0) -- (0,5);
\draw (0,5) -- (5,5);
\draw (2.5,0) -- (2.5,5);
\draw (0,2.5) -- (5,2.5);
\draw (1.25,0) -- (1.25,2.5);
\draw (0,1.25) -- (2.5,1.25);
\end{tikzpicture}

\end{document}


## 2 Answers

Here is a way.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) -- (5,0);
\draw (5,0) -- (5,5);
\draw (0,0) -- (0,5);
\draw (0,5) -- (5,5);
\draw (2.5,0) -- (2.5,5);
\draw (0,2.5) -- (5,2.5);
\draw (1.25,0) -- (1.25,2.5);
\draw (0,1.25) -- (2.5,1.25);
\node (A) at (0.625,0.625) {A};
\node (B) at (1.85,0.625) {B};
\node (C) at (0.625,1.85) {C};
\node (D) at (1.85,1.85) {D};
\node (E) at (3.75,1.25) {E};
\node (F) at (1.25,3.75) {F};
\node (G) at (3.75,3.75) {G};
\node (text) at (2.5,5.25) {Some Text...};
\end{tikzpicture}

\end{document}


With nodes, relative positioned to each other, size is node parameter:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
node distance = 0pt,
box/.style = {draw, minimum size=#1, outer sep=0pt}
]
\node (a) [box=10mm] {A};
\node (b) [box=10mm, right=of a] {B};
\node (c) [box=5mm,  below right=of a.south west] {C};
\node (d) [box=5mm,  right=of c] {D};
\node (e) [box=5mm,  below=of c] {E};
\node (f) [box=5mm,  right=of e] {F};
\node (G) [box=10mm, right=of d.south east] {G};
%
\node[above=of a.north east] {image title};
\end{tikzpicture}


**Addendum: With common defined size of nodes. Now you can simple change nodes size by selecting \w, a width and height of nodes.

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
node distance = 0pt,
box/.style = {draw, minimum size=#1, inner sep=0pt, outer sep=0pt}
]
\def\w{12.5mm}
\node (a) [box=2*\w] {A};
\node (b) [box=2*\w,    right=of a] {B};
\node (c) [box=\w,  below right=of a.south west] {C};
\node (d) [box=\w,  right=of c] {D};
\node (e) [box=\w,  below=of c] {E};
\node (f) [box=\w,  right=of e] {F};
\node (G) [box=2*\w,    right=of d.south east] {G};
%
\node[above=of a.north east] {image title};
\end{tikzpicture}

\end{document}


Result is similar as before.