-1

How do they draw this in Latex ?

enter image description here

marked as duplicate by Henri Menke tikz-pgf Mar 2 at 22:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Search here for trees. – Sigur Mar 2 at 17:13
  • 2
    Package tikz-cd should do it very simply. – Bernard Mar 2 at 17:19
  • 3
    Although you already have an answer, your question is still a just-do-it-for-me question, and we overall dislike those questions. Next time make sure that you will add an MWE showing what you've tried. We prefer fixing to creating. – user156344 Mar 2 at 17:24
  • 2
    @JouleV I don't know this. But the user was removed? – Sebastiano Mar 2 at 17:30
  • 1
    @Sebastiano Well, I don't know why but I'm now a bit uncomfortable when reading just-do-it-for-me questions. Maybe I'm becoming allergic to such questions after a series of 7 questions I saw yesterday. – user156344 Mar 2 at 17:36
5

With tikz-cd:

enter image description here

\documentclass[10pt]{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[row sep= .7cm, column sep=.5cm]
& 1 \arrow[ld, no head] &\\
2 \arrow[rd, no head] && 4 \arrow[lu, no head] \\
& 3 \arrow[ru, no head] &                      
\end{tikzcd}
\end{document}
5

Loops can help avoid repetition and polar coordinates help to make things more symmetric.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \X in {1,...,4} {\node (\X) at (\X*90:1) {\X};} 
\foreach \X [remember=\X as \LastX (initially 4)] in {1,...,4} 
{\draw (\LastX) -- (\X);} 
\end{tikzpicture}
\end{document}

enter image description here

5

Pure tikz?

\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}
\node (1) {1}; 
\node (2) [below left=of 1] {2};
\node (3) [below right=of 2] {3};
\node (4) [below right=of 1] {4};
\draw (1)--(2) (1)--(4) (2)--(3) (3)--(4);
\end{tikzpicture}

\end{document}

A shorter version with a \foreach loop: [PS: similar to @marmot's answer below]

\begin{tikzpicture}
\foreach \i in {1,...,4}
    \node (\i) at (90*\i:1cm) {\i};
\draw (1)--(2) (1)--(4) (2)--(3) (3)--(4);
\end{tikzpicture}

enter image description here

5

A short code with pstricks and multido:

\documentclass{article}

\usepackage{pst-node, multido}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{psmatrix}[rowsep=1cm, colsep=1.25cm]
 & 1 \\ 2 & & 4 \\ & 3
\end{psmatrix}
\multido{\ir=1+2}{2}{\multido{\ic=1+2}{2}{\ncline[nodesep=4pt, linewidth=0.5pt]{\ir,2}{2,\ic}}}

\end{document} 

enter image description here