TikZ - Remove space around nodes

You can control the space added with the inner sep key:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.8]
\node (1) at (0.4, 2.2) [circle,draw] {1};
\node (4) at (0.4, 0.6) [circle,draw] {4};
\node (3) at (2.6, 0.6) [circle,draw] {3};
\node[inner sep=0pt] (7) at (1.5,1.5) {};
\node (2) at (2.6, 2.2) [circle,draw] {2};

\fill (7) circle (2.5pt);

\draw[-] (1) to (7);
\draw[-] (4) to (7);
\draw[-] (3) to (7);
\draw[-] (2) to (7);

\end{tikzpicture}
\end{document}

enter image description here


You are already using circular node shapes, so why not here? And you can put the filled circle in the middle with barycentric cs: (but since you are naming the ones 1, 2, 3, 4, the syntax is here a bit amusing, which is the main reason why I am posting this ;-). And \foreach can make your life easier.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.8]
\node (1) at (0.4, 2.2) [circle,draw] {1};
\node (4) at (0.4, 0.6) [circle,draw] {4};
\node (3) at (2.6, 0.6) [circle,draw] {3};
\node (2) at (2.6, 2.2) [circle,draw] {2};
\node[inner sep=2.5pt,circle,fill] (7) at (barycentric cs:1=1,2=1,3=1,4=1) {};

\foreach \X in {1,...,4}
{\draw[-] (\X) to (7);}

\end{tikzpicture}
\end{document}

enter image description here


\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.8]
\node (1) at (0.4, 2.2) [circle,draw] {1};
\node (4) at (0.4, 0.6) [circle,draw] {4};
\node (3) at (2.6, 0.6) [circle,draw] {3};
\node (7) at (1.5,1.5) {};
\node (2) at (2.6, 2.2) [circle,draw] {2};

\node[circle, fill=black, draw=black, minimum size=2.5pt] (7) at (1.5, 1.4) {};

\draw[-] (1) to (7);
\draw[-] (4) to (7);
\draw[-] (3) to (7);
\draw[-] (2) to (7);

\end{tikzpicture}
\end{document}

You forgot \begin{document} and you should use a node for the circle as well, where you specify the size and color in the node properties.

Tags:

Tikz Pgf