[texhax] Low-level TeX question: string substitution macro

Toby Cubitt tsc25 at cantab.net
Wed Apr 22 19:14:33 CEST 2009


Uwe Lück wrote:
>> In the latest cleveref version (not yet on CTAN), I also use sed
>> addresses
>> to cope with babel language changes. I don't know how easy that would be
>> to replicate with fifinddo.
> 
> It seems if cleveref is clever enough to write to files under babel,
> then fifinddo needn't care about babel anymore.

Just to clarify, the babel issue is that there might have to be one
substitution for, say, "\cref{eq1}" at one location in the source file,
and a *different* substitution for exactly the same string "\cref{eq1}" at
a different location in the file, because the language has changed.

Just consider the following fragment:

...
\selectlanguage{english}
\cref{eq1}
\selectlanguage{german}
\cref{eq1}
...

Sed can easily accommodate this using line-number rule addresses. Never
having used them, I have no idea how easy it would be to do using fifinddo
or other (La)TeX string substitution packages.


> I wouldn't say "patch". cleveref should just have an additional option
> "poorman-tex" that writes (La)TeX-like output instead of sed output --
> hoping there will be some TeX package that can make use of it. 

Implementing this would require copying and modifying the poorman code in
cleveref.dtx to create the new option, and that code involves messing
around with cleveref internals. I would prefer (insist?) that any such
changes are sent to me as a patch against the latest cleveref.dtx
available from my web site (www.dr-qubit.org/latex.php). That way I can
easily merge it with any local changes I might have made to cleveref but
not yet released.

(I suggest taking any further discussion off-list, as it's probably
becoming uninteresting to most list subscribers.)

All the best,

Toby


More information about the texhax mailing list