I know that the TeX macro language, unlike most programming languages, allows nothing but letters in macro names. But what about the names within tikz?
MWE 1
Something like graph1 and graph2 seem to work.
\documentclass[tikz]{standalone}
\tikzset{
graph1/.pic={
\draw[very thick,color=black,domain=-1:9] plot (\x,{\x});
}
}
\tikzset{
graph2/.pic={
\draw[very thick,color=black,domain=-1:9] plot (\x,{0.5*\x});
}
}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (-0.99,-0.99) grid (8.99,8.99);
\pic{graph1};
\end{tikzpicture}
\begin{tikzpicture}
\draw[help lines] (-0.99,-0.99) grid (8.99,8.99);
\pic{graph2};
\end{tikzpicture}
\end{document}
MWE 2
Even 1 and 2 work.
\documentclass[tikz]{standalone}
\tikzset{
1/.pic={
\draw[very thick,color=black,domain=-1:9] plot (\x,{\x});
}
}
\tikzset{
2/.pic={
\draw[very thick,color=black,domain=-1:9] plot (\x,{0.5*\x});
}
}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (-0.99,-0.99) grid (8.99,8.99);
\pic{1};
\end{tikzpicture}
\begin{tikzpicture}
\draw[help lines] (-0.99,-0.99) grid (8.99,8.99);
\pic{2};
\end{tikzpicture}
\end{document}
Does it have any disadvantage of using numbers in tikz style names? I'm just asking because TeX doesn't allow numbers in macro names.
\expandafter\def\csname mymacro1\endcsname{Im a 1}, but it is true that you cannot use numbers in\newcommandor\defwithout the\csnametrick (easily). (If you usedeclare function, you can also use numbers, but not at the beginning of the function.) – Dec 19 '19 at 19:17