* kbd/polski.kmap: new keymap, which assumes that you have a
non-Polish keyboard.
+2003-02-07 Angus Leeming <leeming@lyx.org>
+
+ * BasicLyX.pm: enable reLyX to recognise natbib citations.
+
+ * MakePreamble.pm: if '\usepackage{natbib}' is found, activate
+ LyX's natbib support.
+
+ * reLyX/syntax.default: add natbib citation commands.
+
2003-02-07 Angus Leeming <leeming@lyx.org>
* lyx2lyx/lyx2lyx: enable the debug level to be set.
# ListLayouts may have standard paragraphs nested inside them.
my $ListLayouts = "Itemize|Enumerate|Description";
+# passed a string and an array
+# returns true if the string is an element of the array.
+sub foundIn {
+ my $name = shift;
+ return grep {$_ eq $name} @_;
+}
+
+my @NatbibCommands = map {"\\$_"} qw(citet citealt citep citealp citeauthor);
+
+# passed a string.
+# returns true if it is a valid natbib citation
+sub isNatbibCitation {
+ my $name = shift;
+
+ # These two have a single form
+ return 1 if ($name eq '\citeyear' or $name eq '\citeyearpar');
+
+ # Natbib citations can start with a 'C' or a 'c'
+ $name =~ s/^\\C/\\c/;
+ # The can end with a '*'
+ $name =~ s/\*$//;
+ # Is this doctored string found in the list of valid commands?
+ return foundIn($name, @NatbibCommands);
+
+}
+
##################### PARSER INVOCATION ##################################
sub call_parser {
# This subroutine calls the TeX parser & translator
} # end special handling for \@
# Handle tokens that LyX translates as a "LatexCommand" inset
- } elsif (grep {$_ eq $name} @LatexCommands) {
+ } elsif (foundIn($name, @LatexCommands) ||
+ isNatbibCitation($name)){
&CheckForNewParagraph; #Start new paragraph if necessary
print OUTFILE "$pre_space\n\\begin_inset LatexCommand ",
$name,
print "$name" if $debug_on;
# Handle things that LyX translates as a "LatexCommand" inset
- if (grep {$_ eq $name} @LatexCommands) {
+ if (foundIn($name, @LatexCommands) || isNatbibCitation($name)){
&CheckForNewParagraph; #Start new paragraph if necessary
print OUTFILE "$pre_space\n\\begin_inset LatexCommand ";
# Handle things that LyX translates as a "LatexCommand" inset
# or "Include" insets
- if (grep {$_ eq $name} @LatexCommands, @IncludeCommands) {
+ if (foundIn($name, @LatexCommands, @IncludeCommands) ||
+ isNatbibCitation($name)){
print OUTFILE "\}\n\n\\end_inset \n\n";
} elsif (exists $ReadCommands::ToLayout->{$name}) {
my $up;
foreach $up (keys %Usepackage_Table) {
$Latex_Preamble =~ s/\\usepackage\{$up\}\s*// && do {
- $LyX_Preamble .= "$Usepackage_Table{$up}";
- $LyX_Preamble .= "\n" unless ($Usepackage_Table{$up} eq "");
+ my $tmp = $Usepackage_Table{$up};
+ $LyX_Preamble .= join($tmp, "\n") unless ($tmp eq '');
+ #$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*//) {
+ print "matched it!\n";
+ $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 =(