2

I need to draw following hypergraph in Latex.
enter image description here

My attempt-

\documentclass{article}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{pstricks-add}
\usepackage{epsfig}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\usepackage[space]{grffile} % For spaces in paths
\usepackage{etoolbox} % For spaces in paths
\makeatletter % For spaces in paths
\patchcmd\Gread@eps{\@inputcheck#1 }{\@inputcheck"#1"\relax}{}{}
\makeatother 

\begin{figure}[t]

\begin{center}

\psscalebox{0.5 0.5} % Change this value to rescale the drawing.
{
\begin{pspicture}(0,-5.677559)(12.57659,2.6669903)
\psrotate(2.7260337, 0.3329967){-38.651867}{\psellipse[linecolor=black, linewidth=0.04, dimen=outer](2.7260337,0.33299673)(3.3083334,1.3883333)}
\psrotate(1.1277003, 1.5757744){7.4958577}{\psdots[linecolor=black, dotsize=0.8378179](1.1277003,1.5757744)}
\psdots[linecolor=black, dotsize=0.8](2.585478,0.40244114)
\psdots[linecolor=black, dotsize=0.8](4.1499224,-0.8420033)
\psellipse[linecolor=black, linewidth=0.04, dimen=outer](6.994367,-0.80867)(3.6977777,1.2588888)
\psdots[linecolor=black, dotsize=0.8](6.8521447,-0.7708922)
\psdots[linecolor=black, dotsize=0.8](9.056589,-0.69978106)
\psellipse[linecolor=black, linewidth=0.04, dimen=outer](6.9232564,-2.6731143)(1.2444445,3.0044444)
\psdots[linecolor=black, dotsize=0.8](6.745478,-2.619781)
\psdots[linecolor=black, dotsize=0.8](6.7810335,-4.1131144)
\psellipse[linecolor=black, linewidth=0.04, dimen=outer](9.234367,-4.2197814)(3.3422222,1.0311111)
\psdots[linecolor=black, dotsize=0.8](9.234367,-4.219781)
\psdots[linecolor=black, dotsize=0.8](11.225478,-4.219781)
\end{pspicture}
}
\end{center}
\label{dot}
\end{figure}


however it does not give any result. If possible can anyone explain or give a sample code? I am ok with tikz too.

1
  • I obtain a result compiling with xelatex but the upper-leftmost dot is not where it should be.
    – Bernard
    Dec 18, 2021 at 9:20

2 Answers 2

3

Welcome to TeX.SE!!!

This can be easily done in TikZ defining a \pic for the ellipse with the three dots. We can add a parameter which shifts the \pic to one dot or another, and then the positioning is very simple.

Something like this:

\documentclass[tikz,border=2mm]{standalone}

\tikzset
{%
  pics/my ellipse/.style={% #1 --> shift to node (1,2,3)
      code={%
          \begin{scope}[shift={(1.5*#1-3,0)}]
            \draw (0,0) ellipse (2.5cm and 0.75cm);
            \foreach\i in {1,2,3}
              \fill (1.5*\i-3,0) circle  (0.5) node (-\i) {};
            \end{scope}
    }},
  pics/my ellipse/.default={2},
}

\begin{document}
\begin{tikzpicture}
\pic             (A) at (0,0) {my ellipse};
\pic[rotate= 90] (B) at (A-2) {my ellipse=1};
\pic             (C) at (B-1) {my ellipse=3};
\pic[rotate=300] (D) at (A-1) {my ellipse=1};
\end{tikzpicture}
\end{document}

enter image description here

1
  • Fabulous also this LOL :-)
    – Sebastiano
    Dec 21, 2021 at 8:10
2

run with lualatex to get directly the pdf:

\documentclass{article}
\usepackage[usenames,dvipsnames]{pstricks}

\def\EllipseAndDots(#1)#2{%
  \rput{#2}(#1){\psellipse(0,0)(2.75,1)\psdots[dotsize=0.8](-1.5,0)(0,0)(1.5,0)}}

\begin{document}

\begin{pspicture}[showgrid=false](2,-5)(11.5,2.5)
\EllipseAndDots(7,-0.75){0}%
\EllipseAndDots(7,-2.25){90}%
\EllipseAndDots(8.5,-3.75){0}%
\EllipseAndDots(4.44,0.31){135}%
\end{pspicture}

\end{document}

or with easier coordinates:

\begin{pspicture}[showgrid=true](-5,-5)(5,3)
\EllipseAndDots(0,0){0}%
\EllipseAndDots(0,-1.5){90}%
\EllipseAndDots(1.5,-3){0}%
\EllipseAndDots(-2.56,1.06){135}%
\end{pspicture}

1.06 = 0.75*sqrt(2) (cosinus)

enter image description here

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.