TikZ Styles that set Nodepart Styles












13














In the following, I'm using user-defined macros to set the type style for the nodeparts for class nodes (texttt{textbf{#1}}), interfaces (texttt{textit{#1}}).



Using the tikzset command I also define styles for classes or interfaces that define how these node parts shoulde be aligned and filled. Is there a correct way to set the typesetyle of the node parts as well?



documentclass{beamer}

usepackage{tikz}
usetikzlibrary{shapes}
usetikzlibrary{arrows}
usetikzlibrary{calc}

usepackage{aeguill}
newcommand*{stereotype}[1]{
guillemotleft {#1}guillemotright%
}

tikzset{class or interface/.style={%
draw,%
shape=rectangle split,%
rectangle split parts=3,%
rectangle split part align={center,left,left},%
rectangle split part fill={#1!30!white,#1!20!white,#1!10!white}},
interface/.style={class or interface=green},
concrete class/.style={class or interface=red}}
newtheorem{exercise}{Exercise}

newcommand*umlClassStyle[1]{texttt{textbf{#1}}}
newcommand*umlAbstractClassStyle[1]{texttt{textit{#1}}}
newcommand*umlInterfaceStyle[1]{texttt{textit{#1}}}

begin{document}

%
%
begin{frame}[fragile]
frametitle{Class Diagram of the Observer Pattern}
begin{tikzpicture}[every text node part/.style={align=center}%
,every two node part/.style={align=center}%
,every three node part/.style={align=left}%
,node distance=2]
path (0,0) node(Subject)[interface,anchor=east]
{nodepart{text}
stereotype{interface}\
umlInterfaceStyle{Subject}
nodepart{two}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.south)
+(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
{nodepart{text}
umlClassStyle{ConcreteSubject}
nodepart{two}
texttt{Observer observers}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.north east)
+(+1.5,+0.0)node(ConcreteObserver)[concrete class,anchor=north west]
{nodepart{text}
umlClassStyle{ConcreteObserver}
nodepart{two}
texttt{Subject subject}
nodepart{three}
texttt{update( Object o )} }
(ConcreteObserver.south |- ConcreteSubject.north)
node(Observer)[interface,anchor=north]
{nodepart{text}
stereotype{interface} \
umlInterfaceStyle{Observer}
nodepart{two}
nodepart{three}
texttt{update( Object o )} };
draw[->,>=open triangle 90,dashed]
(ConcreteSubject) -- (Subject)
node[pos=0.1,anchor=south east] {scriptsize{implements}};
draw[->,>=open triangle 90,dashed]
(ConcreteObserver) -- (Observer)
node[pos=0.1,anchor=north east] {scriptsize{implements}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteSubject.text east) -- (ConcreteSubject.text east -| Observer.west)
node[pos=0.1,anchor=south west] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$n$}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteObserver.text west) -- (ConcreteObserver.text west -| Subject.east)
node[pos=0.1,anchor=south east] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$1$}};
end{tikzpicture}
end{frame}
%
%

end{document}


observer patterns










share|improve this question
























  • I believe your first sentence is supposed to read "I'm using user-defined macros to set the type style for the nodeparts...". You might want to consider boiling down your example to include only the stuff that's necessary to illustrate the problem. As it is, it's quite complicated, and includes a package that's not necessary to demonstrate the issue (aeguill).
    – Jake
    Jan 23 '12 at 5:19










  • @Jake You are right about the first sentence. As to the example, I could make up one but I decided I might as well give some motivation and show why I need it.
    – user10274
    Jan 23 '12 at 5:23
















13














In the following, I'm using user-defined macros to set the type style for the nodeparts for class nodes (texttt{textbf{#1}}), interfaces (texttt{textit{#1}}).



Using the tikzset command I also define styles for classes or interfaces that define how these node parts shoulde be aligned and filled. Is there a correct way to set the typesetyle of the node parts as well?



documentclass{beamer}

usepackage{tikz}
usetikzlibrary{shapes}
usetikzlibrary{arrows}
usetikzlibrary{calc}

usepackage{aeguill}
newcommand*{stereotype}[1]{
guillemotleft {#1}guillemotright%
}

tikzset{class or interface/.style={%
draw,%
shape=rectangle split,%
rectangle split parts=3,%
rectangle split part align={center,left,left},%
rectangle split part fill={#1!30!white,#1!20!white,#1!10!white}},
interface/.style={class or interface=green},
concrete class/.style={class or interface=red}}
newtheorem{exercise}{Exercise}

newcommand*umlClassStyle[1]{texttt{textbf{#1}}}
newcommand*umlAbstractClassStyle[1]{texttt{textit{#1}}}
newcommand*umlInterfaceStyle[1]{texttt{textit{#1}}}

begin{document}

%
%
begin{frame}[fragile]
frametitle{Class Diagram of the Observer Pattern}
begin{tikzpicture}[every text node part/.style={align=center}%
,every two node part/.style={align=center}%
,every three node part/.style={align=left}%
,node distance=2]
path (0,0) node(Subject)[interface,anchor=east]
{nodepart{text}
stereotype{interface}\
umlInterfaceStyle{Subject}
nodepart{two}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.south)
+(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
{nodepart{text}
umlClassStyle{ConcreteSubject}
nodepart{two}
texttt{Observer observers}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.north east)
+(+1.5,+0.0)node(ConcreteObserver)[concrete class,anchor=north west]
{nodepart{text}
umlClassStyle{ConcreteObserver}
nodepart{two}
texttt{Subject subject}
nodepart{three}
texttt{update( Object o )} }
(ConcreteObserver.south |- ConcreteSubject.north)
node(Observer)[interface,anchor=north]
{nodepart{text}
stereotype{interface} \
umlInterfaceStyle{Observer}
nodepart{two}
nodepart{three}
texttt{update( Object o )} };
draw[->,>=open triangle 90,dashed]
(ConcreteSubject) -- (Subject)
node[pos=0.1,anchor=south east] {scriptsize{implements}};
draw[->,>=open triangle 90,dashed]
(ConcreteObserver) -- (Observer)
node[pos=0.1,anchor=north east] {scriptsize{implements}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteSubject.text east) -- (ConcreteSubject.text east -| Observer.west)
node[pos=0.1,anchor=south west] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$n$}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteObserver.text west) -- (ConcreteObserver.text west -| Subject.east)
node[pos=0.1,anchor=south east] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$1$}};
end{tikzpicture}
end{frame}
%
%

end{document}


observer patterns










share|improve this question
























  • I believe your first sentence is supposed to read "I'm using user-defined macros to set the type style for the nodeparts...". You might want to consider boiling down your example to include only the stuff that's necessary to illustrate the problem. As it is, it's quite complicated, and includes a package that's not necessary to demonstrate the issue (aeguill).
    – Jake
    Jan 23 '12 at 5:19










  • @Jake You are right about the first sentence. As to the example, I could make up one but I decided I might as well give some motivation and show why I need it.
    – user10274
    Jan 23 '12 at 5:23














13












13








13


7





In the following, I'm using user-defined macros to set the type style for the nodeparts for class nodes (texttt{textbf{#1}}), interfaces (texttt{textit{#1}}).



Using the tikzset command I also define styles for classes or interfaces that define how these node parts shoulde be aligned and filled. Is there a correct way to set the typesetyle of the node parts as well?



documentclass{beamer}

usepackage{tikz}
usetikzlibrary{shapes}
usetikzlibrary{arrows}
usetikzlibrary{calc}

usepackage{aeguill}
newcommand*{stereotype}[1]{
guillemotleft {#1}guillemotright%
}

tikzset{class or interface/.style={%
draw,%
shape=rectangle split,%
rectangle split parts=3,%
rectangle split part align={center,left,left},%
rectangle split part fill={#1!30!white,#1!20!white,#1!10!white}},
interface/.style={class or interface=green},
concrete class/.style={class or interface=red}}
newtheorem{exercise}{Exercise}

newcommand*umlClassStyle[1]{texttt{textbf{#1}}}
newcommand*umlAbstractClassStyle[1]{texttt{textit{#1}}}
newcommand*umlInterfaceStyle[1]{texttt{textit{#1}}}

begin{document}

%
%
begin{frame}[fragile]
frametitle{Class Diagram of the Observer Pattern}
begin{tikzpicture}[every text node part/.style={align=center}%
,every two node part/.style={align=center}%
,every three node part/.style={align=left}%
,node distance=2]
path (0,0) node(Subject)[interface,anchor=east]
{nodepart{text}
stereotype{interface}\
umlInterfaceStyle{Subject}
nodepart{two}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.south)
+(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
{nodepart{text}
umlClassStyle{ConcreteSubject}
nodepart{two}
texttt{Observer observers}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.north east)
+(+1.5,+0.0)node(ConcreteObserver)[concrete class,anchor=north west]
{nodepart{text}
umlClassStyle{ConcreteObserver}
nodepart{two}
texttt{Subject subject}
nodepart{three}
texttt{update( Object o )} }
(ConcreteObserver.south |- ConcreteSubject.north)
node(Observer)[interface,anchor=north]
{nodepart{text}
stereotype{interface} \
umlInterfaceStyle{Observer}
nodepart{two}
nodepart{three}
texttt{update( Object o )} };
draw[->,>=open triangle 90,dashed]
(ConcreteSubject) -- (Subject)
node[pos=0.1,anchor=south east] {scriptsize{implements}};
draw[->,>=open triangle 90,dashed]
(ConcreteObserver) -- (Observer)
node[pos=0.1,anchor=north east] {scriptsize{implements}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteSubject.text east) -- (ConcreteSubject.text east -| Observer.west)
node[pos=0.1,anchor=south west] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$n$}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteObserver.text west) -- (ConcreteObserver.text west -| Subject.east)
node[pos=0.1,anchor=south east] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$1$}};
end{tikzpicture}
end{frame}
%
%

end{document}


observer patterns










share|improve this question















In the following, I'm using user-defined macros to set the type style for the nodeparts for class nodes (texttt{textbf{#1}}), interfaces (texttt{textit{#1}}).



Using the tikzset command I also define styles for classes or interfaces that define how these node parts shoulde be aligned and filled. Is there a correct way to set the typesetyle of the node parts as well?



documentclass{beamer}

usepackage{tikz}
usetikzlibrary{shapes}
usetikzlibrary{arrows}
usetikzlibrary{calc}

usepackage{aeguill}
newcommand*{stereotype}[1]{
guillemotleft {#1}guillemotright%
}

tikzset{class or interface/.style={%
draw,%
shape=rectangle split,%
rectangle split parts=3,%
rectangle split part align={center,left,left},%
rectangle split part fill={#1!30!white,#1!20!white,#1!10!white}},
interface/.style={class or interface=green},
concrete class/.style={class or interface=red}}
newtheorem{exercise}{Exercise}

newcommand*umlClassStyle[1]{texttt{textbf{#1}}}
newcommand*umlAbstractClassStyle[1]{texttt{textit{#1}}}
newcommand*umlInterfaceStyle[1]{texttt{textit{#1}}}

begin{document}

%
%
begin{frame}[fragile]
frametitle{Class Diagram of the Observer Pattern}
begin{tikzpicture}[every text node part/.style={align=center}%
,every two node part/.style={align=center}%
,every three node part/.style={align=left}%
,node distance=2]
path (0,0) node(Subject)[interface,anchor=east]
{nodepart{text}
stereotype{interface}\
umlInterfaceStyle{Subject}
nodepart{two}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.south)
+(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
{nodepart{text}
umlClassStyle{ConcreteSubject}
nodepart{two}
texttt{Observer observers}
nodepart{three}tabular{@{}l}
texttt{attach( Observer o )}\
texttt{detach( Observer o )}\
texttt{notify( )}
endtabular}
(Subject.north east)
+(+1.5,+0.0)node(ConcreteObserver)[concrete class,anchor=north west]
{nodepart{text}
umlClassStyle{ConcreteObserver}
nodepart{two}
texttt{Subject subject}
nodepart{three}
texttt{update( Object o )} }
(ConcreteObserver.south |- ConcreteSubject.north)
node(Observer)[interface,anchor=north]
{nodepart{text}
stereotype{interface} \
umlInterfaceStyle{Observer}
nodepart{two}
nodepart{three}
texttt{update( Object o )} };
draw[->,>=open triangle 90,dashed]
(ConcreteSubject) -- (Subject)
node[pos=0.1,anchor=south east] {scriptsize{implements}};
draw[->,>=open triangle 90,dashed]
(ConcreteObserver) -- (Observer)
node[pos=0.1,anchor=north east] {scriptsize{implements}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteSubject.text east) -- (ConcreteSubject.text east -| Observer.west)
node[pos=0.1,anchor=south west] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$n$}};
draw[<->,arrows=open diamond-angle 90]
(ConcreteObserver.text west) -- (ConcreteObserver.text west -| Subject.east)
node[pos=0.1,anchor=south east] {scriptsize{has a}}
node[very near end,anchor=south] {scriptsize{$1$}};
end{tikzpicture}
end{frame}
%
%

end{document}


observer patterns







tikz-pgf nodes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 14 mins ago









Glorfindel

163119




163119










asked Jan 23 '12 at 5:06







user10274



















  • I believe your first sentence is supposed to read "I'm using user-defined macros to set the type style for the nodeparts...". You might want to consider boiling down your example to include only the stuff that's necessary to illustrate the problem. As it is, it's quite complicated, and includes a package that's not necessary to demonstrate the issue (aeguill).
    – Jake
    Jan 23 '12 at 5:19










  • @Jake You are right about the first sentence. As to the example, I could make up one but I decided I might as well give some motivation and show why I need it.
    – user10274
    Jan 23 '12 at 5:23


















  • I believe your first sentence is supposed to read "I'm using user-defined macros to set the type style for the nodeparts...". You might want to consider boiling down your example to include only the stuff that's necessary to illustrate the problem. As it is, it's quite complicated, and includes a package that's not necessary to demonstrate the issue (aeguill).
    – Jake
    Jan 23 '12 at 5:19










  • @Jake You are right about the first sentence. As to the example, I could make up one but I decided I might as well give some motivation and show why I need it.
    – user10274
    Jan 23 '12 at 5:23
















I believe your first sentence is supposed to read "I'm using user-defined macros to set the type style for the nodeparts...". You might want to consider boiling down your example to include only the stuff that's necessary to illustrate the problem. As it is, it's quite complicated, and includes a package that's not necessary to demonstrate the issue (aeguill).
– Jake
Jan 23 '12 at 5:19




I believe your first sentence is supposed to read "I'm using user-defined macros to set the type style for the nodeparts...". You might want to consider boiling down your example to include only the stuff that's necessary to illustrate the problem. As it is, it's quite complicated, and includes a package that's not necessary to demonstrate the issue (aeguill).
– Jake
Jan 23 '12 at 5:19












@Jake You are right about the first sentence. As to the example, I could make up one but I decided I might as well give some motivation and show why I need it.
– user10274
Jan 23 '12 at 5:23




@Jake You are right about the first sentence. As to the example, I could make up one but I decided I might as well give some motivation and show why I need it.
– user10274
Jan 23 '12 at 5:23










2 Answers
2






active

oldest

votes


















11














You can choose the font for a node part by using the normal TikZ key font=<font switch like bfseries>. Note that the default Computer Modern font does not have a bold typewriter font. You can use the Courier font for that (see Using ttfamily with bfseries (or how to enable bold in fixed-width font)).



documentclass{beamer}

usepackage{tikz}
usetikzlibrary{shapes}
usetikzlibrary{arrows}
usetikzlibrary{calc}




usepackage{aeguill}
newcommand*{stereotype}[1]{
guillemotleft {#1}guillemotright%
}

tikzset{class or interface/.style={%
draw,%
shape=rectangle split,%
rectangle split parts=3,%
rectangle split part align={center,left,left},%
rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
every two node part/.style={align=center, font=ttfamily},
every three node part/.style={align=left, font=ttfamily},
node distance=2
},
interface/.style={
class or interface=green,
every one node part/.style={align=center, font=ttfamilyitshape}
},
concrete class/.style={
class or interface=red,
every one node part/.style={align=center, font=ttfamilybfseries}
}
}
newtheorem{exercise}{Exercise}


begin{document}
renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold
%
%
begin{frame}[fragile]
frametitle{Class Diagram of the Observer Pattern}
begin{tikzpicture}]
path (0,0) node(Subject)[interface,anchor=east]
{nodepart{one}
stereotype{interface}\
Subject
nodepart{two}
nodepart{three}tabular{@{}l}
attach( Observer o )\
detach( Observer o )\
notify( )
endtabular}
(Subject.south)
+(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
{nodepart{one}
ConcreteSubject
nodepart{two}
Observer observers
nodepart{three}tabular{@{}l}
attach( Observer o )\
detach( Observer o )\
notify( )
endtabular};
end{tikzpicture}
end{frame}
%
%

end{document}





share|improve this answer































    0














    Bases on very interesting Jake answer but with some effort to make code more concise (used recent Beamer v3.41 and Tikz v 3.0.1a):



    documentclass{beamer}
    usepackage{tikz}
    usetikzlibrary{arrows, calc, positioning, shapes}% added positioning
    usepackage{aeguill}% for defining of quotation marks
    newcommand*{stereotype}[1]{
    guillemotleft {#1}guillemotright%
    }
    renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold face
    tikzset{
    box/.style={% simplified
    draw,
    shape=rectangle split,
    rectangle split parts=3,
    align=center,
    rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
    font=ttfamily,
    every three node part/.style={align=left}
    },
    node distance=1
    }% end of tikzset

    begin{document}
    %
    begin{frame}
    frametitle{Class Diagram of the Observer Pattern}
    centering
    begin{tikzpicture}
    node (Subject) [box=green] {%
    nodepart{one}itshape stereotype{interface}\
    Subject
    nodepart{two}
    nodepart{three} attach( Observer o )\
    detach( Observer o )\
    notify( )
    };
    node (ConcreteSubject) [box=red,below=of Subject] {%
    nodepart{one}bfseries ConcreteSubject
    nodepart{two} Observer observers
    nodepart{three} attach( Observer o )\
    detach( Observer o )\
    notify( )
    };
    end{tikzpicture}
    end{frame}
    %
    end{document}


    enter image description here






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f41959%2ftikz-styles-that-set-nodepart-styles%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown
























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      11














      You can choose the font for a node part by using the normal TikZ key font=<font switch like bfseries>. Note that the default Computer Modern font does not have a bold typewriter font. You can use the Courier font for that (see Using ttfamily with bfseries (or how to enable bold in fixed-width font)).



      documentclass{beamer}

      usepackage{tikz}
      usetikzlibrary{shapes}
      usetikzlibrary{arrows}
      usetikzlibrary{calc}




      usepackage{aeguill}
      newcommand*{stereotype}[1]{
      guillemotleft {#1}guillemotright%
      }

      tikzset{class or interface/.style={%
      draw,%
      shape=rectangle split,%
      rectangle split parts=3,%
      rectangle split part align={center,left,left},%
      rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
      every two node part/.style={align=center, font=ttfamily},
      every three node part/.style={align=left, font=ttfamily},
      node distance=2
      },
      interface/.style={
      class or interface=green,
      every one node part/.style={align=center, font=ttfamilyitshape}
      },
      concrete class/.style={
      class or interface=red,
      every one node part/.style={align=center, font=ttfamilybfseries}
      }
      }
      newtheorem{exercise}{Exercise}


      begin{document}
      renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold
      %
      %
      begin{frame}[fragile]
      frametitle{Class Diagram of the Observer Pattern}
      begin{tikzpicture}]
      path (0,0) node(Subject)[interface,anchor=east]
      {nodepart{one}
      stereotype{interface}\
      Subject
      nodepart{two}
      nodepart{three}tabular{@{}l}
      attach( Observer o )\
      detach( Observer o )\
      notify( )
      endtabular}
      (Subject.south)
      +(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
      {nodepart{one}
      ConcreteSubject
      nodepart{two}
      Observer observers
      nodepart{three}tabular{@{}l}
      attach( Observer o )\
      detach( Observer o )\
      notify( )
      endtabular};
      end{tikzpicture}
      end{frame}
      %
      %

      end{document}





      share|improve this answer




























        11














        You can choose the font for a node part by using the normal TikZ key font=<font switch like bfseries>. Note that the default Computer Modern font does not have a bold typewriter font. You can use the Courier font for that (see Using ttfamily with bfseries (or how to enable bold in fixed-width font)).



        documentclass{beamer}

        usepackage{tikz}
        usetikzlibrary{shapes}
        usetikzlibrary{arrows}
        usetikzlibrary{calc}




        usepackage{aeguill}
        newcommand*{stereotype}[1]{
        guillemotleft {#1}guillemotright%
        }

        tikzset{class or interface/.style={%
        draw,%
        shape=rectangle split,%
        rectangle split parts=3,%
        rectangle split part align={center,left,left},%
        rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
        every two node part/.style={align=center, font=ttfamily},
        every three node part/.style={align=left, font=ttfamily},
        node distance=2
        },
        interface/.style={
        class or interface=green,
        every one node part/.style={align=center, font=ttfamilyitshape}
        },
        concrete class/.style={
        class or interface=red,
        every one node part/.style={align=center, font=ttfamilybfseries}
        }
        }
        newtheorem{exercise}{Exercise}


        begin{document}
        renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold
        %
        %
        begin{frame}[fragile]
        frametitle{Class Diagram of the Observer Pattern}
        begin{tikzpicture}]
        path (0,0) node(Subject)[interface,anchor=east]
        {nodepart{one}
        stereotype{interface}\
        Subject
        nodepart{two}
        nodepart{three}tabular{@{}l}
        attach( Observer o )\
        detach( Observer o )\
        notify( )
        endtabular}
        (Subject.south)
        +(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
        {nodepart{one}
        ConcreteSubject
        nodepart{two}
        Observer observers
        nodepart{three}tabular{@{}l}
        attach( Observer o )\
        detach( Observer o )\
        notify( )
        endtabular};
        end{tikzpicture}
        end{frame}
        %
        %

        end{document}





        share|improve this answer


























          11












          11








          11






          You can choose the font for a node part by using the normal TikZ key font=<font switch like bfseries>. Note that the default Computer Modern font does not have a bold typewriter font. You can use the Courier font for that (see Using ttfamily with bfseries (or how to enable bold in fixed-width font)).



          documentclass{beamer}

          usepackage{tikz}
          usetikzlibrary{shapes}
          usetikzlibrary{arrows}
          usetikzlibrary{calc}




          usepackage{aeguill}
          newcommand*{stereotype}[1]{
          guillemotleft {#1}guillemotright%
          }

          tikzset{class or interface/.style={%
          draw,%
          shape=rectangle split,%
          rectangle split parts=3,%
          rectangle split part align={center,left,left},%
          rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
          every two node part/.style={align=center, font=ttfamily},
          every three node part/.style={align=left, font=ttfamily},
          node distance=2
          },
          interface/.style={
          class or interface=green,
          every one node part/.style={align=center, font=ttfamilyitshape}
          },
          concrete class/.style={
          class or interface=red,
          every one node part/.style={align=center, font=ttfamilybfseries}
          }
          }
          newtheorem{exercise}{Exercise}


          begin{document}
          renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold
          %
          %
          begin{frame}[fragile]
          frametitle{Class Diagram of the Observer Pattern}
          begin{tikzpicture}]
          path (0,0) node(Subject)[interface,anchor=east]
          {nodepart{one}
          stereotype{interface}\
          Subject
          nodepart{two}
          nodepart{three}tabular{@{}l}
          attach( Observer o )\
          detach( Observer o )\
          notify( )
          endtabular}
          (Subject.south)
          +(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
          {nodepart{one}
          ConcreteSubject
          nodepart{two}
          Observer observers
          nodepart{three}tabular{@{}l}
          attach( Observer o )\
          detach( Observer o )\
          notify( )
          endtabular};
          end{tikzpicture}
          end{frame}
          %
          %

          end{document}





          share|improve this answer














          You can choose the font for a node part by using the normal TikZ key font=<font switch like bfseries>. Note that the default Computer Modern font does not have a bold typewriter font. You can use the Courier font for that (see Using ttfamily with bfseries (or how to enable bold in fixed-width font)).



          documentclass{beamer}

          usepackage{tikz}
          usetikzlibrary{shapes}
          usetikzlibrary{arrows}
          usetikzlibrary{calc}




          usepackage{aeguill}
          newcommand*{stereotype}[1]{
          guillemotleft {#1}guillemotright%
          }

          tikzset{class or interface/.style={%
          draw,%
          shape=rectangle split,%
          rectangle split parts=3,%
          rectangle split part align={center,left,left},%
          rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
          every two node part/.style={align=center, font=ttfamily},
          every three node part/.style={align=left, font=ttfamily},
          node distance=2
          },
          interface/.style={
          class or interface=green,
          every one node part/.style={align=center, font=ttfamilyitshape}
          },
          concrete class/.style={
          class or interface=red,
          every one node part/.style={align=center, font=ttfamilybfseries}
          }
          }
          newtheorem{exercise}{Exercise}


          begin{document}
          renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold
          %
          %
          begin{frame}[fragile]
          frametitle{Class Diagram of the Observer Pattern}
          begin{tikzpicture}]
          path (0,0) node(Subject)[interface,anchor=east]
          {nodepart{one}
          stereotype{interface}\
          Subject
          nodepart{two}
          nodepart{three}tabular{@{}l}
          attach( Observer o )\
          detach( Observer o )\
          notify( )
          endtabular}
          (Subject.south)
          +(+0.0,-1.5)node(ConcreteSubject)[concrete class,anchor=north]
          {nodepart{one}
          ConcreteSubject
          nodepart{two}
          Observer observers
          nodepart{three}tabular{@{}l}
          attach( Observer o )\
          detach( Observer o )\
          notify( )
          endtabular};
          end{tikzpicture}
          end{frame}
          %
          %

          end{document}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 13 '17 at 12:35









          Community

          1




          1










          answered Jan 23 '12 at 5:58









          Jake

          193k24645760




          193k24645760























              0














              Bases on very interesting Jake answer but with some effort to make code more concise (used recent Beamer v3.41 and Tikz v 3.0.1a):



              documentclass{beamer}
              usepackage{tikz}
              usetikzlibrary{arrows, calc, positioning, shapes}% added positioning
              usepackage{aeguill}% for defining of quotation marks
              newcommand*{stereotype}[1]{
              guillemotleft {#1}guillemotright%
              }
              renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold face
              tikzset{
              box/.style={% simplified
              draw,
              shape=rectangle split,
              rectangle split parts=3,
              align=center,
              rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
              font=ttfamily,
              every three node part/.style={align=left}
              },
              node distance=1
              }% end of tikzset

              begin{document}
              %
              begin{frame}
              frametitle{Class Diagram of the Observer Pattern}
              centering
              begin{tikzpicture}
              node (Subject) [box=green] {%
              nodepart{one}itshape stereotype{interface}\
              Subject
              nodepart{two}
              nodepart{three} attach( Observer o )\
              detach( Observer o )\
              notify( )
              };
              node (ConcreteSubject) [box=red,below=of Subject] {%
              nodepart{one}bfseries ConcreteSubject
              nodepart{two} Observer observers
              nodepart{three} attach( Observer o )\
              detach( Observer o )\
              notify( )
              };
              end{tikzpicture}
              end{frame}
              %
              end{document}


              enter image description here






              share|improve this answer


























                0














                Bases on very interesting Jake answer but with some effort to make code more concise (used recent Beamer v3.41 and Tikz v 3.0.1a):



                documentclass{beamer}
                usepackage{tikz}
                usetikzlibrary{arrows, calc, positioning, shapes}% added positioning
                usepackage{aeguill}% for defining of quotation marks
                newcommand*{stereotype}[1]{
                guillemotleft {#1}guillemotright%
                }
                renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold face
                tikzset{
                box/.style={% simplified
                draw,
                shape=rectangle split,
                rectangle split parts=3,
                align=center,
                rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
                font=ttfamily,
                every three node part/.style={align=left}
                },
                node distance=1
                }% end of tikzset

                begin{document}
                %
                begin{frame}
                frametitle{Class Diagram of the Observer Pattern}
                centering
                begin{tikzpicture}
                node (Subject) [box=green] {%
                nodepart{one}itshape stereotype{interface}\
                Subject
                nodepart{two}
                nodepart{three} attach( Observer o )\
                detach( Observer o )\
                notify( )
                };
                node (ConcreteSubject) [box=red,below=of Subject] {%
                nodepart{one}bfseries ConcreteSubject
                nodepart{two} Observer observers
                nodepart{three} attach( Observer o )\
                detach( Observer o )\
                notify( )
                };
                end{tikzpicture}
                end{frame}
                %
                end{document}


                enter image description here






                share|improve this answer
























                  0












                  0








                  0






                  Bases on very interesting Jake answer but with some effort to make code more concise (used recent Beamer v3.41 and Tikz v 3.0.1a):



                  documentclass{beamer}
                  usepackage{tikz}
                  usetikzlibrary{arrows, calc, positioning, shapes}% added positioning
                  usepackage{aeguill}% for defining of quotation marks
                  newcommand*{stereotype}[1]{
                  guillemotleft {#1}guillemotright%
                  }
                  renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold face
                  tikzset{
                  box/.style={% simplified
                  draw,
                  shape=rectangle split,
                  rectangle split parts=3,
                  align=center,
                  rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
                  font=ttfamily,
                  every three node part/.style={align=left}
                  },
                  node distance=1
                  }% end of tikzset

                  begin{document}
                  %
                  begin{frame}
                  frametitle{Class Diagram of the Observer Pattern}
                  centering
                  begin{tikzpicture}
                  node (Subject) [box=green] {%
                  nodepart{one}itshape stereotype{interface}\
                  Subject
                  nodepart{two}
                  nodepart{three} attach( Observer o )\
                  detach( Observer o )\
                  notify( )
                  };
                  node (ConcreteSubject) [box=red,below=of Subject] {%
                  nodepart{one}bfseries ConcreteSubject
                  nodepart{two} Observer observers
                  nodepart{three} attach( Observer o )\
                  detach( Observer o )\
                  notify( )
                  };
                  end{tikzpicture}
                  end{frame}
                  %
                  end{document}


                  enter image description here






                  share|improve this answer












                  Bases on very interesting Jake answer but with some effort to make code more concise (used recent Beamer v3.41 and Tikz v 3.0.1a):



                  documentclass{beamer}
                  usepackage{tikz}
                  usetikzlibrary{arrows, calc, positioning, shapes}% added positioning
                  usepackage{aeguill}% for defining of quotation marks
                  newcommand*{stereotype}[1]{
                  guillemotleft {#1}guillemotright%
                  }
                  renewcommand{ttdefault}{pcr} % Choose typewriter font that supports bold face
                  tikzset{
                  box/.style={% simplified
                  draw,
                  shape=rectangle split,
                  rectangle split parts=3,
                  align=center,
                  rectangle split part fill={#1!30!white,#1!20!white,#1!10!white},
                  font=ttfamily,
                  every three node part/.style={align=left}
                  },
                  node distance=1
                  }% end of tikzset

                  begin{document}
                  %
                  begin{frame}
                  frametitle{Class Diagram of the Observer Pattern}
                  centering
                  begin{tikzpicture}
                  node (Subject) [box=green] {%
                  nodepart{one}itshape stereotype{interface}\
                  Subject
                  nodepart{two}
                  nodepart{three} attach( Observer o )\
                  detach( Observer o )\
                  notify( )
                  };
                  node (ConcreteSubject) [box=red,below=of Subject] {%
                  nodepart{one}bfseries ConcreteSubject
                  nodepart{two} Observer observers
                  nodepart{three} attach( Observer o )\
                  detach( Observer o )\
                  notify( )
                  };
                  end{tikzpicture}
                  end{frame}
                  %
                  end{document}


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 9 '17 at 16:22









                  Zarko

                  120k865156




                  120k865156






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f41959%2ftikz-styles-that-set-nodepart-styles%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Accessing regular linux commands in Huawei's Dopra Linux

                      Can't connect RFCOMM socket: Host is down

                      Kernel panic - not syncing: Fatal Exception in Interrupt