# and translates it to LaTeX.

use strict;

my debugon;#package - widevariablesetif - doptionisgivenmytrue_class; # which textclass to use (if -c option is given)

sub split_preamble # Split the file into two files, one with just the preamble # Simply copy stuff verbatim, saving translation for later # Skip the LyX-generated portion of the preamble, if any. (Otherwise, # when you try to "view dvi" in LyX, there will be two copies of the # preamble matter, which will break LyX. my ( InFileName,PreambleName, OutFileName) = (shift, shift, shift);my(a, b,c); my forget = 0;

#Was - doptiongiven?debug_on = (defined( main : : optd) & &main::opt_d); # -c option? trueclass = defined (main::opt_c) ? main : : optc : "";myzzz = debugon?"fromLaTeXfileInFileName into PreambleNameandOutFileName" : ""; warn "Splitting Preamble zzz$\n$";

open(INFILE," <InFileName") or die "problem opening InFileName :!"; open (PREAMBLE, "> PreambleName")ordie"problemopeningPreambleName: !$\n$";open(OUTFILE," >OutFileName") or die "problem opening OutFileName :!";

# Copy everything up to "" into the preamble while (<INFILE>) if (s///) (a,b, c) = (`, & ,'); # save for later last; # In real life, there should never be Textclass specific stuff unless # there is also LyX specific. But it can't hurt to test for both. forget = 1ifm/m/printPREAMBLE_ unless forget;forget=0 if m/ die "Didn't find
begindocument command!" unless defined b;#There*could*beapreamblecommandonthesamelineas!printPREAMBLEa; print "Put preamble into file PreambleName$\n$"ifdebug_on;

# Copy everything else into another file # Ignore anything after '