4

I have a cluster with which the objects are simply bullets. I would like to group some of the bullets such as the following.

enter image description here

Somehow the edges of the box are exactly on the bullets. Here is my code

   \[
     \xymatrix@C=1cm@R=1cm{
       *={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]\ar@{-}[d]&*={\bullet}
       \save "1,1"."2,3"*[F.]\frm{}\\
       *={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]&*={\bullet}
     \restore}%
   \]

which resulting the following image.

enter image description here

I just need to insert paddings within the box. Or if anybody know another way to draw this with xymatrix would also be great.

Thank you in advance.

2 Answers2

2

Using tikz....

enter image description here

\documentclass{article}



\usepackage{tikz}


\begin{document}
\begin{tikzpicture}
\foreach \y in {0,2}
 {
  \foreach \x in {0,2,4,6}  \fill (\x,\y) circle(1mm);
  \draw[very thick] (0,\y)--(6,\y);
}
\draw[very thick](4,0)--(4,2);
\draw[densely dotted, very thick] (-0.2,-0.2) rectangle (4.2,2.2);
\end{tikzpicture}
\end{document}
JPi
  • 13,595
2

You can use

\save "1,1"."2,3"*+<1pc>!<.5pc,-.5pc>\frm{.}

which having saved the positions increases the size of the rectangle by 1pc in the bottom and right directions and then moves it .5pc vertically and horizontally to be centered on the original material. You do not need the extra [F.] command, the \frm{.} is sufficient.

Sample output

\documentclass{article}

\usepackage[all]{xy}

\begin{document}
\[
  \xymatrix@C=1cm@R=1cm@M=1pc{
  *={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]\ar@{-}[d]
  &*={\bullet}
  \save "1,1"."2,3"*+<1pc>!<.5pc,-.5pc>\frm{.}\\
  *={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]&*={\bullet}\ar@{-}[r]
  &*={\bullet}
  \restore}%
\]

\end{document}
Andrew Swann
  • 95,762