Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm a beginner in tikz and need to draw Subgroup lattices. I did figure this "easy" way out, but it doesn't look that good:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{amsfonts}
\begin{document}
\begin{figure}

\begin{tikzpicture}[node distance=2cm]
\title{Untergruppenverband der $A_4$}
\node(A4)                           {$A_4$};
\node(V4)       [below right of=A4] {$V_4$};
\node(C31)      [below left of=A4]  {$C_3$};
\node(C32)      [left of=C31]       {$C_3$};
\node(C33)      [left of=C32]       {$C_3$};
\node(C34)      [left of=C33]       {$C_3$};
\node(C22)      [below of=V4]       {$C_2$};
\node(C21)      [left of=C22]       {$C_2$};
\node(C23)      [right of=C22]      {$C_2$};

\node(1)            [below left of=C21]     {$\left\{1\right\}$};
\draw(A4)       -- (V4);
\draw(A4)       -- (C31);
\draw(A4)       -- (C32);
\draw(A4)       -- (C33);
\draw(A4)       -- (C34);
\draw(C31)      -- (C32);
\draw(C32)      --  (C33);
\draw(C33)      --  (C34);
\draw(C31)      --  (1);
\draw(C32)      --  (1);
\draw(C33)      --  (1);
\draw(C34)      --  (1);
\draw(V4)       -- (C21);
\draw(V4)       -- (C22);
\draw(V4)       -- (C23);
\draw(C21)      -- (C22);
\draw(C22)      -- (C23);
\draw(C21)      --  (1);
\draw(C22)      --  (1);
\draw(C23)      --  (1);
\end{tikzpicture}
\caption{Untergruppenverband}
\end{figure}
\end{document}

output

I want A_4 to be on the top center of the picture and the lines between V_4 and the C_2's and between the C_3's should be shorter. In addition to that, I'd like to put the index of the subgroup (a natural number) on some lines, like a 2 on the lines connecting V_4 and C_2.

I would appreciate any help.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

With tikz you can set an offset between relative positioned nodes. I changed your code a little and stripped repeating draws into \foreach-loops. This way you can save some lines of code and automate some things very easy. There are some more places of code that can be wrapped into loops, but this is just for example.

Furthermore there are labelled lines created with midway-nodes. Just have a look at the code and ask again if you got more questions.

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amsfonts}
\begin{document}
\begin{figure}

% center everything in the figure
\centering
% horizontal node distance
\newcommand{\mydistance}{.6cm}
\begin{tikzpicture}[node distance=2cm]
\title{Untergruppenverband der $A_4$}
\node(A4)                           {$A_4$};
\node(V4)       [below right=2cm and 2cm of A4] {$V_4$};
\node(C31)      [below left=2cm and 0cm of A4]  {$C_3$};
\node(C32)      [left=\mydistance of C31]       {$C_3$};
\node(C33)      [left=\mydistance of C32]       {$C_3$};
\node(C34)      [left=\mydistance of C33]       {$C_3$};
\node(C22)      [below=2cm of V4]       {$C_2$};
\node(C21)      [left=\mydistance of C22]       {$C_2$};
\node(C23)      [right=\mydistance of C22]      {$C_2$};
\node(1)            [below=6cm of A4]     {$\left\{1\right\}$};
\draw(A4)       -- (V4);
\foreach \x\y in {1,2,3,4} {
    \draw (A4) -- (C3\x) node [midway, fill=white] {3};
    \draw (C3\x) -- (1);

}
\foreach \x\y in {1/2,2/3,3/4} {
    \draw(V4) -- (C2\x) node [midway, fill=white] {2};
\draw (C3\x) -- (C3\y);
\draw (C2\x) -- (1);
}
\draw(C21)      -- (C22);
\draw(C22)      -- (C23);
\end{tikzpicture}
\caption{Untergruppenverband}
\end{figure}
\end{document}

enter image description here

share|improve this answer
    
midway is the default setting, so you don't really need to specify that. –  Torbjørn T. Feb 6 at 10:25
    
Thank you, I really appreciate your answer, it helped me a lot! I just got one more question: I don't want the numbers on every line, I'd rather like to put the 2 on the right side of the three lines connecting V_4 and C_2 –  Dominik B. Feb 6 at 10:49
    
If you want the label only of the right side of V4 and C_2 you can do \draw (V4) -- (C22) node[midway, right=1cm] {2}; This way you create a new node aligned between V4 and C22 and put it 1cm to the right. –  moospit Feb 6 at 11:09
    
That is exactly what I was looking for, thanks a lot! –  Dominik B. Feb 6 at 11:24

An alternative where I modified some of your code, for example, the coordinate of node A4 and then all follows will be referenced to it. The node distance=<dim> can be used to increase/reduce the general layout.

enter image description here

Code

\documentclass[12pt]{article}
\usepackage[papersize={25cm,10cm}]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amsfonts}
\begin{document}
\begin{figure}

\begin{tikzpicture}[node distance=2.5cm,line width=1pt]
\title{Untergruppenverband der $A_4$}
\node(A4) at (0,0)     {$A_4$};
\node(V4)       [below right  =0.2cm of A4] {$V_4$};
\node(C31)      [below left of=A4]  {$C_3$};
\node(C32)      [left of=C31]       {$C_3$};
\node(C33)      [left of=C32]       {$C_3$};
\node(C34)      [left of=C33]       {$C_3$};
\node(C21)      [below right of =A4]       {$C_2$};
\node(C22)      [right of=C21]      {$C_2$};
\node(C23)      [right of=C22]      {$C_2$};

\node(1)        [below=5cm of A4]   {$\left\{1\right\}$};
\draw(A4)       -- (V4);
\draw(A4)       -- (C31);
\draw(A4)       -- node[left]{3}  (C32);
\draw(A4)       -- (C33);
\draw(A4)       -- (C34);
\draw(C31)      -- (C32);
\draw(C32)      -- (C33);
\draw(C33)      -- (C34);
\draw(C31)      --  (1);
\draw(C32)      --  (1);
\draw(C33)      --  (1);
\draw(C34)      --  (1);
\draw(V4)       --(C21);
\draw(V4)       -- node[midway,left]{2} (C22);
\draw(V4)       -- (C23);
\draw(C21)      -- (C22);
\draw(C22)      -- (C23);
\draw(C21)      --  (1);
\draw(C22)      --  (1);
\draw(C23)      --  (1);
\end{tikzpicture}
\caption{Untergruppenverband}
\end{figure}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.