1

Following MWE:

\documentclass{article}

\begin{filecontents}{defis.bib}
% Encoding: UTF-8
@entry{sometool,
name={SomeTool},
description={A fictive tool.}
}
\end{filecontents}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[record]{glossaries-extra}
\GlsXtrLoadResources[src=defis]


\usepackage{tikz}
\usepackage{tikz-uml}

\begin{document}
\begin{tikzpicture}
\node at (0,0) {some text \gls{sometool}}
\umlactor{sometool}%\gls{sometool}
\begin{umlsystem}{sometool}%\gls{sometool}
\end{umlsystem}
\end{tikzpicture}
\end{document}

The file defis.bib is as you would expect and defines sometool as SomeTool and the package tikz-uml is installed at the working directory. Its documentation is given by https://perso.ensta-paris.fr/~kielbasi/tikzuml/var/files/doc/tikzumlmanual.pdf.

Compilation is done by

pdflatex test
bib2gls test
pdflatex test

As one would expect, some text \gls{sometool} displays as some text SomeTool. So tikz itself combines with glossaries-extra and bib2gls.

In contrast, if I try to replace sometool by \gls{sometool} in the constructs related with tikz-uml, then an error occurs running pdflatex:

! Missing \endcsname inserted. 
<to be read again>
        
l.21\umlactor{\gls{sometool}}

?
  • Academic question: Why do glossaries cooperate with tikz but not with tikz-uml.
  • Practical question: What to do to make it work for tikz-uml?
6
  • 3
    The file defis.bib is as you would expect please supply a suitable file in a code block so people can see the issue and test answers. Commented Jun 23 at 13:08
  • 1
    also, please tell us where you got tikz-uml.sty. it is not in tex live. nor can I find it on ctan. Commented Jun 23 at 15:57
  • I guess from perso.ensta-paris.fr/~kielbasi/tikzuml/…. however, that software is unlicensed, as far as I can tell, which means nobody but the author has any legal right to use it. Commented Jun 23 at 16:10
  • you would have to patch or redefine \umlactor in order to make this work. I'd recommend just typing the name in \umlactor. unless you need to do the same thing many times, I doubt it is worth the trouble making it work. Commented Jun 23 at 16:21
  • @DavidCarlisle I added defis.bib. Commented Jun 23 at 22:30

1 Answer 1

3

The issue is that tikz-uml uses the (mandatory) argument of \umlactor not just for the output to print under the actor, but also as an internal TikZ node name. This choice is made for many other \uml... commands as well, and it leads to various issues because TikZ node nodes are supposed to be simple and not contain special characters, and definitely not commands.

This can be demonstrated with a simpler MWE. The following has a \umlactor with \textbf in the argument, that also fails:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{tikz-uml}

\begin{document}
\begin{tikzpicture}
\umlactor{\textbf{sometool}}
\begin{umlsystem}{system name}
\end{umlsystem}
\end{tikzpicture}
\end{document}

As a quick workaround you can patch \umlactor as cfr suggested. The idea here is to define a new command with three arguments, the first optional argument for the node options, the second mandatory argument for a (clean) node name, and the third mandatory argument for the full printable contents. This can be a wrapper around a slightly modified \umlactor command with two arguments, where the modification consists of changing the name of the command to be used for printing the text contents of the actor into the command set by the three-argument version.

The modification of \umlactor (actually of a copy made with \NewCommandCopy, so the original can also still be used) can be done with the xpatch package, which provides the command \xpatchcmd with five arguments, i.e., the command to be patched, the text to be found, the text to be replaced, and what to do when the patch succeeds or fails, respectively.

In the original tikz-uml code the printable contents is used in the following TikZ node:

\node[text=\tikzumlActorTextColor, font=\tikzumlDefaultFont, below=\tikzumlActorScale*\tikzumlActorBelow] at (\tikzumlActorNodeName) {\tikzumlActorName};%

From this line the relevant part is:

at (\tikzumlActorNodeName) {\tikzumlActorName}

which can be changed with xpatch into:

at (\tikzumlActorNodeName) {\tikzumlFullActorName}

Now the three-argument version of \umlactor needs to set \tikzumlFullActorName from its third argument and then call the modified two-argument version with the first two arguments, i.e., the TikZ options and the clean name.

MWE:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{xpatch}
\usepackage{tikz-uml}

\NewCommandCopy\umlactortwo\umlactor
\xpatchcmd{\umlactortwo}{at (\tikzumlActorNodeName) {\tikzumlActorName}}{at (\tikzumlActorNodeName) {\tikzumlFullActorName}}{\typeout{patch ok}}{\typeout{patch failed}}
\newcommand{\umlactorclean}[3][]{%
\def\tikzumlFullActorName{#3}% store full name in command to be called from modified \umlactor
\umlactortwo[#1]{#2}% call modified command with the clean name
}

\begin{document}
\begin{tikzpicture}
\umlactorclean{sometool}{\textbf{sometool}}
\begin{umlsystem}{system name}
\end{umlsystem}
\end{tikzpicture}
\end{document}

Result:

screenshot of actor with bold text

1
  • Thank you very much... works fine, also in the context of glossaries. What I learned is, that I shall contact the author first to ask for a general license and second to resolve the issues with the package -- without patching. Commented Jun 24 at 0:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.