Why this tikzpicture does not appear centered?

While creating a state machine diagram with tikz I noticed that it appears to be off center. This result seems counter intuitive to me because of the way the diagram was created, using a foreach construct with all nodes having the same radius and varying angles. I also placed a single node at the coordinate (0,0), but it appears not to be centered. I provide below a working example showing the issue. I am sure there must be a logical explanation that I am missing somehow, and perhaps someone here will be able to explain what's going on

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,automata,positioning,calc}

\begin{document}

Indented text

\noindent Unindented text

\begin{figure}[h]
\centering
\begin{tikzpicture}[-Stealth,shorten >=1pt,semithick]
\tikzstyle{every state}=[fill=blue!20,draw=blue!50,very thick,text=black,minimum size=1cm]
\def \n {8}
\node[state] (c) at (0,0) {};
\foreach \s/\stext in {1/1,2/2\_1,3/3,4/4,5/5,6/6,7/7,8/8}
{
\node[state] (\s) at ({-360/\n * (\s - 1)+90}:\radius) {\stext};
}
\end{tikzpicture}
\end{figure}

\end{document}


• If I compile your code, I recieve the following warning: Overfull \hbox (26.08575pt too wide) which means that yor image is wider than the textwidth and therefor appears to not be centered with respect to the margins. To make the image smaller you could add the scale=0.9 option to \begin{tikzpicture}. – leandriis Mar 19 at 21:21
• \tikzstyle is deprecated, please use \tikzset{every state/.append style={fill=blue!20,draw=blue!50,very thick,text=black,minimum size=1cm}} instead. – marmot Mar 19 at 21:59
If I compile your code, I recieve the following warning: Overfull \hbox (26.08575pt too wide) which means that yor image is wider than the textwidth and therefor appears to not be centered with respect to the margins. To make the image smaller you could add the scale=0.9 option to \begin{tikzpicture}.
You should also replace the \tikzstyle command by \tikzset{every state/.append style={fill=blue!20,draw=blue!50,very thick,text=black,minimum size=1cm}} as the former is deprecated.