# How can I produce a Hasse (or lattice) diagram?

I want to produce a some kind of lattice diagram, such as a Hasse diagram. How can I do so? I tried using matrix with letters and slashes but it seems ugly. Do I need any additional packages?

EDIT: I mean graph like this one (for zessenhaous lemma):

-
what is a lattice, hasse graph? – percusse Aug 22 '13 at 15:10
there are several packages that are intended to create such diagrams. someone will probably recommend tikz. xypic and pstricks also provide such capabilities. – barbara beeton Aug 22 '13 at 16:56
In LyX, go to File > Open then go to examples, then click on "xypic.lyx". Similarly, you could try Help > Specific Manuals > XY-pic Manual (although this might have been added only in a recent version, I forget). Both documents are the same. – scottkosty Aug 22 '13 at 22:53
– Peter Grill Aug 23 '13 at 23:59
Paul Taylor's diagrams package will also work. I'm not sure which is easiest. – isomorphismes Mar 17 '15 at 17:33

According to @barbarabeeton, here comes a possible PSTricks solution for the example you gave:

\documentclass[preview,border=3pt]{standalone}
\usepackage{pst-node}
\begin{document}
\psset{nodesep=3pt}
\newpsstyle{DblDash}{linestyle=dashed, dash=1pt 1.5pt, doubleline}
\begin{psmatrix}[mnode=r,colsep=0.6,rowsep=0.5]
[name=11] $A_1$ & & & & [name=12] $B_2$\\
& [name=21] $A(A_1\cap B_1)$ & & [name=22] $B(A_1\cap B_1)$ \\
& [name=31] $A(A_1\cap B)$ & [name=32] $A_1\cap B_1$ & [name=33] $B(A\cap B_1)$ \\
[name=41] $A$ & & [name=42] $D$ & & [name=43] $B$\\
& [name=51] $A\cap B_1$ & & [name=52] $A_1 \cap B$ \\
& & [name=61] $A\cap B$
\ncline{11}{21}\ncline{12}{22}
\ncline{21}{32}\ncline{22}{32}
\ncline[style=DblDash]{21}{31}
\ncline[style=DblDash]{22}{33}
\ncline{31}{41}\ncline{31}{42}\ncline{32}{42}\ncline{33}{42}\ncline{33}{43}
\ncline{41}{51}\ncline{42}{51}\ncline{42}{52}\ncline{42}{52}
\ncline{51}{61}\ncline{52}{61}
\end{psmatrix}
\end{document}


This gives the output:

-

It's quite easy with tikz-cd, with a very natural syntax. I tried [double,densely dotted], but the result is not really nice.

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[tips=false,column sep=1em,row sep=1.5em]
A_1 \ar{dr} &&&& B_1 \ar{dl} \\
& A(A_1\cap B_1) \ar{dr}
\ar[densely dotted,shift left=.2ex]{d}
\ar[densely dotted,shift right=.2ex]{d} &&
B(A_1\cap B_1) \ar{dl}
\ar[densely dotted,shift left=.2ex]{d}
\ar[densely dotted,shift right=.2ex]{d} \\
& A(A_1\cap B_1) \ar{dl} \ar{dr} & A_1\cap B_1 \ar{d} &
B(A_1\cap B_1) \ar{dl} \ar{dr} \\
A \ar{dr} && D \ar{dl} \ar{dr}  && B \ar{dl} \\
& A\cap B_1 \ar{dr} && A_1\cap B \ar{dl} \\
&& A\cap B
\end{tikzcd}

\end{document}


-

Just for fun, with TikZ and borrowing some code from Christoph answer

\documentclass[tikz,border=3pt]{standalone}
\usetikzlibrary{matrix}
\begin{document}

\begin{tikzpicture}

\matrix (a) [matrix of math nodes, column sep=0.6cm, row sep=0.5cm]{
A_1 & & & & B_2\\
& A(A_1\cap B_1) & & B(A_1\cap B_1) \\
& A(A_1\cap B) & A_1\cap B_1 & B(A\cap B_1) \\
A & & D & & B\\
& A\cap B_1 & & A_1 \cap B \\
& & A\cap B \\};

\foreach \i/\j in {1-1/2-2, 1-5/2-4,  2-2/3-3, 2-4/3-3,%
3-2/4-1, 3-2/4-3, 3-3/4-3, 3-4/4-3, 3-4/4-5,%
4-1/5-2, 4-3/5-2, 4-3/5-4, 4-5/5-4, 5-2/6-3,5-4/6-3}
\draw (a-\i) -- (a-\j);

\draw[double,densely dotted] (a-2-2)--(a-3-2) (a-2-4)--(a-3-4);
\end{tikzpicture}
\end{document}


-