Hi Folks,
lyx is really great, but
there it is quite choosy at accepting latex files.
I have written a small pearl program
which changes some older things as {\bar ..}
into \overline{ .. } and also environments
lemma -> lem, theorem -> thm etc. (necessary
for amsbook style, otherwise the environments are
completely in tex-mode!). Maybe it can inspire how
to improve the next version of texToLyx-translator.
All the best,
Artur Andrzejak
----------------------------
#!/usr/local/bin/perl5 -w
# Some help for tex to LYX conversion
# Artur Andrzejak, August 1999
# paragraph mode
$/ = "";
while ($in = <>) {
&make_substitution;
print $in;
};
sub make_substitution {
# the input is $in
# substitute the documentclass to amsbook
$in =~ s/\\documentclass(.*?)\{(.*?)\}/\\documentclass$1\{amsbook\}/g;
# substitute some environment names
$in =~ s/\\begin\{lemma\}/\\begin\{lem\}/g;
$in =~ s/\\end\{lemma\}/\\end\{lem\}/g;
$in =~ s/\\begin\{theorem\}/\\begin\{thm\}/g;
$in =~ s/\\end\{theorem\}/\\end\{thm\}/g;
$in =~ s/\\begin\{corollary\}/\\begin\{cor\}/g;
$in =~ s/\\end\{corollary\}/\\end\{cor\}/g;
$in =~ s/\\begin\{proposition\}/\\begin\{prop\}/g;
$in =~ s/\\end\{proposition\}/\\end\{prop\}/g;
$in =~ s/\\textbf\{Proof:\}/\\begin\{proof\}/g;
$in =~ s/\$\\square\$/\\end\{proof\}/g;
$in =~ s/\\hfill/ /g;
# substitute \cal, \bar, \choose etc.
$in =~ s/\{\\cal(.*?)\}/\{\\mathcal\{$1\}\}/gs;
$in =~ s/\{\\bar(.*?)\}/\{\\overline\{$1\}\}/gs;
$in =~ s/\{([^\$\{\}]*?)\\choose(.*?)\}/\\binom\{$1\}\{$2\}/gs;
$in =~ s/\\text\{(.*?)\}/\\textrm\{$1\}/gs;
$in =~ s/\\mbox\{(.*?)\}/\\textrm\{$1\}/gs;
return;
};