2

I wanted to use the umlstatetext macro in my uml state diagram. I use the version 1.0 of tikz-uml though the macro just does nothing, as in there is no text added in the body of the state or any where else. Anybody with similar problems and knows a work around?

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-uml}

\begin{document}
\begin{tikzpicture}
\begin{umlstate}[x=0,y=-4, name=horizontal, fill=white]{Waagrecht}
\umlstatetext{Some State Content}
\end{umlstate}
\end{tikzpicture}

\end{document}

EDIT: In this example it works actually. But as soon as the example gets more complicated it just doesn't show it anymore:

\begin{tikzpicture}
\begin{umlstate}[name=main]{Großkanonischer-Monte-Carlo-Schritt}
\umlstateinitial[x=4, y=1.75, name=mainInit]
\begin{umlstate}[y=-2, name=input, fill=gray!20]{\shortstack{Einfügen\\ Wahrscheinlichkeit $\alpha_{ins} = \frac{2M^2}{N+1}\cdot e^{\beta \cdot }$}}
\umlstateinitial[x = 4, name=initInput]
\begin{umlstate}[x=0,y=-4, name=horizontal, fill=white]{Waagrecht}
\umlstatetext{Some

State

Content

$$x = y$$
}
\umlstatetext{Teste auf Kollision}

\umlstatedecision[x=4, y=0, name=decision]
\umlstatefinal[x=1, y=-3, name=collision]
\umlHVtrans[arg=transition1, pos=1.5]{decision}{collision}
\begin{umlstate}[x=4, y=-3, name=noCollision]{Keine Kollision}
\end{umlstate}
\umltrans[arg=]{decision}{noCollision}
\end{umlstate}
\begin{umlstate}[x=8,y=-4, name=vertical, fill=white]{Senkrecht}
\umlstatedecision[ x=4, y=0, name=decision]
\begin{umlstate}[x=1, y=-3, name=noCollision]{Keine Kollision}
\end{umlstate}
\umlbasicstate[x=4.5, y=-3, name=collision]{Kollision}
\end{umlstate}
\umlHVtrans[arg=transition1, pos=1.5]{initInput}{vertical}
\umlHVtrans[arg=transition1, pos=1.5]{initInput}{horizontal}
\end{umlstate}
\umlHVtrans[arg=$\frac{1}{2}$, pos=1.5]{mainInit}{input}
\end{umlstate}
\end{tikzpicture}
2

First of all, seems there can be only one \umlstatetext in an umlstate environment, any additional ones will overwrite the first one. And the text in the argument is put inside a tabular with a single l column, so text doesn't wrap, and you can't use displayed math. You can add multiple lines by using \\ though, as in a normal tabular.

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-uml}    
\begin{document}
\begin{tikzpicture}
\begin{umlstate}[x=0,y=-4, name=horizontal, fill=white]{Waagrecht}
\umlstatetext{%
Some State Content\\
And more}
\end{umlstate}
\end{tikzpicture}
\end{document}

output of above code

Regarding your more complex example, if you have a nested umlstate environment, you need to add the \umlstatetext after the nested environment. This is, if I understood the code directly, because \umlstatetext does

\def\tikzumlStateText{#1}

but the umlstate environment does

\def\tikzumlStateText{tikzumlEmpty}%

before the content of the environment, i.e. it "empties" the existing definition of \tikzumlStateText.

So implementing that in your larger example:

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-uml}    
\begin{document}    
\begin{tikzpicture}
\begin{umlstate}[name=main]{Großkanonischer-Monte-Carlo-Schritt}
\umlstateinitial[x=4, y=1.75, name=mainInit]
\begin{umlstate}[y=-2, name=input, fill=gray!20]{\shortstack{Einfügen\\ Wahrscheinlichkeit $\alpha_{ins} = \frac{2M^2}{N+1}\cdot e^{\beta \cdot }$}}
\umlstateinitial[x = 4, name=initInput]
\begin{umlstate}[x=0,y=-4, name=horizontal, fill=white]{Waagrecht}
\umlstatedecision[x=4, y=0, name=decision]
\umlstatefinal[x=1, y=-3, name=collision]
\umlHVtrans[arg=transition1, pos=1.5]{decision}{collision}
\begin{umlstate}[x=4, y=-3, name=noCollision]{Keine Kollision}
\end{umlstate}
% note this is placed after the nested umlstate environment
\umlstatetext{Teste auf Kollision}
\umltrans[arg=]{decision}{noCollision}
\end{umlstate}
\begin{umlstate}[x=8,y=-4, name=vertical, fill=white]{Senkrecht}
\umlstatedecision[ x=4, y=0, name=decision]
\begin{umlstate}[x=1, y=-3, name=noCollision]{Keine Kollision}
\end{umlstate}
\umlbasicstate[x=4.5, y=-3, name=collision]{Kollision}
\end{umlstate}
\umlHVtrans[arg=transition1, pos=1.5]{initInput}{vertical}
\umlHVtrans[arg=transition1, pos=1.5]{initInput}{horizontal}
\end{umlstate}
\umlHVtrans[arg=$\frac{1}{2}$, pos=1.5]{mainInit}{input}
\end{umlstate}
\end{tikzpicture}
\end{document}

output of second code

| improve this answer | |

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.