1

So I have states and nodes drawn in my tikz project. Now I want my node's text look smaller and go INSIDE the middle of node. Also how to change text and node color?

My code for nodes:

   \documentclass{article}

     \usepackage{verbatim}
        \usepackage{pgf}
        \usepackage{tikz}
        \usetikzlibrary{arrows,automata}
        \usepackage{iftex}
        \ifPDFTeX
           \usepackage[utf8]{inputenc}
           \usepackage[T1]{fontenc}
           \usepackage{lmodern}
        \else
           \ifXeTeX
             \usepackage{xltxtra}
           \else 
             \usepackage{luatextra}
           \fi
           \defaultfontfeatures{Ligatures=TeX}
        \fi
        \usetikzlibrary{positioning}
        \tikzset{
        state/.style={
               rectangle,
               rectangle split,
                rectangle split parts=2,
                 rectangle split part fill={red!30,blue!20},
               rounded corners,
               draw=black, very thick,
               minimum height=4em,
               inner sep=3pt,
               text width=3cm,
               text centered,
               },
    }
    \begin{document}
    \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm,
                        semithick]

      \node[state] (A) {};
      \node[state]        (B) [below right of=A]{};
      \node[state]         (C) [right of=B] {};
    ....

         \path       (A) edge                node {}(D)
                     (B) edge                node {OK} (E)
                         edge    [bend right]node {Error} (F)
                     (C) edge               node {OK} (E)
                         edge               node {} (F)
                     (D) edge  [bend right] node {Error} (F)
                         edge              node {OK} (E)
                     (E) edge              node {} (B)
                         edge   [bend left]node {>}(C)
                         edge              node{}(G)
                     (F) edge  [loop above]node{Error}(F)
                         edge              node{OK}(E)
                    (G) edge  [bend right] node{Error}(F);
        \end{tikzpicture}

Thanks in advance.

  • Could you write a Minimal but complete example? From \documentclass to \end{document}. You code is not compilable in this way. – Ignasi Mar 30 '16 at 9:21
  • @Ignasi added more code :) – Mantas Mar 30 '16 at 9:24
  • Thank you by your effort, but your code is still not compilable. Did you try it? At least \end{document} is missing just like nodes D, E, F, G. – Ignasi Mar 30 '16 at 9:27
  • Node's text color changes with option text=red, text size is fixed with option font=\small, node's fill color with fill=blue. – Ignasi Mar 30 '16 at 9:31
  • @Ignasi how to write it correctly into my code? – Mantas Mar 30 '16 at 9:35

Your Answer

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

Browse other questions tagged or ask your own question.