On Mon, Feb 23, 2009 at 17:52, Wolfgang Schuster wrote: > > Am 23.02.2009 um 17:21 schrieb Mojca Miklavec: > >> Hello, >> >> I did not try to analyze how the following macros work (they are too >> complex), but they somehow fail in mkiv. (I don't need the "F" >> kerning, so that portion of code may go away, but the macro itself is >> very very handy.) >> >> All I want is to have a macro that "converts" _{...} into \low{...} >> and ^{...} into \high{...} (or possibly enable using both at the same >> time). > > \startluacode > > thirddata = thirddata or { } > > function thirddata.molecule(text) > text = string.gsub(text,"_","\\low") > text = string.gsub(text,"%^","\\high") > tex.sprint(text) > end > > \stopluacode > > \def\molecule#1{\ctxlua{thirddata.molecule('#1')}} > > \starttext > \molecule{H_2SO_4} > \molecule{H_2^+} > \stoptext
Hello Wolfgang, thanks a lot for the very nice code :) :) :) The second example (H_2^+) does not return expected result - it should have been H\lohi{2}{+} instead, but I don't require such cases for the current document, so I guess that I'll just replace the old macro with this one for now in order not to get distracted with TeX problems too much :) Thanks again, Mojca ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________