3

I'm reasonably new to using xy-pics, and I'm trying to figure out how to connect bullets together. The lines I draw are only 'half connected'. This is my code:

\documentclass{article}
\usepackage[all]{xy}  
\begin{document}
\xymatrix{
    {\bullet} \ar@{-}[r]*{} & {\bullet} \ar@{-}[r]*{} \ar@/^2pc/[rr] & {\bullet} & *+[o][F]{+} \ar@{-}[l]
    }
\end{document}

Result

I want the lines to join up. As you can see, I've managed to half connect them by using *{} at the end of the lines, but no matter where else I place that, it doesn't allow me to connect the other side.

I tried to just adding in lines in the other direction, but obviously this isn't practical, especially when wanting to add in arrows like I've done. (NB: I would like the tail of the arrow and the head of the arrow to touch the nodes)

So what is the best way to do this? I'm sure there's something incredibly simple I'm missing, but I can't figure out what!

  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Stefan Pinnow Feb 18 at 10:53
  • I would do it in TikZ. – user156344 Feb 18 at 11:09
  • For the horizontal, you can make it pass over, so start it in 1st cell and goes [rrr] directly. – Sigur Feb 18 at 11:43
  • Apologises for not including the pre-amble in the code; didn't realise that was the required! @JouleV - I've tried using TikZ in the past, and could never get my head round it. Whereas xy-pic has felt more natural to me and caused little problem (except this one!) – LukeCham91 Feb 19 at 8:57
  • @LukeCham91 Yes, I have read the documentation of xy and it is very good. However, when drawing graphics, I prefer TikZ -- and the code TikZ here is very simple: \fill[black] (0,0) circle (2pt) -- (2,0) circle (2pt) -- (4,0) circle (2pt); \node[circle,draw] (nd) at (6,0) {$+$}; \draw (0,0)--(2,0)--(4,0)--(nd); \draw[->] (2,0) to[out=60,in=130] (nd);. – user156344 Feb 19 at 9:16
1

The *object form allows you control spacing and other conventions for the entry. In your case, you can simply prefex each bullet with *=:

\documentclass{article}
\usepackage[all]{xy}  
\begin{document}
\xymatrix{
    *=0{\bullet} \ar@{-}[r]*{} & *=0{\bullet} \ar@{-}[r]*{} \ar@/^2pc/[rr] & *=0{\bullet} & *+[o][F]{+} \ar@{-}[l]
    }
\end{document}

Spacing for the entire diagram can also be set adding a string between xymatrix and the first { -- see the user's guide.

output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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