Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In advance of a summer class I'm teaching, I decided to try compiling my notes, which I haven't touched in any way, shape or fashion for 4-5 months. However, in that interval, I've updated laTeX packages as new updates have come online (using MikTeX 2.9). I have a large number of lectures containing tikzpictures, of the following general form (all of which used to compile perfectly):

  \documentclass{article}

   \usepackage{tikz}
      \usetikzlibrary{snakes,shapes,arrows,matrix,positioning}

      \begin{document}

  \begin{figure}[h]
  \centering
  \rule[-1.25cm]{0pt}{3.25cm}
    \begin{tikzpicture}[>=stealth,->,shorten >=1.5pt,line width=0.75pt]
   \matrix (a) [matrix of nodes,row sep=0.5em, column sep=3em]
   { \node[circle,draw,font=\small,minimum width=1cm] {\sffamily{1}};  &   \node[circle,draw,font=\small,minimum width=1cm]{\sffamily{2}}; &  \node[circle,draw,font=\small,minimum width=1cm]    {\sffamily{3}}; \\};
 \path[>=stealth,font=\small] (a-1-1) edge node[below] {$S_o$} (a-1-2);
 \path[>=stealth,font=\small] (a-1-2) edge node[below] {$S_1$} (a-1-3);
 \path[>=stealth,->,font=\small] (a-1-2) edge [bend right=50] node [above,near start] {$S_1F_2$} (a-1-1) ;
 \path[>=stealth,->,font=\small] (a-1-3) edge [bend right=55] node [above,near start] {$S_2F_3$} (a-1-1) ;
    \end{tikzpicture}
  \end{figure}

\end{document}

When I try to compile the preceding MWE, I get all sorts of error messages about 'no shape named a-1-1 is know...' etc. etc.

Which I find odd, because clearly, when it compiled perfectly before, said shape was known. I gather something has changed.

Any insights/pointers to the obvious most appreciated.

share|improve this question
1  
Same problem as tex.stackexchange.com/questions/163319/… I think? –  Torbjørn T. Mar 31 at 15:15
1  
Change the matrix code to \matrix (a) [matrix of nodes,row sep=0.5em, column sep=3em, every node/.style={circle,draw,font=\small\sffamily,minimum width=1cm}] { 1 & 2 & 3 \\}; and it works fine. –  Torbjørn T. Mar 31 at 15:18

1 Answer 1

Things have changed with tikz v3.

  \documentclass{article}

   \usepackage{tikz}
      \usetikzlibrary{snakes,shapes,arrows,matrix,positioning}
   \tikzset{mynode/.style={circle,draw,font=\small,minimum width=1cm,font=\sffamily}
   }
      \begin{document}

  \begin{figure}[h]
  \centering
  \rule[-1.25cm]{0pt}{3.25cm}
    \begin{tikzpicture}[>=stealth,->,shorten >=1.5pt,line width=0.75pt]
   \matrix (a) [matrix of nodes,row sep=0.5em, column sep=3em]
    {|[mynode]|1  &   |[mynode]|2 &  |[mynode]|3 \\};
 \path[>=stealth,font=\small] (a-1-1) edge node[below] {$S_o$} (a-1-2);
 \path[>=stealth,font=\small] (a-1-2) edge node[below] {$S_1$} (a-1-3);
 \path[>=stealth,->,font=\small] (a-1-2) edge [bend right=50] node [above,near start] {$S_1F_2$} (a-1-1) ;
 \path[>=stealth,->,font=\small] (a-1-3) edge [bend right=55] node [above,near start] {$S_2F_3$} (a-1-1) ;
    \end{tikzpicture}
  \end{figure}

\end{document}

enter image description here

BTW \sffamily{1} is wrong as \sffamily is a switch. Use font=\sffamily as the option to the node instead..

Edit:

You can customize each node by putting the attributes in a \tikzset. This way you have more control over the individual nodes.

  \documentclass{article}

   \usepackage{tikz}
      \usetikzlibrary{snakes,shapes,arrows,matrix,positioning}
   \tikzset{mynode/.style={circle,draw,font=\small,minimum width=1cm,font=\sffamily},
            every node/.style={minimum width=1cm},
            firstnode/.style={ellipse,draw,font=\small\sffamily,fill=red!10}, 
            secondnode/.style={ellipse,draw,font=\small\sffamily,fill=green!10},
            thirdnode/.style={ellipse,draw,font=\small\sffamily,fill=brown!10},
            fourthnode/.style={ellipse,draw,font=\small\sffamily,fill=black!10}
   }
      \begin{document}

  \begin{figure}[h]
  \centering
  \rule[-1.25cm]{0pt}{3.25cm}
    \begin{tikzpicture}[>=stealth,->,shorten >=1.5pt,line width=0.75pt]
   \matrix (a) [matrix of nodes,row sep=0.5em, column sep=3em]
    {|[firstnode]|1  &   |[secondnode]|2 &  |[thirdnode]|3 \\};
 \path[>=stealth,font=\small] (a-1-1) edge node[below] {$S_o$} (a-1-2);
 \path[>=stealth,font=\small] (a-1-2) edge node[below] {$S_1$} (a-1-3);
 \path[>=stealth,->,font=\small] (a-1-2) edge [bend right=50] node [above,near start] {$S_1F_2$} (a-1-1) ;
 \path[>=stealth,->,font=\small] (a-1-3) edge [bend right=55] node [above,near start] {$S_2F_3$} (a-1-1) ;
    \end{tikzpicture}
  \end{figure}

\end{document}

enter image description here

This way the styles will be usable across tikzpictures.

share|improve this answer
    
What exactly is the relevant change that prevented the original code from working? I see some differences between your code and the code in the question but I can't tell what the fix is. –  David Z Mar 31 at 19:17
    
And, I'm afraid I don't se the major difference either. Moreover, it isn't obvious to me how you then change shape or colour of individual nodes. Part of the reason I use(d) the structure I presented in the OP was because it is easy, verging on trivial, to change individual node attributes. I'm not sure how one dos this with 'new and improved' tikz. –  user67322 Mar 31 at 19:26
    
Well, after much fooling around, I discovered the 'new and improved' way of handling tweaks to individual nodes. There may be better approaches, but the following works for me -- something like: \matrix (a) [matrix of nodes,row sep=2em, column sep=3em, every node/.style={minimum width=1cm}, first.node/.style={ellipse,draw,font=\small\sffamily,fill=red!10}, second.node/.style={ellipse,draw,font=\small\sffamily,fill=green!10}, third.node/.style={ellipse,draw,font=\small\sffamily,fill=brown!10}, fourth.node/.style={ellipse,draw,font=\small\sffamily,fill=black!10}] –  user67322 Mar 31 at 20:15
    
@user67322 Answer updated. –  Harish Kumar Mar 31 at 23:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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