1

I am drawing a large Markov chain with different state names; some states include numbers such as (0,2) and some are named as (S-1,R-1). I am trying to find a way to have one font size for all states. The states with S and R are larger than the others. Is there a way to have one state size and one font size? My code without the transitions are as follows

\documentclass{document}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{chains,shapes.multipart}
\usetikzlibrary{shapes}
\usetikzlibrary{automata,}
\setlength{\jot}{7pt}
\usepackage{multirow}
\usepackage{latexsym}
\usepackage[utf8]{inputenc}
%\usepackage[dvipsnames]{xcolor}
\definecolor {processblue}{cmyk}{0,0,0,0.17}
\definecolor{light-gray}{gray}{0.85}
\newcommand*{\grayemph}[1]{%
  \tikz[baseline=(X.base)] \node[rectangle, fill=light-gray, rounded corners, inner sep=1.8mm] (X) {#1};%
}
\begin{document}
\begin{figure*}[t]
\centering
\begin{tikzpicture}
  \tikzset{
    >=stealth',
    node distance=1.5cm and 1.7cm ,on grid,
    every text node part/.style={align=center}
    state/.style={minimum size=30pt,font=\small,circle,draw},
    dots/.style={state,draw=none},
    edge/.style={->},
    trans/.style={font=\footnotesize,above=2mm},
    reflexive/.style={out=120,in=60,looseness=5,relative},
  }

\node[state] (C){$0,0$};
\node[state]       (v1)  [right =of C]   {$1,0$};
\node[state]       (v2)  [right =of v1]   {$2,0$};
\node[state]       (v3)  [right =of v2]   {$\cdots$};
\node[state]       (v4)  [right =of v3]   {\begin{scriptsize}S-1, {0}\end{scriptsize}};
\node[state]       (v5)  [right =of v4]   {$S,0$};

\node[state]       (v6)  [above =of C]   {$1,0$};
\node[state]       (v7)  [right =of v6]   {$1,1$};
\node[state]       (v8)  [right =of v7]   {$2,1$};
\node[state]       (v9)  [right =of v8]   {$\cdots$};
\node[state]       (v10)  [right =of v9]   {\begin{scriptsize}S-1, {0}\end{scriptsize}};;
\node[state]       (v11)  [right =of v10]   {$S,1$};
\node[state]       (v12)  [right =of v11]   {\begin{scriptsize}S+1, {0}\end{scriptsize}};; 

\node[state]       (v13)  [above =of v6]   {$\vdots$};
\node[state]       (v14)  [above =of v7]   {$\vdots$};
\node[state]       (v15)  [above =of v8]   {$\vdots$};
\node[state]       (v16)  [above =of v9]   {$\vdots$};
\node[state]       (v17)  [above =of v10]   {$\vdots$};
\node[state]       (v18)  [above =of v11]   {$\vdots$};
\node[state]       (v19)  [right =of v18]   {$\ddots$};

\node[state]       (v20)  [above =of v13]   {\begin{scriptsize}0,R-1\end{scriptsize}};
\node[state]       (v21)  [right =of v20]   {\begin{scriptsize}1,R-1\end{scriptsize}};
\node[state]       (v22)  [right =of v21]   {\begin{scriptsize}2,R-1\end{scriptsize}};
\node[state]       (v23)  [right =of v22]   {$\cdots$};
\node[state]       (v24)  [right =of v23]   {\begin{scriptsize}S-1, {R-1}\end{scriptsize}};;
\node[state]       (v25)  [right =of v24]   {\begin{scriptsize}S, {R-1}\end{scriptsize}};
\node[state]       (v26)  [right =of v25]   {\begin{scriptsize}S+1, {R-1}\end{scriptsize}};
\node[state]       (v27)  [right =of v26]   {$\cdots$};
\node[state]       (v28)  [right =of v27]  {\begin{scriptsize}S+R-1,R-1\end{scriptsize}};
\end{tikzpicture}
\caption{The Markov chain mode;.}

\end{figure*}
\end{document}
  • Can you add the rest of the document viz, the preamble? What is your version of tikz? What tikzlibraries are you using? The MWE does not compile in my machine (texlive2015). is there a comma after every text node part/.style={align=center}? – AJN Mar 20 '16 at 14:55
  • Just added the preamble packages. This is my first test with the Tikz, so the problem could be a silly one. – user1094480 Mar 21 '16 at 16:08
0

Some of the text was in scriptsize and others (the ones enclosed in $...$) were not. This caused the difference in font size. The nodes minimum size specification has to be larger than the node with longest text in order for all nodes to be of the same size (in this code the top right node has the longest text). So I changed the minimum size specification also.

Again, as I said earlier in the comment to the question, the missing comma seems to have suppressed the state/.style specification. So I have added a comma there. Only then does Tikz seem to read that value.

markov nodes

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{chains,shapes.multipart}
\usetikzlibrary{shapes}
\usetikzlibrary{automata}
\begin{document}
\begin{tikzpicture}
  \tikzset{
    >=stealth',
    node distance=2.5cm and 2.5cm ,on grid,
    every text node part/.style={align=center},
    state/.style={minimum width=2cm,
                  font=\small,
                  draw,
                  circle},
  }

\node[state] (C){$0,0$};
\node[state]       (v1)  [right =of C]   {$1,0$};
\node[state]       (v2)  [right =of v1]   {$2,0$};
\node[state]       (v3)  [right =of v2]   {$\cdots$};
\node[state]       (v4)  [right =of v3]   {\begin{scriptsize}S-1, {0}\end{scriptsize}};
\node[state]       (v5)  [right =of v4]  
        {\begin{scriptsize}S,0\end{scriptsize}};

\node[state]       (v6)  [above =of C]   {$1,0$};
\node[state]       (v7)  [right =of v6]   {$1,1$};
\node[state]       (v8)  [right =of v7]   {$2,1$};
\node[state]       (v9)  [right =of v8]   {$\cdots$};
\node[state]       (v10)  [right =of v9]   {\begin{scriptsize}S-1, {0}\end{scriptsize}};;
\node[state]       (v11)  [right =of v10]   {\begin{scriptsize}S,1\end{scriptsize}};
\node[state]       (v12)  [right =of v11]   {\begin{scriptsize}S+1, {0}\end{scriptsize}};; 

\node[state]       (v13)  [above =of v6]   {$\vdots$};
\node[state]       (v14)  [above =of v7]   {$\vdots$};
\node[state]       (v15)  [above =of v8]   {$\vdots$};
\node[state]       (v16)  [above =of v9]   {$\vdots$};
\node[state]       (v17)  [above =of v10]   {$\vdots$};
\node[state]       (v18)  [above =of v11]   {$\vdots$};
\node[state]       (v19)  [right =of v18]   {$\ddots$};

\node[state]       (v20)  [above =of v13]   {\begin{scriptsize}0,R-1\end{scriptsize}};
\node[state]       (v21)  [right =of v20]   {\begin{scriptsize}1,R-1\end{scriptsize}};
\node[state]       (v22)  [right =of v21]   {\begin{scriptsize}2,R-1\end{scriptsize}};
\node[state]       (v23)  [right =of v22]   {$\cdots$};
\node[state]       (v24)  [right =of v23]   {\begin{scriptsize}S-1, {R-1}\end{scriptsize}};;
\node[state]       (v25)  [right =of v24]   {\begin{scriptsize}S, {R-1}\end{scriptsize}};
\node[state]       (v26)  [right =of v25]   {\begin{scriptsize}S+1, {R-1}\end{scriptsize}};
\node[state]       (v27)  [right =of v26]   {$\cdots$};
\node[state]       (v28)  [right =of v27]  {\begin{scriptsize}S+R-1,R-1\end{scriptsize}};
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.