kosmikus/lhs2tex

A more modular approach (not needing to run on the main tex file)?

Closed this issue · 2 comments

Lhs2TeX assumes control over my TeXing [1], as it wants to run on the main file processing all code environments (and inline Haskell) in one go. I'd wish one could use it in a more modular way, like running it on some lhs files which are part of a larger project, and then inputting the generated tex files into the main file. Latex macros Lhs2TeX depends on could be included e.g. via some usepackage directive. (The agda --latex mode works in this style; it produces LaTeX files but not a preamble.)

This feature request might be similar to #47.

[1] For instance, every occurrence of @ is interpreted by Lhs2TeX, even in array format strings. I can of course put parts that Lhs2TeX should not touch in separate files. But I'd like it the other way round, to put the parts that Lhs2TeX should touch in separate files, especially if 90% of my document do not require the services of Lhs2TeX.

Don't the first two FAQ entries address this scenario?

That would be:

  • The document consists of multiple files. Can lhs2TEX be used?
    One option is to use %include rather than LATEX commands to include all files in the master file. The other is to process all files that contain code and the master file with lhs2TEX. All files to be processed with lhs2TEX must contain an %include lhs2TeX.fmt (or %include polycode.fmt) statement. From version 1.11 on, including lhs2TeX.sty is no longer necessary.
  • Yes, but the master file should be pure LATEX.
    Create a file mylhs2tex.lhs with just one line, namely %include lhs2TeX.fmt. Process that file with lhs2TEX, using the options you also use for the other included files. Call the resulting file mylhs2tex.sty and say \usepackage{mylhs2tex} at the beginning of your master file.

Thanks, got to try this!