i can't figure out how to solve my issue. A little bit Background info so you understand, why I would do such things: I have some variables that contain numbers. Because this is not possible (as far as i know) i did name then like: VoltageI VoltageII etc. I now want to process them in a for loop with the loopcounter. This works nice for figures i named figure1 etc. ->
includegraphics{path/figure\arabic{counter}}.
My Goal is to Substitute the Counter (in this case 1) with a I and so on. I already wrote a new command:
\newcommand{\Romannum}{%
\ifnum #1=1
#1I
\fi
}
For the Code in my text:
\Romannum{Profile}{1}
This prints me:
ProfileI
as intended. But I Need the Output not as a text but as a variable Name to Display the Content of the variable->
\ProfileI
Is this even possible or is there an easier way to get numbers in variable names?
Thank you!
Here an example (it doesnt compile due to the lack of the image but it makes my question more clear.)
\documentclass{article}
\usepackage{forloop}
\newcommand{\Romannum}[2]{%
\ifnum #2=1
#1I
\fi
\ifnum #2=2
#1II
\fi
}
\newcommand{\ProfileI}{Some text is written here.}
\newcommand{\ProfileII}{Some text is written here.}
\newcounter{profilecounter}
\setcounter{profilecounter}{1}
\begin{document}
\forloop{profilecounter}{1}{\value{profilecounter} < 3}{%
\begin{figure}[htbp]
\centering
\includegraphics[width = \textwidth]{Profil\arabic{profilecounter}.png} %This works
\caption{Profile \arabic{profilecounter} -~\Romannum{Profile}{profilecounter}}%This doesnt work (it writes ProfileI. I'd need \ProfileI to acces the string in the variable.
\end{figure}
}
\end{document} }
\ProfileI
then?\csname text\endcsname
, refers to a macro equivalent to\text
. Likewise,\csname\Romannum{Profile}{1}\endcsname
could be used to refer to a macro\ProfileI
.\newcommand{\Romannum}[1]{% \ifnum\value{#1}=1 \csname #1I\endcsname \fi }
if#1
will be the counter ?\newcommand{\Romannum}[1]{% \csname #1\Roman{#1}\endcsname }
? -- Actually, I don't understand what you want to achieve here