mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
enable reLyX to recognise natbib citations
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6071 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3c6341496f
commit
a17cf1b3f4
@ -3,6 +3,15 @@
|
||||
* 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.
|
||||
|
@ -218,6 +218,32 @@ my $MathEnvironments = "(math|displaymath|xxalignat|(equation|eqnarray|align|ali
|
||||
# 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
|
||||
@ -417,7 +443,8 @@ sub basic_lyx {
|
||||
} # 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,
|
||||
@ -573,7 +600,7 @@ sub basic_lyx {
|
||||
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 ";
|
||||
@ -808,7 +835,8 @@ sub basic_lyx {
|
||||
|
||||
# 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}) {
|
||||
|
@ -294,11 +294,22 @@ sub translate_preamble {
|
||||
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 =(
|
||||
|
@ -69,6 +69,54 @@ $$
|
||||
\bibliographystyle{}
|
||||
\c{}
|
||||
\cite[]{}
|
||||
|
||||
% Natbib citations can usually have two optional args, but LyX currently
|
||||
% supports only one.
|
||||
\citet[]{}
|
||||
\Citet[]{}
|
||||
\citet*[]{}
|
||||
\Citet*[]{}
|
||||
%\citet[][]{}
|
||||
%\Citet[][]{}
|
||||
%\citet*[][]{}
|
||||
%\Citet*[][]{}
|
||||
|
||||
\citealt[][]{}
|
||||
\Citealt[][]{}
|
||||
\citealt*[][]{}
|
||||
\Citealt*[][]{}
|
||||
%\citealt[][{}
|
||||
%\Citealt[]{}
|
||||
%\citealt*[]{}
|
||||
%\Citealt*[]{}
|
||||
|
||||
\citep[][]{}
|
||||
\Citep[][]{}
|
||||
\citep*[][]{}
|
||||
\Citep*[][]{}
|
||||
%\citep[]{}
|
||||
%\Citep[]{}
|
||||
%\citep*[]{}
|
||||
%\Citep*[]{}
|
||||
|
||||
\citealp[]{}
|
||||
\Citealp[]{}
|
||||
\citealp*[]{}
|
||||
\Citealp*[]{}
|
||||
%\citealp[][]{}
|
||||
%\Citealp[][]{}
|
||||
%\citealp*[][]{}
|
||||
%\Citealp*[][]{}
|
||||
|
||||
\citeauthor[]{}
|
||||
\Citeauthor[]{}
|
||||
\citeauthor*[]{}
|
||||
\Citeauthor*[]{}
|
||||
|
||||
\citeyear[]{}
|
||||
\citeyearpar[]{}
|
||||
%\citeyearpar[][]{}
|
||||
|
||||
\cline{ - }
|
||||
\d{}
|
||||
\documentclass[]{}[]
|
||||
|
Loading…
Reference in New Issue
Block a user