]> git.lyx.org Git - lyx.git/blobdiff - lib/reLyX/MakePreamble.pm
clean up french language handling
[lyx.git] / lib / reLyX / MakePreamble.pm
index 5568c78627fc429922807ad0cf9f42edd54aa43f..4c16c294f581c7d680d9e4f711c80417cc7c3963 100644 (file)
@@ -1,4 +1,4 @@
-# This file is part of reLyX. 
+# This file is part of reLyX.
 # Copyright (c) 1998-9 Amir Karger karger@post.harvard.edu
 # You are free to use and modify this code under the terms of
 # the GNU General Public Licence version 2 or later.
@@ -26,8 +26,8 @@ sub split_preamble {
     $debug_on = (defined($main::opt_d) && $main::opt_d);
     # -c option?
     $true_class = defined($main::opt_c) ? $main::opt_c : "";
-    my $zzz = $debug_on 
-        ? " from LaTeX file $InFileName into $PreambleName and $OutFileName" 
+    my $zzz = $debug_on
+        ? " from LaTeX file $InFileName into $PreambleName and $OutFileName"
        : "";
     warn "Splitting Preamble$zzz\n";
 
@@ -148,7 +148,8 @@ sub translate_preamble {
 #}
 
     # Write first line of the lyx file
-    $LyX_Preamble .= "\#LyX 1.2 created this file. For more info see http://www.lyx.org/\n";
+    $LyX_Preamble .= "\# The reLyX bundled with LyX 1.3 created this file.\n" .
+       "# For more info see http://www.lyx.org/\n";
 
     # Print \lyxformat.
     $LyX_Preamble .= "\\lyxformat $Format\n";
@@ -164,7 +165,7 @@ sub translate_preamble {
     warn "Uncommented text before \\documentclass command ignored!\n"if $ignore;
     print "Ignored text was\n------\n$ignore------\n" if $debug_on && $ignore;
 
-    # concatenate all the extra options until the required argument to 
+    # concatenate all the extra options until the required argument to
     # \documentclass, which will be in braces
     until (eof(PREAMBLE) || /\{/) {
         my $instr = <PREAMBLE>;
@@ -293,12 +294,20 @@ sub translate_preamble {
 
     my $up;
     foreach $up (keys %Usepackage_Table) {
-       $Latex_Preamble =~ s/\\usepackage\{$up\}\s*// && do {
+       $Latex_Preamble =~ s/^\s*\\usepackage\{$up\}\s*// && do {
            $LyX_Preamble .= "$Usepackage_Table{$up}";
            $LyX_Preamble .= "\n" unless ($Usepackage_Table{$up} eq "");
        }
     }
 
+    # Natbib is a little more complex than that.
+    if ($Latex_Preamble =~ s/\\usepackage(.*)\{natbib\}\s*//) {
+       $LyX_Preamble .= "\\use_natbib 1\n\\use_numerical_citations ";
+       $LyX_Preamble .= ($1 =~ /numbers/) ? "1\n" : "0\n";
+    } else {
+       $LyX_Preamble .= "\\use_natbib 0\n\\use_numerical_citations 0\n";
+    }
+
     ## Handle geometry options
     ## The custom paper missing from the options list since it involves two parameters
     my %Geometry_Options =(
@@ -342,7 +351,7 @@ sub translate_preamble {
     }
 
     ## Paragraph skip or indentation
-    if ( $Latex_Preamble =~ 
+    if ( $Latex_Preamble =~
         s/\\setlength\\parskip\{\\(.*)amount\}\s*\\setlength\\parindent\{0pt\}//) {
        $LyX_Preamble .= "\\paragraph_separation skip\n";
        $LyX_Preamble .= "\\defskip $1\n";