# tikz - draw a uml style note box

Can I draw a uml style note box with tikz?

Below picture is copied from UML:

I try it with tikz as below:

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{positioning,shapes.multipart}

\definecolor{activityBackgroundColor}{RGB}{254,254,206}
\definecolor{activityBorderColor}{RGB}{168,0,54}
\definecolor{noteBackgroundColor}{RGB}{251,251,119}
\definecolor{noteBorderColor}{RGB}{168,0,54}
\begin{document}

\begin{tikzpicture}[every text node part/.style={align=center}]

\node (A) [draw=activityBorderColor,fill=activityBackgroundColor,rectangle,rounded corners,] {Hello \\ world};
\node[draw=noteBorderColor,fill=noteBackgroundColor,rectangle,right=2mm of A] {this is \\ a node};
\end{tikzpicture}

\end{document}


Output:

How can we get exactly the same style as uml note box?

There is a shapes.callout library which comes close without much work. If you insist on the folded corner look, it's possible to create a new shape yourself (although quite a bit of work for that one detail, I suspect.)

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{positioning,shapes.multipart,shapes.callouts}

\definecolor{activityBackgroundColor}{RGB}{254,254,206}
\definecolor{activityBorderColor}{RGB}{168,0,54}
\definecolor{noteBackgroundColor}{RGB}{251,251,119}
\definecolor{noteBorderColor}{RGB}{168,0,54}
\begin{document}

\begin{tikzpicture}[every text node part/.style={align=center}]

\node (A) [draw=activityBorderColor,fill=activityBackgroundColor,rectangle,rounded corners,] {Hello \\ world};
\node[draw=noteBorderColor,fill=noteBackgroundColor,rectangle callout,callout relative pointer={(-1,0)},right =of A] {this is \\ a node};
\end{tikzpicture}

\end{document}


If you would like to add the folded little corner to Alan Munn's answer:

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{positioning,%shapes.multipart,
shapes.callouts}
\definecolor{activityBackgroundColor}{RGB}{254,254,206}
\definecolor{activityBorderColor}{RGB}{168,0,54}
\definecolor{noteBackgroundColor}{RGB}{251,251,119}
\definecolor{noteBorderColor}{RGB}{168,0,54}
\begin{document}

\begin{tikzpicture}[every text node part/.style={align=center}]
\node (A) [draw=activityBorderColor,fill=activityBackgroundColor,rectangle,rounded corners] {Hello \\ world};
\node[draw=noteBorderColor,fill=noteBackgroundColor,rectangle callout,callout relative pointer={(-1,0)},right =3em of A] (B) {this is \\ a node};
\draw[white, fill=white] ([xshift=-4pt]B.north east) -- (B.north east) -- ([yshift=-4pt]B.north east);
\draw[noteBorderColor, fill=noteBackgroundColor, line width=.4pt] ([shift={(-4pt,-.2pt)}]B.north east) -- ([shift={(-4pt,-4pt)}]B.north east)  [rounded corners=.01pt]-- ([shift={(-.2pt,-4pt)}]B.north east) -- cycle;
\end{tikzpicture}

\end{document}


• Nice. It would be nice to make this a style such that the folded corner adapts to the direction of the callout pointer and also to the size of the callout rectangle. Jul 13, 2017 at 19:34
• @AlanMunn Thank you! I'll try to improve it :) Jul 13, 2017 at 19:43