I use the UML-tikZ package to create UML state machines. From time to time I want to make changes to the appearance of the given elements. For example, I want to enlarge the arrowhead of the element \umltrans (line 13). Stupidly, a completely different arrow enlarges, which has nothing to do with this transition at all. Can you tell me if and how to change the style of UML elements using the commands from the tikZ library?

\usetikzlibrary{positioning, calc, shadings, shadows, shapes.arrows, arrows.meta, matrix, mindmap}
    \umlstateinitial[name=start, x=0,y=3]{start}
    \umlbasicstate [name=manuel, fill=red!20, width=5cm] {manuel}
    \umlbasicstate [name=waiting,below left=4of manuel,fill=red!20, width=5cm,] {witing}
    \umlbasicstate [name=auto,below right=4of manuel,fill=red!20, width=5cm] {auto}
    \umlbasicstate [name=time,below=8of manuel,fill=red!20, width=5cm] {time}
    \umltrans[geometry =-|]{start}{waiting}
    \umltrans[->,/tikz/arrows={-Straight Barb[angle=60:9pt 3]}]{waiting}{auto}

enter image description here

1 Answer 1


For state transitions macros this is the default style:

\tikzstyle{tikzuml transition style}=[color=\tikzumlDefaultDrawColor, rounded corners, -angle 45]

You can define your own styles in the preamble to change a particular transition.




\tikzstyle{tikzuml transition style2}=[color=blue, rounded corners, arrows={-Straight Barb[angle=60:9pt 3]}]% added <<<<

\tikzstyle{tikzuml transition style3}=[color=red, rounded corners, arrows={-Latex[angle=40:5.5mm]}]% added <<<<

            \umlbasicstate[name=waiting,below left=1 of manuel,fill=red!20,width=5cm,]{waiting}
            \umlbasicstate[name=auto,below right=1 of manuel,fill=red!20,width=5cm]{auto}
            \umlbasicstate[name=time,below=8 of manuel,fill=red!20,width=5cm]{time}
            \umlHVtrans[tikzuml transition style2]{start}{waiting} % changed <<<<<<<<<<<<
            \umltrans[tikzuml transition style3]{waiting}{auto}% changed <<<<<<<<<<<<

Analogously, the default style for the state

\tikzstyle{tikzuml state style}=[rectangle split, rectangle split parts=2, rounded corners, inner xsep=1.5ex]%

can be redefined.

  • Thank you for your valuable approach. It has solved my problem. I now have a state machine diagram with clearly visible arrows. However, instead of the \tikzstyle syntax, I wrote the style definitions in the square brackets that follow \begin{tikzpicture}[...].
    – Z.J
    Aug 16 at 5:46
  • @Z.J Thank you for your feedback! Aug 16 at 12:55

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.