I'm trying to generate page references inside a command that defines a row of a table, with the name of the label being referenced generated as a result of some string maniupulation using stringstrings. Here's a much simplified version of what I'm trying to do, generating a reference to the OPSFOO label based on a command parameter of FO_O, with the string processing removing underscores and prepending OPS:
\documentclass{article}
\usepackage{stringstrings}
\newcommand{\opind}[2]{
\convertchar[q]{OPS#2}{\_}{}
#1 & #2 & \pageref{\thestring} \\
}
\begin{document}
\begin{table}[h]
\begin{tabular}{l l l}
\opind{1}{FO\_O} \\
\end{tabular}
\end{table}
\clearpage
\label{OPSFOO} FOO \\
\end{document}
That fails with the error "! Undefined control sequence. \thestring"
I thought perhaps there was something wrong with using \thestring inside a command, so I tried putting it directly into the table entry like this:
\begin{table}[h]
\begin{tabular}{l l l}
\convertchar[q]{OPSFO\_O}{\_}{}
1 & FO\_O & \pageref{\thestring} \\
\end{tabular}
\end{table}
But that gets essentially the same error. So I started wondering if there's just a problem with using \thestring as an argument to \pageref. Apparently not; if I do the string manipulation outside the table, everything works fine:
\convertchar[q]{OPSFO\_O}{\_}{}
\begin{table}[h]
\begin{tabular}{l l l}
1 & FO\_O & \pageref{\thestring} \\
\end{tabular}
\end{table}
Is there anything I can do to get the string manipulation and the use of \pageref{\thestring} to work in the command that's called inside the table, as in the first code listing above?
\thestring
is expanded locally in the first table cell, but then lost in the 3rd. one, since table cells aregroups
– user31729 Nov 1 '14 at 6:15#2
? There can be much faster ways to solve your problem. Is lowercasing connected to this? Perhaps it's better if you state your complete problem. – egreg Nov 1 '14 at 9:56