[texhax] removing any macros from a string argument
Dieter Meinert
DMeinert at RosenInspection.net
Tue Mar 23 17:33:34 CET 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hi all,
I have a special problem I can't get managed:
I have a unique identifier (user-defined) in my documents,
which may or
may not include other macros (preferred \_, but anything
may be possible).
Now I need to remove all macros from this string in order
to use it as a
save label-generator.
I just don't find a way to remove all the macros from the
string.
% Example:
\newcommand{\identifier}[1]{
\newcommand{\myID}{#1}
\renewcommand{\identifier}{\myID}
}
\begin{document}
\identifier{abc\_def\macro{}ghi}
This is Document \myID, uniquely known as \identifier.
\begin{figure}
\caption{\label{\identifier:F1} my first image}
\includegraphics{firstImage.jpg}
\end{figure}
\end{document}
%end Example
Obviously this does not work, latex produces lots of error
messages
concerning the macros in the label. So I need to redefine
the label
that it looks like "abcdefghk", i.e. remove all macro names
from the string.
How do I have to redefine \identifier in the first place to
get this
result?
I already tried splitting the argument like
\process{\myID}
\long\def\process#1\@proc #1@@@
\long\def\@proc#1#2#3@@@{\def\myNewID{#1#3}
\renewcommand{\identifier}{\myNewID}
and similar constructs with defined #2, but each test
stopped at the
definition of the macros which is expanded somewhere in the
process.
Did anyone solve this problem ? (if it's in the FAQ it
completely
escaped my search, sorry)
tia
Dieter Meinert
++++++ Do not support SPAM ++++++ use only plaintext for
email ++++++
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
iQEVAwUBQGBYzrYBkYAdGmPFAQGESAf+Ir05t712Ju3QcM0iDQpGVmcqokPzoemi
uK772oGOxpduznBidXDYSXbuJ66LBXvBRzfqw3lNy1NDEimI2YtGryyjl1DZhVvm
HxhLT/uZ0eZTa3vwbzbZVuf7exrJpR+wnvtRjAsyY8flu2GXNujcr6BKwg/7TQ5q
Y4dyhccYz5/KxR2FD/zXbLD1hoF+4rN2g8f1QSvdf1XJhIF3O7QuuEyPx+ioOzMx
OVQq7iVYx0H7ZjUFx82HyFt0gJfsZu6KN+47GmE9SM1yUFwSa6+HCShaN//PqOwq
YMwsLX2Q1/VPvkQ4w85DFwbfKOmRINLFr5mShfkbaKu6QoJPG7kTWQ==
=cAFj
-----END PGP SIGNATURE-----
More information about the texhax
mailing list