问题

问题

问题

如何在文本装饰text=\somevariable中获得正确的文本扩展tikz?我认为我这里有一个扩展问题。

  1. \releasedate
  2. \releasedate从中提取年份\manufacturedate
  3. 设置\manufacturedatetext=decoration={}

我尝试用以下方法解决这个问题

\begingroup\expandarg\manufacturedate{}\endgroup.<- 对此不确定。

例子

\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}

答案1

您可以通过或手册中描述的其他更轻的设置来xstring为您进行扩展。\fullexpandarg

\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}

在此处输入图片描述

相关内容