Is it possible to define a multipart variable and then check for its definition and use its multiple parts later? Here's what I mean:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{etoolbox}
\begin{document}
%Define macro
\def\myMacro{
%Check for multipart variable definition
\ifdef{\VariableOne}{
##1
##2
##3
}{}
#1
}
%Define multipart variable
\def\VariableOne#1#2#3{
{1}
{2}
{3}
}
\myMacro{4}
\end{document}
I know this task can be accomplished this way:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{etoolbox}
\begin{document}
\def\myMacro#1{
\ifdef{\VariableOne}{
\foreach \x/\y/\z in \VariableOne{
\x
\y
\z
}
}{}
#1
}
\def\VariableOne{1/2/3}
\myMacro{4}
\end{document}
I also know that you could just pass in all of the variables to \myMacro
, but I'm curious if this is doable using the methods in the first block of code.
\VariableOne
. – Kevin Gregory May 25 '18 at 15:18\mymacro{4}
would select the 4th but your example only has three fields, so what is the intended behaviour of\mymaco{4}
? – David Carlisle May 25 '18 at 15:29\myMacro
is twofold: First, it checks to see if\VariableOne
is defined, and if it is, the macro prints out the three parts of the variable. If\VariableOne
isn't defined, it just moves on. Second, the macro just prints out the argument passed to it. In this case, just the 4. – Kevin Gregory May 25 '18 at 15:35#1
argument at all, and just wrote\myMacro 4
– David Carlisle May 25 '18 at 15:38