I'm attempting to create documents of a priori unknown length that is determined by a set of conditions. I'm generating LaTeX variables, including conditional variables, using Python. Within a variables LaTeX file, I have something resembling:
\newcommand{\VariableList}{VariableOne,VariableTwo}
\newcommand{\VariableOneSubOne}{SomeValueOne}
\newcommand{\VariableOneSubTwo}{SomeOtherValueOne}
\newif\ifVariableOneCondOne
\VariableOneCondOnetrue
\newcommand{\VariableTwoSubOne}{SomeValueTwo}
\newcommand{\VariableTwoSubTwo}{SomeOtherValueTwo}
\newif\ifVariableTwoCondOne
\VariableTwoCondOnefalse
Where the number of variables are not known. I loop over each variable and have some text that includes the values dynamically defined by the variables.
\foreach \n in \VariableList{
Here is some text with \inputnum{\n}{SubOne} and \inputnum{\n}{SubTwo}.
}
Where I have defined:
\newcommand{\inputnum}[2]{\expandafter\csname #1#2\endcsname}
How can I define a similar command to take advantage of the conditional variables I have defined above? For example, I tried:
\newcommand{\inputcondnum}[2]{\expandafter\csname if#1#2\endcsname}
using the logic that the macro would replace
\inputcondnum{\n}{CondOne}
with the following
\ifVariableOneCondOne
but that does not seem to work. Any suggestions on how to use these dynamically generated conditional variables?
Here is a minimum example:
\documentclass{article}
\usepackage{pgffor}
% Command to generate variables
\newcommand{\inputnum}[2]{\expandafter\csname #1#2\endcsname}
\newcommand{\inputcondnum}[2]{\expandafter\csname if#1#2\endcsname}
% Variable definitions
\newcommand{\VariableList}{VariableOne,VariableTwo}
\newcommand{\VariableOneSubOne}{SomeValueOne}
\newcommand{\VariableOneSubTwo}{SomeOtherValueOne}
\newif\ifVariableOneCondOne
\VariableOneCondOnetrue
\newcommand{\VariableTwoSubOne}{SomeValueTwo}
\newcommand{\VariableTwoSubTwo}{SomeOtherValueTwo}
\newif\ifVariableTwoCondOne
\VariableTwoCondOnefalse
\begin{document}
\foreach \n in \VariableList{
Here is some text with \inputnum{\n}{SubOne} and \inputnum{\n}{SubTwo}.
\inputcondnum{\n}{CondOne} Include this text if true \else Include this text if false. \fi
}
\end{document}