# Problem plotting hasse diagram with xypic

I need to plot the following hasse diagrams: 1)

2)

I tried using xypic. For the first I worte the following code

\xymatrix{
&{G}\ar@{-}[dr]\ar@{-}[dl] \\
{\mathbb{Z}_p}\ar@{-}[dr] & & \mathbb{Z}_q}\ar@{-}[dl]}\\
{{e}} \\
}


but it displays nothing. About second one, I don't really know from where to start. I can write also this wrong code:

\xymatrix{
& {HK}\ar@{-}[dr]\ar@{=}[dl]\\
H@\ar{=}[dr] & K@\ar{-}[dl]\\
{H\cap K}
}


How can I plot them both? Where is my mistake?

-
I'd suggest you tikz-cd. – Gonzalo Medina Aug 26 '13 at 15:52
I asked one of my proffesors and that's what he suggested. I don't know tikz-cd. – Danis Fischer Aug 26 '13 at 15:53
Please see my answer below for an example of the necessary code using tikz-cd. tikz-cd has an advantage in that it allows you to use the power of TikZ. (You can respectfully tell you teacher about this package also :-)). – Gonzalo Medina Aug 26 '13 at 15:59
What about you other posting about Hasse diagrams and the solution proposed there? – Christoph Aug 26 '13 at 18:22
there I wanted to get basic intution in which tool to use. then I got answer from my prof. It failed so I opened new thread. Thanks. – Danis Fischer Aug 26 '13 at 18:49

If you're not bound to use xy, I'd suugest you to use the powerful and more modern tikz-cd package instead:

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

\begin{document}

\begin{tikzcd}[column sep=0.3cm]
{} & G\arrow[dash]{dr}\arrow[dash]{dl}
& \\
\mathbb{Z}_p\arrow[dash]{dr} & & \mathbb{Z}_q\arrow[dash]{dl} \\
& \lbrace e\rbrace
\end{tikzcd}

\begin{tikzcd}[column sep=0.3cm]
{} & HK\arrow[equal]{dr}\arrow[dash]{dl}
& \\
H\arrow[equal]{dr} & & K\arrow[dash]{dl} \\
& H\cap K
\end{tikzcd}

\end{document}


-
when I put the first in math-field in lyx it seems as a code and not as a diagram... – Danis Fischer Aug 26 '13 at 16:08
@CoarguAliquis you need to load the package, and then to introduce the diagrams using my code as LaTeX code. I am not familiar with LyX, but it must be pretty much the same you were doing with your xy diagrams. – Gonzalo Medina Aug 26 '13 at 16:12

This works with xy:

\documentclass{article}
\usepackage{amssymb}
\usepackage[all,cmtip]{xy}
\begin{document}
$\xymatrix{ & G \ar@{-}[dr] \ar@{-}[dl] \\ \mathbb{Z}_p \ar@{-}[dr] & & \mathbb{Z}_q \ar@{-}[dl] \\ & \{e\} } \qquad \xymatrix{ & HK \ar@{=}[dr] \ar@{-}[dl]\\ H \ar@{=}[dr] & & K \ar@{-}[dl]\\ & H\cap K }$
\end{document}


-
not in lyx. I added to latex-prwmble usepackage{xypic}, added in formula these sketches but nothing seems to happen except long code. – Danis Fischer Aug 26 '13 at 16:15
@CoarguAliquis Sorry, but LyX is something I can't think to. My opinion is that it makes more difficult, rather than simpler, inputting LaTeX code. – egreg Aug 26 '13 at 16:16
Reseted lyx and now works like a charm. Thanks :) – Danis Fischer Aug 26 '13 at 16:21
When you get a useful answer to a question you should accept it, and vote it up. You can even vote up more than one answer. Please go back to your other questions and take care of this there too. – Ethan Bolker Aug 26 '13 at 17:08