# diagram

• Sep 30th 2013, 11:10 AM
vernal
diagram
Hi, how can I drawing this diagram with latex?

Thanks
• Sep 30th 2013, 01:23 PM
emakarov
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{\rad}{1.5pt} \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.
• Sep 30th 2013, 01:47 PM
vernal
Re: diagram
Quote:

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{\rad}{1.5pt} \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
• Sep 30th 2013, 02:21 PM
emakarov
Re: diagram
You could do the following.

Code:

\begin{tikzpicture} \newcommand{\rad}{1.5pt} \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{\rad}{1.5pt} \newcommand{\crcl}[2]{circle (\rad)  coordinate (#1) node[#2] {$#1$}} \newcommand{\row}[2]{\foreach \lbl in {#1} {++(2,0) \crcl{\lbl}{#2}};} \begin{scope}[rotate=-30] \fill (0,0) \row{A, K, M, B}{above=2pt} \fill (2,-1.5) \row{j, i, l, o}{below=2pt} \draw (A) -- (K) -- (M) -- (B) (j) -- (i) -- (l) -- (o) (K) -- (j) (M) -- (i) (B) -- (l); \end{scope} \end{tikzpicture}