-1

How do they draw this in Latex ?

enter image description here

  • 2
    Search here for trees. – Sigur Mar 02 '19 at 17:13
  • 2
    Package tikz-cd should do it very simply. – Bernard Mar 02 '19 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. –  Mar 02 '19 at 17:24
  • 2
    @JouleV I don't know this. But the user was removed? – Sebastiano Mar 02 '19 at 17:30
  • @Sebastiano I think he deleled his account after seeing my comment. Is my comment attacking him? –  Mar 02 '19 at 17:31
  • @JouleV My simple answer is: no! – Sebastiano Mar 02 '19 at 17:33
  • 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. –  Mar 02 '19 at 17:36
  • 1
    @JouleV Look down. Four answers. You might have missed something, this community is right now quite comfortable with Just-do-it-for-me. An answer makes someone happy in providing them with an answes ... and it gives some free (real-world) worthless reputation. – Johannes_B Mar 02 '19 at 18:48
  • @Johannes_B Indeed, and that is what we have in this meta question. Well, I do have free-time but I am not a reputation seeker. –  Mar 02 '19 at 18:56
  • @JouleV Just opted for https://tex.meta.stackexchange.com/questions/8116/reasons-for-closing-questions-too-little-effort – Johannes_B Mar 02 '19 at 18:58
  • 1
    @JouleV When I joined more than two years ago, however, for my first question, I didn't even know where to start. Yet they helped me. I understand your frustration but from my point of view if it is the first time that a user who asks a question Just-do-it-for-me in my opinion there is nothing wrong. If then the same user persists in the Just-do-it-for-me questions then the speech changes totally. I think you should be patient and not angry. – Sebastiano Mar 02 '19 at 20:21
  • 1
    @Sebastiano Oh yes, I am not angry, I am just a bit uncomfortable. I have my own rule! If user182626 has been here for a while, I will vote to close the question, but because he is a new user, I don't do it. And I am sad that this question got closed. Because he is new here, I just suggest him to add an MWE to his next questions. –  Mar 03 '19 at 04:10

4 Answers4

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

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
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}
Sebastiano
  • 54,118
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

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

Bernard
  • 271,350