# Drawing a graphics with details using Tikz

I'm new to using Tikz for generating graphics in Latex. I've written the following part to generate a 2D domain.

\usepackage{tikz}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
\begin{document}

\begin{document}
\begin{figure}[hbt]
\centering
\begin{tikzpicture}[scale=350]
\centering
\draw[blue,thick] (0,0) -- (0.0219837,0)-- (0.0219837,0.0168148)-- (0.0056579,0.0168148) -- (0.0052959,0.0127) -- (0.0027051,0.0127) -- (0.0027051,0.0142494)--(0,0.0142494) -- cycle;
\filldraw[fill=green!20,draw=green!50!black] (0,0) -- (0.0219837,0)-- (0.0219837,0.0168148)-- (0.0056579,0.0168148) -- (0.0052959,0.0127) -- (0.0027051,0.0127) -- (0.0027051,0.0142494)--(0,0.0142494) -- cycle;
\end{tikzpicture}
\caption{2D domain.}
\label{fig:2D Domain}
\end{figure}
\end{document}


This gives me the following figure:

Now, I want to have something like the following:

So, the addions will be adding labels at each lines/edges, and then defining those labels on the right side of the figure.

• What is 2 supposed to label, as compared to 1? May 12 at 21:21
• Hi Bernard, that top left line is divided into 2 labels. May 12 at 22:17

With use of the quotes library and package enumitem your code be significantly shorten (i.e. to be concise):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{quotes}
\usepackage{enumitem}

\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}[scale=350,
auto]
\filldraw[fill=green!20,draw=green!50!black]
(0,0)   to["4"] (0.0219837,0)
to["5"] coordinate (R) (0.0219837,0.0168148)
to["6"] (0.0056579,0.0168148)
to["7"] (0.0052959,0.0127)
to["8"] (0.0027051,0.0127)
to["9"] (0.0027051,0.0142494)  node[above left] {1}
to      (0,0.0142494)  node[above right] {2}
to["3"] cycle;
\node[right=1em, text width=10em] at (R) {%
Details:
\begin{description}[nosep,format=\normalfont]
\item[1:]   Section area A
\item[2:]   Section area B
\item[3:]   Symmetry axis
\item[4:]   Surface C
\item[5,6:]     Opening
\item[7,8,9:]   Surface area D
\end{description}
};
\end{tikzpicture}
\end{document}


• +1 Nice answer , Zarko. May 12 at 22:48
• Thanks, Zarko. This is helpful. May 12 at 22:50

Your code didn't compile, btw. Here's what you want, I think:

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
\usetikzlibrary{positioning}
\begin{document}

\begin{figure}[hbt]
\centering
\begin{tikzpicture}[scale=350]
\centering
\draw[blue,thick] (0,0) -- (0.0219837,0)-- (0.0219837,0.0168148)-- (0.0056579,0.0168148) -- (0.0052959,0.0127) -- (0.0027051,0.0127) -- (0.0027051,0.0142494)--(0,0.0142494) -- cycle;
\filldraw[fill=green!20,draw=green!50!black]
(0,0)   -- (0.0219837,0) node[midway,above]{4}
-- (0.0219837,0.0168148) node[midway,left](A){5}
-- (0.0056579,0.0168148) node[midway,below]{6}
-- (0.0052959,0.0127) node[midway,right]{7}
-- (0.0027051,0.0127) node[midway,below]{8}
-- (0.0027051,0.0142494) node[midway,left]{9}
--(0,0.0142494) node[pos=0.2,above]{1} node[pos=0.6,above]{2}
-- cycle node[midway,left]{3};
\node[right=5pt of A,text width=4cm] {Details:\\1: Section Area A\\Etc.};
\end{tikzpicture}
\caption{2D domain.}
\label{fig:2D Domain}
\end{figure}
\end{document}

• Hi SebGlav, I think I forgot to paste the additional libraries from my project (which is a long one), that's why might have shown errors. May 12 at 22:18
• Thanks for your help. May 12 at 22:18
• There are two \begin{document}` and some inacurracies that you will have to check, but anyway. Feel free to vote up (up arrow on the left) this answer and maybe accept it (check mark) if it suits you, in order to let know that you found what you were looking for. May 12 at 22:21
• Yeah, I see that now. Thanks for your help, it works fine for me. May 12 at 22:23