# Math Help - diagram

1. ## diagram

Hi, how can I drawing this diagram with latex?

Thanks

2. ## Re: diagram

See the Graphics section in these TeX FAQs about drawing in LaTeX.

Here is my attempt in TikZ. I could not quite make out the labels, so they may need to be changed.

The code is the following.
Code:
\begin{tikzpicture}
\newcommand{\crcl}[2]{circle (\rad) node[#1] {$H_{#2}$}}
\newcommand{\row}[3]{\filldraw (#1,#2) \crcl{#3}{1} \foreach \i in {2, ..., 4} { -- ++(2,0) \crcl{#3}{\i} };}
\begin{scope}[rotate=-30]
\row{0}{0}{above=2pt}
\row{2}{-1.5}{below=2pt}
\foreach \x in {2,4,6} \draw (\x,0) -- (\x,-1.5);
\end{scope}
\end{tikzpicture}
It may not be the simplest way of doing this. I wanted to practice by making the code shorter.

3. ## Re: diagram

Originally Posted by emakarov
See the Graphics section in these TeX FAQs about drawing in LaTeX.

Here is my attempt in TikZ. I could not quite make out the labels, so they may need to be changed.

The code is the following.
Code:
\begin{tikzpicture}
\newcommand{\crcl}[2]{circle (\rad) node[#1] {$H_{#2}$}}
\newcommand{\row}[3]{\filldraw (#1,#2) \crcl{#3}{1} \foreach \i in {2, ..., 4} { -- ++(2,0) \crcl{#3}{\i} };}
\begin{scope}[rotate=-30]
\row{0}{0}{above=2pt}
\row{2}{-1.5}{below=2pt}
\foreach \x in {2,4,6} \draw (\x,0) -- (\x,-1.5);
\end{scope}
\end{tikzpicture}
It may not be the simplest way of doing this. I wanted to practice by making the code shorter.
Ok. Thanks a lot. I practice more, but I have one question. how can I writ any thing instaed H1, H2,....? for example I write A, K, M, B ineasted H1, H2,H3 and H4, and on the underneath I write for example j, i , l , o

4. ## Re: diagram

You could do the following.

Code:
\begin{tikzpicture}
\newcommand{\crcl}[2]{circle (\rad) node[#1] {$#2$}}
\newcommand{\row}[5]{\filldraw (#1,#2) \crcl{#3}{#4} \foreach \i in {#5} { -- ++(2,0) \crcl{#3}{\i} };}
\begin{scope}[rotate=-30]
\row{0}{0}{above=2pt}{A}{B, C, D}
\row{2}{-1.5}{below=2pt}{E}{F, G, H}
\foreach \x in {2,4,6} \draw (\x,0) -- (\x,-1.5);
\end{scope}
\end{tikzpicture}
Here is another variant.

Code:
\begin{tikzpicture}
\newcommand{\crcl}[2]{circle (\rad)  coordinate (#1) node[#2] {$#1$}}
\end{tikzpicture}