Befehl als optionales Argument für TikzPicture-Umgebung verwenden

Befehl als optionales Argument für TikzPicture-Umgebung verwenden
\begin{tikzpicture}[x={(0.5cm, 0cm)}, y={(0cm, 0.5cm)}, z={(0.25cm, 0.25cm)}]
...
\end{tikzpicture}

Werke

\newcommand{\kosXYZ}{[x=\{(0.5cm, 0cm)\}, y=\{(0cm, 0.5cm)\}, z=\{(0.25cm, 0.25cm)\}]}

\begin{tikzpicture}\kosXYZ
...
\end{tikzpicture}

Nicht

Wie und warum?

Antwort1

Warum funktioniert es nicht? \kosXYZwird nicht erweitert, wenn nach \begin{tikzpicture}dem optionalen Argument gesucht wird. Scheint so, als ob es so sein sollte.

Vielleicht so:

\newcommand\Exchange[2]{#2#1}%
\newcommand\Expandsecond[2]{\expandafter\Exchange\expandafter{#2}{#1}}%

\newcommand{\kosXYZ}{[x={(0.5cm, 0cm)}, y={(0cm, 0.5cm)}, z={(0.25cm, 0.25cm)}]}

\Expandsecond{\begin{tikzpicture}}{\kosXYZ}
...
\end{tikzpicture}

verwandte Informationen