# Want to make the following shape function in TikZ? [closed]

Want to make the following shapes function in TikZ

\begin{tikzpicture}
\tikzstyle{every node}=[draw,shape=circle];
\draw (0,0)  --   (0,1)  node {1};
\draw (0,1)  --   (1,1)  node {2};
\draw (1,1)  --   (1,0)  node {3};
\draw (1,0) --    (0,0)  node {4};
\end{tikzpicture}
\begin{tikzpicture}
\tikzstyle{every node}=[draw,shape=circle];
\draw (0,0)  -- ++  (1,1)  node {1};
\draw (1,1)  -- ++  (1,-1) node {2};
\draw (0,0)  --  ++ (2,0)  node {3};
\end{tikzpicture}

-

## closed as too broad by Christian Hupfer, Masroor, Werner, Martin Schröder, JubobsJun 21 '14 at 14:11

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Can you show us what you've tried so far? Have you consulted the numerous TikZ resources recommended to you in your other questions to give you a starting point? – Paul Gessler May 7 '14 at 14:13
I need these figure for my Thesis. I start working on TikZ but complex figure I couldn't make it like last 5 figure – Micky K May 7 '14 at 14:16
Then please, show us your code for the first nine. Or better yet, just ask about a specific issue in one of the final five. When asking graphics questions that are essentially "do this for me" formats, you are at the mercy of the procrastination of our users here. :-) Asking questions about specific problems you're having on one figure often leads to faster and more learning-conducive answers. The question is then much more useful to future visitors to the site as well. – Paul Gessler May 7 '14 at 14:25
Please edit these into the question (using the "edit" button to the left side of the bottom of the post) rather than leaving multiple comments. A tip when editing your post: If you indent lines by 4 spaces or enclose words in backticks , they'll be marked as code. You can also highlight the code and click the "code" button (with "{}" on it). – Paul Gessler May 7 '14 at 14:30
The above two i make for 4 and 7 figure. I am still trying to make it. – Micky K May 7 '14 at 14:45

Try to understand this code and you'll know how to draw all of them.

\coordinate (1) at (0,0,2);


creates a coordinate node (node without dimensions) named 1 at point (x,y,z)=(0,0,2). 2 means 2cm. If you need some particular unit change cm to mm, in, ... Later reference to point (0,0,2) will be done with (1). There is no need to remember its particular coordinates.

Second place circles in every coordinate and add labels to it.

    \fill (1) circle (1pt) node [below] {1};


will draw and fill a circle with radious 1pt (1 point) with center in coordinate 1. Below it a node with text 1 is placed. Because points 1 to 4 has label below and 5 to 8 has it above, it's possible to use a foreach loop.

Last, draw lines between coordinates:

\draw[dashed] (1)--(4)--(3) (4)--(8);


draws a dashed line from coordinate 1 to 4 and 3. Next places the pen on coordinate 4 and draws another line to coordinate 8.

You can use nodes (coordinates are nodes) to position other nodes. JLDiaz explained in his comments how to use calc syntax (needs \usetikzlibrary{calc} in preamble) to do it:

\coordinate (17) at ($(1)!.5!(5)$);


defines a new coordinate 17 on "the point in the line (1)-(5) which is at 50% of the distance from (1)" (the !.5! means that 50%). One you have coordinate 17 defined you can apply again \fill (17) circle (1pt) node [left] {17}; to draw the circle and label.

An alternative syntax could be

\path (1) -- (5) coordinate[pos=0.5] (17);


which means move from 1 to 5 and in pos=0.5 from this path place a coordinate node named 17. This syntax doesn't use calc library.

As an exercice: What do you think \coordinate (27) at ($(1)!.5!(7)$); does?

Before the complete code a little suggestion. If you fill intimidated by TiKZ huge documentation, take a look at some of documents recommended in

Now the complete code

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}

\coordinate (1) at (0,0,2);
\coordinate (2) at (2,0,2);
\coordinate (3) at (2,0,0);
\coordinate (4) at (0,0,0);
\coordinate (5) at (0,2,2);
\coordinate (6) at (2,2,2);
\coordinate (7) at (2,2,0);
\coordinate (8) at (0,2,0);

\coordinate (17) at ($(1)!.5!(5)$);
\coordinate (27) at ($(1)!.5!(7)$);

\foreach \i in {1,...,4}
\fill (\i) circle (1pt) node [below] {\i};

\foreach \i in {5,...,8}
\fill (\i) circle (1pt) node [above] {\i};

\fill (17) circle (1pt) node [left] {17};
\fill (27) circle (1pt) node [above] {27};

\draw (1) --(2) --(3) --(7) --(6)--(5)--(8)--(7);
\draw (1)--(5) (2)--(6);
\draw[dashed] (1)--(4) --(3) (4)--(8);

\end{tikzpicture}
\end{document}


-
by using the your code I just make the first and now I am try to make the 2nd figure – Micky K May 7 '14 at 15:02
second done :-) – Micky K May 7 '14 at 15:07
How i make the mid node between 1 and 2, in 4th figure? – Micky K May 7 '14 at 15:35
@SKKhan Interpolated coordinates. You need \usetikzlibrary{calc}, and then you can write \coordinate (5) at ($(1)!.5!(2)$);`, which means "the point in the line (1)-(2) which is at 50% of the distance from (1)" (the !.5! means that 50%). – JLDiaz May 7 '14 at 15:46