I am trying to generate figure labels with macro like this:
Code: Select all
\newcommand{\getLabel}[3]{
\newcommand{\Stat}{\StrLeft{#1}{3}}
fig:{\Stat}Re#2DOF#3 %1st 3 letters of #2
}
Code: Select all
\label{\getLabel{recirculation point}{50}{4M}}
The 1st parameter has space (I suspect space is not allowed to be part of label?), therefore I use \StrLeft to get first 3 letters for the label. Using only 2nd and 3rd parameters is not enough to generate unique label. It doesn’t really matter how the generated label will look like as long as it is unique (I expect to have a 100 page document with at least 50 figures).
The goal is to have a macro that plots figures and generates caption and label based on few parameters. Here is its code:
Code: Select all
\newcommand{\myplot}[4]{
\begin{figure}[h!]
\label{\getLabel{#2}{#3}{#4}}
\centering
\includegraphics[width=\linewidth]{#1}
\caption{#2 for #4 DOF mesh, Re #3.}
\end{figure}
}
Argument of \caption@@@withoptargs has an extra }.
Extra }, or forgotten \endgroup. ...@d = *\def \par }{ on input line 336}}{9}} (followed by: )
Extra }, or forgotten \endgroup. \newlabel{ \let \reserved@d = *\def \par } (followed by: {{\caption@xref { \let \reser...)
Extra }, or forgotten \endgroup. \newlabel{ \let \reserved@d = *\def \par } (followed by: {{\caption@xref { \let \reser...)
and many more. When I remove \StrLeft, all errors disappear.
Is there a way to implement this?
Can figure label contain digits and/or spaces?
Thank you.