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

Uwe Lück uwe.lueck at web.de
Wed Apr 22 20:48:29 CEST 2009

I agree that this should leave the list, but you just have made a very 
good, important, interesting point ...

At 19:14 22.04.09, Toby Cubitt wrote:
>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:
>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.

fifinddo provides the same functionality, see section 5.2, pp. 15f. of


This is used in makedoc.sty to activate the code/comment distinction only 
after a certain number of lines, so the legal informations in the file 
header is typeset verbatim.

This needs, of course, that cleveref outputs (also for "poorman-tex", as it 
seems to do for sed) a report of \selectlanguage.

> > 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.

Fine, thanks, so long,


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

More information about the texhax mailing list