6

I am getting the following error when trying to use mathematic symbols as part of a message caption:

Missing \endcsname inserted

Here is a working minimal example:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgf-umlsd}
\usepgflibrary{arrows} % for pgf-umlsd
\usepackage{verbatim}

\begin{comment}
\end{comment}

\begin{document}

\begin{figure}[!h]
    \centering
        \tikzset{font=\scriptsize}
    \begin{sequencediagram}
    \footnotesize
        \newinst{p}{Prover}
        \newinst[2.6]{v}{Verifier}

        \mess[0]{p}{{$\epsilon$}}{v}{};    % LOCATION OF ERROR
        \node[below {$\epsilon$} to, font=\centering] {$test$};
    \end{sequencediagram}
\caption{\scriptsize Sequence diagram of the device authentication protocol.}   
\label{fig:protocolsAuth}
\end{figure}

\end{document}

There is no problem if no latex macros are used but numbers, text, etc. inside the math mode instead.

1
  • Looks like the package has a general problem with backslashes. While the caption $a$ works, \ensuremath{a} doesn't. Same problem with \textsc{a} or \textbf{a}.
    – JMP
    Mar 30, 2016 at 21:00

2 Answers 2

5

The label in the third argument of \mess is also reused as part of a node name. Therefore the text is very restricted. The following example redefines \mess to make the argument safe for use in node names by using \detokenize:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgf-umlsd}
\usepgflibrary{arrows} % for pgf-umlsd
\usepackage{verbatim}
\usepackage{caption} 
\captionsetup{font=scriptsize}

\renewcommand{\mess}[4][0]{
  \stepcounter{seqlevel}   
  \path
  (#2)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess from) {};
  \addtocounter{seqlevel}{#1}
  \path
  (#4)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess to) {};
  \draw[->,>=angle 60] (mess from) -- (mess to) node[midway, above]
  {#3};

  \node (\detokenize{#3} from) at (mess from) {};
  \node (\detokenize{#3} to) at (mess to) {};
}

\begin{comment}
\end{comment}  

\begin{document}

\begin{figure}[!h]
    \centering
        \tikzset{font=\scriptsize}
    \begin{sequencediagram}
    \footnotesize
        \newinst{p}{Prover}
        \newinst[2.6]{v}{Verifier}

        \mess[0]{p}{$\epsilon$}{v}{};

    \end{sequencediagram}
\caption{Sequence diagram of the device authentication
protocol.}   
\label{fig:protocolsAuth}
\end{figure}

\end{document}

Result

2
  • Thanks for the solution. Unfortunately, it breaks, once I add a node that refers to that message: \node[below {$\epsilon$} to, font=\centering] {$test$}; I will add it to the original post. Mar 31, 2016 at 15:38
  • @RichardLaurant Then \detokenize{$\epsilon$} should be used as node name. Mar 31, 2016 at 16:55
1

If you're not opposed to using the TikZ library calc, here's an approach that will do what you want.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgf-umlsd}
\usepgflibrary{arrows} % for pgf-umlsd
\usepackage{verbatim}

\begin{comment}
\end{comment}

\begin{document}

\def\aee{\mbox{fd}}
\begin{figure}[!h]
    \centering
        \tikzset{font=\scriptsize}
    \begin{sequencediagram}
    \footnotesize
        \newinst{p}{Prover}
        \newinst[2.6]{v}{Verifier}

        \mess[0]{p}{}{v}%{p}{{$\epsilon$}}{v}{};    % LOCATION OF ERROR
        \node[anchor=south] at ($(mess from)!0.5!(mess to)$) {$\epsilon$};
    \end{sequencediagram}
\caption{\scriptsize Sequence diagram of the device authentication protocol.}   
\label{fig:protocolsAuth}
\end{figure}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .