(Andre: I'm sending this reply back to the ConTeXt list, because I think a fair bit of my reply might be generally useful to other people who want to try to convert LaTeX packages to ConTeXt. I hope that's ok!) At 01:58 PM 9/13/2005, Andre van der Vlies wrote:
Brooks Moses said:
Meanwhile, though, after looking through the code, I don't think there's actually much need to modify the executable. Lgrind mostly doesn't write LaTeX (which is why Andre found it so obscure) -- it writes TeXcode that uses its own simple commands, which are then defined in lgrind.sty. To use Lgrind in ConTeXt, one needs to translate the style file into a t-lgrind.tex, at which point the same Lgrind output files can be used in both systems.
Hmmm, that sure sounds promising. I've just recently using ConTeXt, this week actually. I am trying to rebuild a, few paged, LaTeX document which is typical for me...
I think that renaming the 'sty' file will not be enough :-/
Not really, no. Though it's potentially a start. What you'll need to do then is to translate all of the LaTeX bits in it to ConTeXt bits. (Also, it may be easier to start with the lgrind.dtx file, since that has all the comments that explain what's going on.)
Thus, I produce a t-lgrind.tex, which I can \input and henceforth use something like \plasterthis{fine.grind}?
I should perhaps have explained that more thoroughly. ConTeXt has "modules", which are roughly equivalent to LaTeX's packages; the filename "t-lgrind.tex" indicates a module. (Specifically, the "t-" prefix indicates that it's a "third-party module", which is everything other than the modules that are actually part of ConTeXt itself.) Thus, you'd use it with \usemodule[lgrind] rather than \input. It amounts to pretty much the same thing, except ConTeXt does keep track of things so as not to load it twice, and things like that. One big difference is that LaTeX puts all package code in a \makeatletter / \makeatother block. ConTeXt doesn't do this, so you need to put those in manually -- the ConTeXt equivalent is \unprotect / \protect (which also allow ! and ? in macro names, along with @).
Or, am I on the wrong track???
I sure need to to a lot of reading...
Feel free to ask questions, too! Some information to get you started: ===== An introduction to translating packages to modules ===== (As exemplified by a detailed discussion of lgrind.dtx) First, copy everything in lgrind.dtx from about line 609 ("Implementation of Lgrind") to the end of the file into t-lgrind.tex. Put a \unprotect command at the beginning, and a \protect command at the end, so that you can use @ in macro names. \newcommand and \renewcommand are LaTeX-specific. The easiest way to deal with this is to simply replace it with TeX \def macros, though that loses the error messages that come from checking whether the command exists or not. \DeclareOption is LaTeX's way of handling package options. For a first pass, it's probably easiest to just delete these. (Or, if you usually use the option, then include the option's code directly.) All of the \sffamily, \rmfamily, \itshape, and other font formatting commands on lines 727-736 are LaTeX-specific; you can replace them with the ConTeXt equivalents, which are on a Wiki page on "Basic Text Formatting". I'm not sure whether \normalfont (lines 893, 901, and so forth) is LaTeX-specific or not. You might have to replace that with the ConTeXt equivalent. At line 818, the "lgrind" environment is defined. The \newenvironment command is definitely a LaTeXism; you'll want to replace that with definitions for \startlgrind and \stoplgrind. The use of the minipage and figure environments in lines 1060 or so and later are going to require a bit of looking at to figure out how to best replace them with ConTeXt equivalents. Luckily, it looks like these are some of the "advanced" bits, so you could just not worry about this until you've got the basic lgrind environment working. And I think that should do it. There may be a few other LaTeXisms in the file that I missed, but a bit of testing should find those.... ===== end ===== Probably by the time you've done that, you'll have had quite a thorough introduction to ConTeXt! :) - Brooks