2

Issue

How can I get proper text expansion for text=\somevariable in a tikz text decoration. I think I have an expansion problem here.

  1. Set \releasedate
  2. Extract year from \releasedate in \manufacturedate
  3. Set \manufacturedate as value to text= in decoration={}

I attempted to solve this with

\begingroup\expandarg\manufacturedate{}\endgroup. <- unsure about this.

Example

\documentclass{article}
\usepackage{fontspec}
\usepackage{xstring}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.text}

\newcommand\textthatpath[1]{%
\begin{tikzpicture}[node distance=10cm]
    \node (data) {Data};
    \node [right=of data] (app) {App};
    % Lines
    \draw [<->,postaction={decorate,decoration={text along path,text align=center,text={#1}}}]  (data) to[out=90,in=90] (app);
\end{tikzpicture}
}%
\newcommand{\releasedate}{2015-03-27}
\newcommand\manufacturedatetext{%
    \StrLeft{\releasedate}{4}[\productiondate]
    \productiondate
}%

\newcommand\decotext{© Specialized Services GmbH \manufacturedatetext{}} 

\begin{document}
    %\textthatpath{\decotext{}} % This does not work, but I am hoping to get it working.
    \manufacturedatetext{}  % This prints \productiondate
\end{document}
3

You can tell xstring to do the expansion for you via \fullexpandarg or another lighter setting described in the manual.

\documentclass{article}
\usepackage{fontspec}
\usepackage{xstring}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.text}

\newcommand{\releasedate}{2015-03-27}
\newcommand\manufacturedatetext{%
{\fullexpandarg
    \StrLeft{\releasedate}{4}[\productiondate]\productiondate%
}
}%
\newcommand\decotext{© Specialized Services GmbH \manufacturedatetext{}} 


\newcommand\textthatpath[1]{%
\begin{tikzpicture}[node distance=10cm]
    \node (data) {Data};
    \node [right=of data] (app) {App};
    % Lines
    \draw [<->,postaction={decorate,decoration={text along path,text align=center,text={#1}}}]  (data) to[out=90,in=90] (app);
\end{tikzpicture}%
}


\begin{document}
    \textthatpath{\decotext} % This does not work, but I am hoping to get it working.
    \manufacturedatetext{}  % This prints \productiondate
\end{document}

enter image description here

| improve this answer | |
  • What a relief. That was driving me nuts! – Jonathan Komar Mar 27 '15 at 12:43

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.