Edwin Leuven wrote:
>> This says that \cite can take an optional arg but \nocite cannot. I don't
>> know about the natbib commands. Perhaps you could do some research for
>> me. In the meantime, does adding these to syntax.default improve the
>> situation?
>
> I does. I also added
>
> \citet[]{}
>
> the only remaining thing is that reLyX doesn't tell lyx to use natbib:
>
> \use_natbib 1
> \use_numerical_citations 0
>
> so this must still be set by hand
>
> citet* and Citet* don't work (I added them, naively, to syntax.default but
> apparently this is not enough)
>
> Ed.
Edwin, apply the attached patch to a clean reLyX.
Please also add an enhancement request to Bugzilla and attach the patch.
Rgds,
--
Angus
Index: lib/reLyX/BasicLyX.pm
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/BasicLyX.pm,v
retrieving revision 1.5
diff -u -p -r1.5 BasicLyX.pm
--- lib/reLyX/BasicLyX.pm 7 Jan 2003 14:30:52 -0000 1.5
+++ lib/reLyX/BasicLyX.pm 6 Feb 2003 17:25:42 -0000
@@ -187,6 +187,8 @@ my %TextTransTable = (
my @LatexCommands = map {"\\$_"} qw(ref pageref label cite bibliography
index printindex tableofcontents
listofalgorithms listoftables listoffigures);
+my @NatbibCommands = map {"\\$_"} qw(citet citealt citep citealp citeauthor
+ citeyear citeyearpar);
my @IncludeCommands = map {"\\$_"} qw(input include);
# Included postscript files
# LyX 1.0 can't do \includegraphics*!
@@ -218,6 +220,26 @@ my $MathEnvironments = "(math|displaymat
# 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;
+ my @array = @_;
+ return grep {$_ eq $name} @array;
+}
+
+# passed a string.
+# returns true if it is a valid natbib citation
+sub isNatbibCitation {
+ my $name = shift;
+ my $array_element = $name;
+ $array_element =~ s/^\\C/\\c/;
+ $array_element =~ s/\*$//;
+
+ my $ret = foundIn($array_element, @NatbibCommands);
+ return $ret; #foundIn($array_element, @NatbibCommands);
+}
+
##################### PARSER INVOCATION ##################################
sub call_parser {
# This subroutine calls the TeX parser & translator
@@ -381,7 +403,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,
@@ -537,7 +560,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 ";
@@ -772,7 +795,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}) {
Index: lib/reLyX/syntax.default
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/syntax.default,v
retrieving revision 1.3
diff -u -p -r1.3 syntax.default
--- lib/reLyX/syntax.default 28 Oct 2002 09:52:39 -0000 1.3
+++ lib/reLyX/syntax.default 6 Feb 2003 17:25:43 -0000
@@ -69,6 +69,34 @@ $$
\bibliographystyle{}
\c{}
\cite[]{}
+\citet{}
+\citealt{}
+\citep{}
+\citealp{}
+\citeauthor{}
+\citeyear{}
+\citeyearpar{}
+\Citet{}
+\Citealt{}
+\Citep{}
+\Citealp{}
+\Citeauthor{}
+\Citeyear{}
+\Citeyearpar{}
+\citet*{}
+\citealt*{}
+\citep*{}
+\citealp*{}
+\citeauthor*{}
+\citeyear*{}
+\citeyearpar*{}
+\Citet*{}
+\Citealt*{}
+\Citep*{}
+\Citealp*{}
+\Citeauthor*{}
+\Citeyear*{}
+\Citeyearpar*{}
\cline{ - }
\d{}
\documentclass[]{}[]