Re: [patch 13x]: reLyX natbib citations try 2
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Fixes the mess in syntax.default. -- Angus This one does not look right: +\citealt[][{} Once this is fixed, you can apply it to 1.3.x. JMarc
Re: [patch 13x]: reLyX natbib citations try 2
Jean-Marc Lasgouttes wrote: Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Fixes the mess in syntax.default. -- Angus This one does not look right: +\citealt[][{} Once this is fixed, you can apply it to 1.3.x. JMarc What would I do without you? ;-) -- Angus
Re: [patch 13x]: reLyX natbib citations try 2
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus What would I do without you? ;-) Apply patches faster :) JMarc
Re: [patch 13x]: reLyX && natbib citations try 2
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> Fixes the mess in syntax.default. -- Angus This one does not look right: +\citealt[][{} Once this is fixed, you can apply it to 1.3.x. JMarc
Re: [patch 13x]: reLyX && natbib citations try 2
Jean-Marc Lasgouttes wrote: >> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: > > Angus> Fixes the mess in syntax.default. -- Angus > > This one does not look right: > +\citealt[][{} > > Once this is fixed, you can apply it to 1.3.x. > > JMarc What would I do without you? ;-) -- Angus
Re: [patch 13x]: reLyX && natbib citations try 2
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> What would I do without you? ;-) Apply patches faster :) JMarc
Re: [patch 1.3.x] enable reLyX to handle natbib citations
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Jean-Marc, I've applied this to 1.4.x already. Here's a patch Angus for 1.3.x together with a test .tex file for you to try it out Angus with. The reLyX support for this package is now exactly the Angus same as LyX's. I do not understand this part: +% 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*[]{} In the first group, you comment out the versions with two [] groups, but in the second you do the opposite. Also, this test seems a bit fragile to me: +# 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; +} What if I have \usepackage{amsmath, natbib}? My reading of the regexp suggests that it will not work. To be fair, it seems that all the preamble reading code has this flaw, isn't it? Finally, the files produced by reLyX start with #LyX 1.2 created this file. For more info see http://www.lyx.org/ That's a bit strange, don't you think so? JMarc
Re: [patch 1.3.x] enable reLyX to handle natbib citations
Jean-Marc Lasgouttes wrote: Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Jean-Marc, I've applied this to 1.4.x already. Here's a patch Angus for 1.3.x together with a test .tex file for you to try it out Angus with. The reLyX support for this package is now exactly the Angus same as LyX's. I do not understand this part: +% Natbib citations can usually have two optional args, but LyX currently +% supports only one. +\citet[]{} +%\citet[][]{} + +\citealt[][]{} +%\citealt[][{} In the first group, you comment out the versions with two [] groups, but in the second you do the opposite. Thank you. My mistake. Only the single [] groups are handled by LyX. I'll fix it. Also, this test seems a bit fragile to me: +# 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; +} What if I have \usepackage{amsmath, natbib}? My reading of the regexp suggests that it will not work. To be fair, it seems that all the preamble reading code has this flaw, isn't it? Yes it has. I simply copied existing code. I also do not propose to fix that as my aim is to improve the LyX-LaTeX-LyX round trip, not to be able to import arbitrary TeX. If you want that, talk to André about tex2lyx. Finally, the files produced by reLyX start with #LyX 1.2 created this file. For more info see http://www.lyx.org/ That's a bit strange, don't you think so? Maybe. Shall I change it to # The reLyX bundled with LyX 1.3 created this file. # For more info see http://www.lyx.org/ # It produces a bastardised mess of various LyX versions, but # we specify the earliest to ensure that the upgrading script # lyx2lyx can handle it. :-) -- Angus
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 03:54:16PM +, Angus Leeming wrote: Yes it has. I simply copied existing code. I also do not propose to fix that as my aim is to improve the LyX-LaTeX-LyX round trip, not to be able to import arbitrary TeX. If you want that, talk to André about tex2lyx. As you talk about tex2lyx: Could anybody please set up the Make machinery for a new directory src/tex2lyx and a binary target tex2lyx somewhere? Jean-Marc maybe? Maybe. Shall I change it to # The reLyX bundled with LyX 1.3 created this file. # For more info see http://www.lyx.org/ # It produces a bastardised mess of various LyX versions, but # we specify the earliest to ensure that the upgrading script # lyx2lyx can handle it. Sounds honest. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Re: [patch 1.3.x] enable reLyX to handle natbib citations
Angus == Angus Leeming [EMAIL PROTECTED] writes: What if I have \usepackage{amsmath, natbib}? My reading of the regexp suggests that it will not work. To be fair, it seems that all the preamble reading code has this flaw, isn't it? Angus Yes it has. I simply copied existing code. I also do not Angus propose to fix that as my aim is to improve the LyX-LaTeX-LyX Angus round trip, not to be able to import arbitrary TeX. If you want Angus that, talk to André about tex2lyx. OK, that's fair again. Finally, the files produced by reLyX start with #LyX 1.2 created this file. For more info see http://www.lyx.org/ That's a bit strange, don't you think so? Angus Maybe. Shall I change it to # The reLyX bundled with LyX 1.3 Angus created this file. # For more info see http://www.lyx.org/ # It Angus produces a bastardised mess of various LyX versions, but # we Angus specify the earliest to ensure that the upgrading script # Angus lyx2lyx can handle it. Yes, whatever. Who reads these files, anyway? I just wonder if some people rely on the first few chars on the files as a /etc/magic string. JMarc
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 04:59:08PM +0100, Andre Poenitz wrote: Could anybody please set up the Make machinery for a new directory src/tex2lyx and a binary target tex2lyx somewhere? I suppose you don't mean something as simple as this Index: config/configure.ac === RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/configure.ac,v retrieving revision 1.26 diff -u -r1.26 configure.ac --- config/configure.ac 7 Feb 2003 11:36:05 - 1.26 +++ config/configure.ac 10 Feb 2003 16:07:07 - @@ -368,6 +368,7 @@ sourcedoc/Makefile \ src/Makefile \ src/version.C \ + src/tex2lyx/Makefile \ src/mathed/Makefile \ src/graphics/Makefile \ src/insets/Makefile \ Index: config/configure.in === RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/configure.in,v retrieving revision 1.19 diff -u -r1.19 configure.in --- config/configure.in 7 Feb 2003 11:36:05 - 1.19 +++ config/configure.in 10 Feb 2003 16:07:08 - @@ -303,6 +303,7 @@ sourcedoc/Makefile \ src/Makefile \ src/version.C \ + src/tex2lyx/Makefile \ src/mathed/Makefile \ src/graphics/Makefile \ src/insets/Makefile \ Index: src/Makefile.am === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v retrieving revision 1.152 diff -u -r1.152 Makefile.am --- src/Makefile.am 8 Feb 2003 19:17:43 - 1.152 +++ src/Makefile.am 10 Feb 2003 16:07:08 - @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES += $(srcdir)/config.h.in -SUBDIRS = mathed insets graphics support frontends +SUBDIRS = mathed insets graphics support frontends tex2lyx bin_PROGRAMS = lyx --- /dev/null 2002-08-31 00:31:37.0 +0100 +++ src/tex2lyx/Makefile.am 2003-02-10 16:06:53.0 + @@ -0,0 +1,5 @@ +include $(top_srcdir)/config/common.am + +bin_PROGRAMS = tex2lyx + +tex2lyx_SOURCES = main.C
Re: [patch 1.3.x] enable reLyX to handle natbib citations
Andre Poenitz wrote: On Mon, Feb 10, 2003 at 03:54:16PM +, Angus Leeming wrote: Yes it has. I simply copied existing code. I also do not propose to fix that as my aim is to improve the LyX-LaTeX-LyX round trip, not to be able to import arbitrary TeX. If you want that, talk to André about tex2lyx. As you talk about tex2lyx: Could anybody please set up the Make machinery for a new directory src/tex2lyx This is easy. Modify the bottom of config/configure.ac and config/configure.in and add your directory to: ### Finish the work. AC_CONFIG_SUBDIRS(lib lib/reLyX) AC_CONFIG_FILES([Makefile \ and a binary target tex2lyx somewhere? Have you tried adding a tex2lyx_SOURCES section to src/Makefile.am? Go on! I dare you! Angus -- Angus
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 04:08:40PM +, John Levon wrote: Could anybody please set up the Make machinery for a new directory src/tex2lyx and a binary target tex2lyx somewhere? I suppose you don't mean something as simple as this I think I mean something as simple as that. Simplicity lies in the eye of the beholder... Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 04:08:40PM +, John Levon wrote: I suppose you don't mean something as simple as this I think I mean it. Works well. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
[patch 13x]: reLyX natbib citations try 2
Fixes the mess in syntax.default. -- Angus ? build-qt ? build-xforms ? relyx-accents.diff ? relyx-natbib-test.lyx ? relyx-natbib-test.tex ? relyx-natbib.diff ? relyx-starredmath-test.tex ? relyx-starredmath.diff ? relyx-table-test.tex ? relyx-table.diff Index: status.13x === RCS file: /usr/local/lyx/cvsroot/lyx-devel/Attic/status.13x,v retrieving revision 1.1.2.8 diff -u -p -r1.1.2.8 status.13x --- status.13x 7 Feb 2003 16:49:19 - 1.1.2.8 +++ status.13x 10 Feb 2003 20:01:38 - @@ -27,6 +27,8 @@ What's new - new polski keymap, useful for entering Polish on a QWERTY keyboard +- enable reLyX to handle natbib citations + ** Bug fixes - fix bug where opening the tabular dialog would mark the document as @@ -41,4 +43,4 @@ What's new - fix strerror() build problem with some gcc/glibc versions [bug #874] -lyx2lyx: enable the debug level to be set. +- enable the lyx2lyx debug level to be set Index: lib/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.363.2.2 diff -u -p -r1.363.2.2 ChangeLog --- lib/ChangeLog 7 Feb 2003 16:14:34 - 1.363.2.2 +++ lib/ChangeLog 10 Feb 2003 20:01:42 - @@ -1,3 +1,12 @@ +2003-02-07 Angus Leeming [EMAIL PROTECTED] + + * 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 Tomasz Luczak [EMAIL PROTECTED] * kbd/polski.kmap: new keymap, which assumes that you have a 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 - 1.5 +++ lib/reLyX/BasicLyX.pm 10 Feb 2003 20:01:48 - @@ -218,6 +218,32 @@ 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; +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 @@ -381,7 +407,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 +564,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 +799,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/MakePreamble.pm === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/MakePreamble.pm,v retrieving revision 1.8 diff -u -p -r1.8 MakePreamble.pm --- lib/reLyX/MakePreamble.pm 15 Jan 2003 14:31:34 - 1.8 +++ lib/reLyX/MakePreamble.pm 10 Feb 2003 20:01:49 - @@ -299,6 +299,14 @@ sub translate_preamble { } } +# 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
Re: [patch 1.3.x] enable reLyX to handle natbib citations
>>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> Jean-Marc, I've applied this to 1.4.x already. Here's a patch Angus> for 1.3.x together with a test .tex file for you to try it out Angus> with. The reLyX support for this package is now exactly the Angus> same as LyX's. I do not understand this part: +% 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*[]{} In the first group, you comment out the versions with two [] groups, but in the second you do the opposite. Also, this test seems a bit fragile to me: +# 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"; +} What if I have \usepackage{amsmath, natbib}? My reading of the regexp suggests that it will not work. To be fair, it seems that all the preamble reading code has this flaw, isn't it? Finally, the files produced by reLyX start with #LyX 1.2 created this file. For more info see http://www.lyx.org/ That's a bit strange, don't you think so? JMarc
Re: [patch 1.3.x] enable reLyX to handle natbib citations
Jean-Marc Lasgouttes wrote: >>>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: > > Angus> Jean-Marc, I've applied this to 1.4.x already. Here's a patch > Angus> for 1.3.x together with a test .tex file for you to try it > out Angus> with. The reLyX support for this package is now exactly > the Angus> same as LyX's. > > I do not understand this part: > > +% Natbib citations can usually have two optional args, but LyX > currently +% supports only one. > +\citet[]{} > +%\citet[][]{} > + > +\citealt[][]{} > +%\citealt[][{} > > In the first group, you comment out the versions with two [] groups, > but in the second you do the opposite. Thank you. My mistake. Only the single [] groups are handled by LyX. I'll fix it. > Also, this test seems a bit fragile to me: > > +# 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"; > +} > > What if I have \usepackage{amsmath, natbib}? My reading of the > regexp suggests that it will not work. To be fair, it seems that all > the preamble reading code has this flaw, isn't it? Yes it has. I simply copied existing code. I also do not propose to fix that as my aim is to improve the LyX->LaTeX->LyX round trip, not to be able to import arbitrary TeX. If you want that, talk to André about tex2lyx. > Finally, the files produced by reLyX start with > #LyX 1.2 created this file. For more info see http://www.lyx.org/ > > That's a bit strange, don't you think so? Maybe. Shall I change it to # The reLyX bundled with LyX 1.3 created this file. # For more info see http://www.lyx.org/ # It produces a bastardised mess of various LyX versions, but # we specify the earliest to ensure that the upgrading script # lyx2lyx can handle it. :-) -- Angus
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 03:54:16PM +, Angus Leeming wrote: > Yes it has. I simply copied existing code. I also do not propose to > fix that as my aim is to improve the LyX->LaTeX->LyX round trip, not > to be able to import arbitrary TeX. If you want that, talk to André > about tex2lyx. As you talk about tex2lyx: Could anybody please set up the Make machinery for a new directory src/tex2lyx and a binary target tex2lyx somewhere? Jean-Marc maybe? > Maybe. Shall I change it to > # The reLyX bundled with LyX 1.3 created this file. > # For more info see http://www.lyx.org/ > # It produces a bastardised mess of various LyX versions, but > # we specify the earliest to ensure that the upgrading script > # lyx2lyx can handle it. Sounds honest. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Re: [patch 1.3.x] enable reLyX to handle natbib citations
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: >> What if I have \usepackage{amsmath, natbib}? My reading of the >> regexp suggests that it will not work. To be fair, it seems that >> all the preamble reading code has this flaw, isn't it? Angus> Yes it has. I simply copied existing code. I also do not Angus> propose to fix that as my aim is to improve the LyX->LaTeX->LyX Angus> round trip, not to be able to import arbitrary TeX. If you want Angus> that, talk to André about tex2lyx. OK, that's fair again. >> Finally, the files produced by reLyX start with #LyX 1.2 created >> this file. For more info see http://www.lyx.org/ >> >> That's a bit strange, don't you think so? Angus> Maybe. Shall I change it to # The reLyX bundled with LyX 1.3 Angus> created this file. # For more info see http://www.lyx.org/ # It Angus> produces a bastardised mess of various LyX versions, but # we Angus> specify the earliest to ensure that the upgrading script # Angus> lyx2lyx can handle it. Yes, whatever. Who reads these files, anyway? I just wonder if some people rely on the first few chars on the files as a /etc/magic string. JMarc
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 04:59:08PM +0100, Andre Poenitz wrote: > Could anybody please set up the Make machinery for a new directory > src/tex2lyx and a binary target tex2lyx somewhere? I suppose you don't mean something as simple as this Index: config/configure.ac === RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/configure.ac,v retrieving revision 1.26 diff -u -r1.26 configure.ac --- config/configure.ac 7 Feb 2003 11:36:05 - 1.26 +++ config/configure.ac 10 Feb 2003 16:07:07 - @@ -368,6 +368,7 @@ sourcedoc/Makefile \ src/Makefile \ src/version.C \ + src/tex2lyx/Makefile \ src/mathed/Makefile \ src/graphics/Makefile \ src/insets/Makefile \ Index: config/configure.in === RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/configure.in,v retrieving revision 1.19 diff -u -r1.19 configure.in --- config/configure.in 7 Feb 2003 11:36:05 - 1.19 +++ config/configure.in 10 Feb 2003 16:07:08 - @@ -303,6 +303,7 @@ sourcedoc/Makefile \ src/Makefile \ src/version.C \ + src/tex2lyx/Makefile \ src/mathed/Makefile \ src/graphics/Makefile \ src/insets/Makefile \ Index: src/Makefile.am === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v retrieving revision 1.152 diff -u -r1.152 Makefile.am --- src/Makefile.am 8 Feb 2003 19:17:43 - 1.152 +++ src/Makefile.am 10 Feb 2003 16:07:08 - @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES += $(srcdir)/config.h.in -SUBDIRS = mathed insets graphics support frontends +SUBDIRS = mathed insets graphics support frontends tex2lyx bin_PROGRAMS = lyx --- /dev/null 2002-08-31 00:31:37.0 +0100 +++ src/tex2lyx/Makefile.am 2003-02-10 16:06:53.0 + @@ -0,0 +1,5 @@ +include $(top_srcdir)/config/common.am + +bin_PROGRAMS = tex2lyx + +tex2lyx_SOURCES = main.C
Re: [patch 1.3.x] enable reLyX to handle natbib citations
Andre Poenitz wrote: > On Mon, Feb 10, 2003 at 03:54:16PM +, Angus Leeming wrote: >> Yes it has. I simply copied existing code. I also do not propose to >> fix that as my aim is to improve the LyX->LaTeX->LyX round trip, >> not to be able to import arbitrary TeX. If you want that, talk to >> André about tex2lyx. > > As you talk about tex2lyx: > > Could anybody please set up the Make machinery for a new directory > src/tex2lyx This is easy. Modify the bottom of config/configure.ac and config/configure.in and add your directory to: ### Finish the work. AC_CONFIG_SUBDIRS(lib lib/reLyX) AC_CONFIG_FILES([Makefile \ > and a binary target tex2lyx somewhere? Have you tried adding a tex2lyx_SOURCES section to src/Makefile.am? Go on! I dare you! Angus -- Angus
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 04:08:40PM +, John Levon wrote: > > Could anybody please set up the Make machinery for a new directory > > src/tex2lyx and a binary target tex2lyx somewhere? > > I suppose you don't mean something as simple as this I think I mean something as simple as that. Simplicity lies in the eye of the beholder... Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Re: [patch 1.3.x] enable reLyX to handle natbib citations
On Mon, Feb 10, 2003 at 04:08:40PM +, John Levon wrote: > I suppose you don't mean something as simple as this I think I mean it. Works well. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
[patch 13x]: reLyX && natbib citations try 2
Fixes the mess in syntax.default. -- Angus ? build-qt ? build-xforms ? relyx-accents.diff ? relyx-natbib-test.lyx ? relyx-natbib-test.tex ? relyx-natbib.diff ? relyx-starredmath-test.tex ? relyx-starredmath.diff ? relyx-table-test.tex ? relyx-table.diff Index: status.13x === RCS file: /usr/local/lyx/cvsroot/lyx-devel/Attic/status.13x,v retrieving revision 1.1.2.8 diff -u -p -r1.1.2.8 status.13x --- status.13x 7 Feb 2003 16:49:19 - 1.1.2.8 +++ status.13x 10 Feb 2003 20:01:38 - @@ -27,6 +27,8 @@ What's new - new "polski" keymap, useful for entering Polish on a QWERTY keyboard +- enable reLyX to handle natbib citations + ** Bug fixes - fix bug where opening the tabular dialog would mark the document as @@ -41,4 +43,4 @@ What's new - fix strerror() build problem with some gcc/glibc versions [bug #874] -lyx2lyx: enable the debug level to be set. +- enable the lyx2lyx debug level to be set Index: lib/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.363.2.2 diff -u -p -r1.363.2.2 ChangeLog --- lib/ChangeLog 7 Feb 2003 16:14:34 - 1.363.2.2 +++ lib/ChangeLog 10 Feb 2003 20:01:42 - @@ -1,3 +1,12 @@ +2003-02-07 Angus Leeming <[EMAIL PROTECTED]> + + * 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 Tomasz Luczak <[EMAIL PROTECTED]> * kbd/polski.kmap: new keymap, which assumes that you have a 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 - 1.5 +++ lib/reLyX/BasicLyX.pm 10 Feb 2003 20:01:48 - @@ -218,6 +218,32 @@ 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; +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 @@ -381,7 +407,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)){ #Start new paragraph if necessary print OUTFILE "$pre_space\n\\begin_inset LatexCommand ", $name, @@ -537,7 +564,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)){ #Start new paragraph if necessary print OUTFILE "$pre_space\n\\begin_inset LatexCommand "; @@ -772,7 +799,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/MakePreamble.pm === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/MakePreamble.pm,v retrieving revision 1.8 diff -u -p -r1.8 MakePreamble.pm --- lib/reLyX/MakePreamble.pm 15 Jan 2003 14:31:34 - 1.8 +++ lib/reLyX/MakePreamble.pm 10 Feb 2003 20:01:49 - @@ -299,6 +299,14 @@ sub translate_preamble { } } +# 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
[patch 1.3.x] enable reLyX to handle natbib citations
Jean-Marc, I've applied this to 1.4.x already. Here's a patch for 1.3.x together with a test .tex file for you to try it out with. The reLyX support for this package is now exactly the same as LyX's. Rgds, -- Angus Index: status.13x === RCS file: /usr/local/lyx/cvsroot/lyx-devel/Attic/status.13x,v retrieving revision 1.1.2.8 diff -u -p -r1.1.2.8 status.13x --- status.13x 7 Feb 2003 16:49:19 - 1.1.2.8 +++ status.13x 7 Feb 2003 22:26:09 - @@ -27,6 +27,8 @@ What's new - new polski keymap, useful for entering Polish on a QWERTY keyboard +- enable reLyX to handle natbib citations + ** Bug fixes - fix bug where opening the tabular dialog would mark the document as @@ -41,4 +43,4 @@ What's new - fix strerror() build problem with some gcc/glibc versions [bug #874] -lyx2lyx: enable the debug level to be set. +- enable the lyx2lyx debug level to be set Index: lib/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.363.2.2 diff -u -p -r1.363.2.2 ChangeLog --- lib/ChangeLog 7 Feb 2003 16:14:34 - 1.363.2.2 +++ lib/ChangeLog 7 Feb 2003 22:26:13 - @@ -1,3 +1,12 @@ +2003-02-07 Angus Leeming [EMAIL PROTECTED] + + * 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 Tomasz Luczak [EMAIL PROTECTED] * kbd/polski.kmap: new keymap, which assumes that you have a 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 - 1.5 +++ lib/reLyX/BasicLyX.pm 7 Feb 2003 22:26:17 - @@ -218,6 +218,32 @@ 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; +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 @@ -381,7 +407,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 +564,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 +799,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/MakePreamble.pm === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/MakePreamble.pm,v retrieving revision 1.8 diff -u -p -r1.8 MakePreamble.pm --- lib/reLyX/MakePreamble.pm 15 Jan 2003 14:31:34 - 1.8 +++ lib/reLyX/MakePreamble.pm 7 Feb 2003 22:26:17 - @@ -299,6 +299,14 @@ sub translate_preamble { } } +# 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
[patch 1.3.x] enable reLyX to handle natbib citations
Jean-Marc, I've applied this to 1.4.x already. Here's a patch for 1.3.x together with a test .tex file for you to try it out with. The reLyX support for this package is now exactly the same as LyX's. Rgds, -- Angus Index: status.13x === RCS file: /usr/local/lyx/cvsroot/lyx-devel/Attic/status.13x,v retrieving revision 1.1.2.8 diff -u -p -r1.1.2.8 status.13x --- status.13x 7 Feb 2003 16:49:19 - 1.1.2.8 +++ status.13x 7 Feb 2003 22:26:09 - @@ -27,6 +27,8 @@ What's new - new "polski" keymap, useful for entering Polish on a QWERTY keyboard +- enable reLyX to handle natbib citations + ** Bug fixes - fix bug where opening the tabular dialog would mark the document as @@ -41,4 +43,4 @@ What's new - fix strerror() build problem with some gcc/glibc versions [bug #874] -lyx2lyx: enable the debug level to be set. +- enable the lyx2lyx debug level to be set Index: lib/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.363.2.2 diff -u -p -r1.363.2.2 ChangeLog --- lib/ChangeLog 7 Feb 2003 16:14:34 - 1.363.2.2 +++ lib/ChangeLog 7 Feb 2003 22:26:13 - @@ -1,3 +1,12 @@ +2003-02-07 Angus Leeming <[EMAIL PROTECTED]> + + * 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 Tomasz Luczak <[EMAIL PROTECTED]> * kbd/polski.kmap: new keymap, which assumes that you have a 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 - 1.5 +++ lib/reLyX/BasicLyX.pm 7 Feb 2003 22:26:17 - @@ -218,6 +218,32 @@ 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; +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 @@ -381,7 +407,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)){ #Start new paragraph if necessary print OUTFILE "$pre_space\n\\begin_inset LatexCommand ", $name, @@ -537,7 +564,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)){ #Start new paragraph if necessary print OUTFILE "$pre_space\n\\begin_inset LatexCommand "; @@ -772,7 +799,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/MakePreamble.pm === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/MakePreamble.pm,v retrieving revision 1.8 diff -u -p -r1.8 MakePreamble.pm --- lib/reLyX/MakePreamble.pm 15 Jan 2003 14:31:34 - 1.8 +++ lib/reLyX/MakePreamble.pm 7 Feb 2003 22:26:17 - @@ -299,6 +299,14 @@ sub translate_preamble { } } +# 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" :
Re: natbib citations
On Tue, 23 Apr 2002, Angus Leeming wrote: On Monday 22 April 2002 8:12 pm, Mike Ressler wrote: No problem. As a return favor, could you look at the ProvidesNatbib patch I sent out Friday? The patch itself is trivial, but you might be able to address my question about how ProvidesNatbib 1 in the layout file might automatically turn on the GUI support provided by clicking on Use Natbib. Mike, I _think_ that all you need to do is modify InsetCitation::validate I'll give this a try, perhaps tomorrow. The real world has been awfully intrusive this week ... Thanks for the hint. Mike -- Mike Ressler [EMAIL PROTECTED] OK, I'm lame: I don't have my own website ...
Re: natbib citations
On Wednesday 24 April 2002 6:19 pm, Mike Ressler wrote: On Tue, 23 Apr 2002, Angus Leeming wrote: On Monday 22 April 2002 8:12 pm, Mike Ressler wrote: No problem. As a return favor, could you look at the ProvidesNatbib patch I sent out Friday? The patch itself is trivial, but you might be able to address my question about how ProvidesNatbib 1 in the layout file might automatically turn on the GUI support provided by clicking on Use Natbib. Mike, I _think_ that all you need to do is modify InsetCitation::validate I'll give this a try, perhaps tomorrow. The real world has been awfully intrusive this week ... Thanks for the hint. Mike The hint was wrong! This is all done correctly. You ned to set BufferParams::use_natbib when the buffer is opened and you discover that the textclass supports natbib. Angus
Re: natbib citations
On Tue, 23 Apr 2002, Angus Leeming wrote: > On Monday 22 April 2002 8:12 pm, Mike Ressler wrote: > > No problem. As a return favor, could you look at the ProvidesNatbib patch > > I sent out Friday? The patch itself is trivial, but you might be able to > > address my question about how "ProvidesNatbib 1" in the layout file might > > automatically turn on the GUI support provided by clicking on "Use > > Natbib". > > Mike, I _think_ that all you need to do is modify InsetCitation::validate I'll give this a try, perhaps tomorrow. The real world has been awfully intrusive this week ... Thanks for the hint. Mike -- Mike Ressler [EMAIL PROTECTED] OK, I'm lame: I don't have my own website ...
Re: natbib citations
On Wednesday 24 April 2002 6:19 pm, Mike Ressler wrote: > On Tue, 23 Apr 2002, Angus Leeming wrote: > > On Monday 22 April 2002 8:12 pm, Mike Ressler wrote: > > > No problem. As a return favor, could you look at the ProvidesNatbib > > > patch I sent out Friday? The patch itself is trivial, but you might be > > > able to address my question about how "ProvidesNatbib 1" in the layout > > > file might automatically turn on the GUI support provided by clicking > > > on "Use Natbib". > > > > Mike, I _think_ that all you need to do is modify InsetCitation::validate > > I'll give this a try, perhaps tomorrow. The real world has been awfully > intrusive this week ... > > Thanks for the hint. > > Mike The hint was wrong! This is all done correctly. You ned to set BufferParams::use_natbib when the buffer is opened and you discover that the textclass supports natbib. Angus
Re: natbib citations
On Monday 22 April 2002 10:35 am, Angus Leeming wrote: On Tuesday 16 April 2002 10:31 am, Angus Leeming wrote: On Monday 15 April 2002 4:40 pm, Angus Leeming wrote: I think that the screen label part of the patch is fine, although I've modified it to work with numerical natbib citations and to cache the label. Attached are my re-workings. [snip] I have tested this patch pretty thoroughly myself and have decided that it's only real shortcoming is that it results in VERY slow loading of a buffer. This occurs because we reload Buffer::getBibkeyList from any BibTeX files for each and every citation key. Mike Ressler has been testing this patch for me and discovered another shortcoming: On Thu, 18 Apr 2002, Angus Leeming wrote: the problem with your files is that you have used natbib but not used BibTeX and the current, rather clunky, solution can't cope. I have fixed things here so that you get the old, uninformative labels in this case. Okay. BibTeX usage is exceedingly uncommon in astronomical journals. In fact, I don't think there is any facility in AASTeX for dealing with it. Thus it never even occurred to me to try BibTeX. I guess that this shows the benefit of asking users what they need! Anyway, that problem is very easy to fix and the patch, attached, solves it. In fact, I'd like to apply it. It gives LyX WYSIWYG citation labels when using natbib and the boring old ones when not. Lars? Angus If I've had no NO, I'll apply this patch later today. Angus
Re: natbib citations
Angus Leeming [EMAIL PROTECTED] writes: | On Monday 22 April 2002 10:35 am, Angus Leeming wrote: On Tuesday 16 April 2002 10:31 am, Angus Leeming wrote: On Monday 15 April 2002 4:40 pm, Angus Leeming wrote: I think that the screen label part of the patch is fine, although I've modified it to work with numerical natbib citations and to cache the label. Attached are my re-workings. [snip] I have tested this patch pretty thoroughly myself and have decided that it's only real shortcoming is that it results in VERY slow loading of a buffer. This occurs because we reload Buffer::getBibkeyList from any BibTeX files for each and every citation key. Mike Ressler has been testing this patch for me and discovered another shortcoming: On Thu, 18 Apr 2002, Angus Leeming wrote: the problem with your files is that you have used natbib but not used BibTeX and the current, rather clunky, solution can't cope. I have fixed things here so that you get the old, uninformative labels in this case. Okay. BibTeX usage is exceedingly uncommon in astronomical journals. In fact, I don't think there is any facility in AASTeX for dealing with it. Thus it never even occurred to me to try BibTeX. I guess that this shows the benefit of asking users what they need! Anyway, that problem is very easy to fix and the patch, attached, solves it. In fact, I'd like to apply it. It gives LyX WYSIWYG citation labels when using natbib and the boring old ones when not. Lars? Angus | If I've had no NO, I'll apply this patch later today. Silence is not approval. I want to hear J-M's opinion, since he has look at this case earlier... -- Lgb
Re: natbib citations
On Tuesday 23 April 2002 9:19 am, Lars Gullik Bjønnes wrote: Silence is not approval. I want to hear J-M's opinion, since he has look at this case earlier... Fair enough. I just wanted to trigger some response. Jean-Marc, the patch I submitted yesterday contained a bug that lead to the occasional crash (an invalid iterator). However, that has now been fixed. See attached. Angus cite.diff.gz Description: GNU Zip compressed data
Re: natbib citations
On Monday 22 April 2002 8:12 pm, Mike Ressler wrote: On Mon, 22 Apr 2002, Angus Leeming wrote: On Monday 22 April 2002 11:00 am, Angus Leeming wrote: This might make you happy... If you could test it a little, that'd make me happy too. Had a few minutes to play with it - beautifully done. I'll try it a bit more fully later today, but it already appears to do everything I need. and, perhaps not unexpectedly, it leads occasionally to a crash. Now fixed. Sorry for the email bombardment... No problem. As a return favor, could you look at the ProvidesNatbib patch I sent out Friday? The patch itself is trivial, but you might be able to address my question about how ProvidesNatbib 1 in the layout file might automatically turn on the GUI support provided by clicking on Use Natbib. Mike, I _think_ that all you need to do is modify InsetCitation::validate void InsetCitation::validate(LaTeXFeatures features) const { + BufferParams params = features.bufferParams(); + if (params.use_natbib + !params.textclass.provides(LyXTextClass::natbib)) - if (features.bufferParams().use_natbib) features.require(natbib); } Angus
Re: natbib citations
On Monday 22 April 2002 10:35 am, Angus Leeming wrote: > On Tuesday 16 April 2002 10:31 am, Angus Leeming wrote: > > On Monday 15 April 2002 4:40 pm, Angus Leeming wrote: > > > I think that the screen label part of the patch is fine, although I've > > > modified it to work with numerical natbib citations and to cache the > > > label. > > > > > > Attached are my re-workings. > > > > [snip] > > > > I have tested this patch pretty thoroughly myself and have decided that > > it's only real shortcoming is that it results in VERY slow loading of a > > buffer. This occurs because we reload Buffer::getBibkeyList from any > > BibTeX files for each and every citation key. > > Mike Ressler has been testing this patch for me and discovered another > > shortcoming: > > On Thu, 18 Apr 2002, Angus Leeming wrote: > > > the problem with your files is that you have used natbib but not used > > > BibTeX and the current, rather clunky, solution can't cope. I have > > > "fixed" things here so that you get the old, uninformative labels in > > > this case. > > > > Okay. BibTeX usage is exceedingly uncommon in astronomical journals. In > > fact, I don't think there is any facility in AASTeX for dealing with it. > > Thus it never even occurred to me to try BibTeX. > > I guess that this shows the benefit of asking users what they need! Anyway, > that problem is very easy to fix and the patch, attached, solves it. In > fact, I'd like to apply it. It gives LyX WYSIWYG citation labels when using > natbib and the boring old ones when not. > > Lars? > > Angus If I've had no NO, I'll apply this patch later today. Angus
Re: natbib citations
Angus Leeming <[EMAIL PROTECTED]> writes: | On Monday 22 April 2002 10:35 am, Angus Leeming wrote: >> On Tuesday 16 April 2002 10:31 am, Angus Leeming wrote: >> > On Monday 15 April 2002 4:40 pm, Angus Leeming wrote: >> > > I think that the screen label part of the patch is fine, although I've >> > > modified it to work with numerical natbib citations and to cache the >> > > label. >> > > >> > > Attached are my re-workings. >> > >> > [snip] >> > >> > I have tested this patch pretty thoroughly myself and have decided that >> > it's only real shortcoming is that it results in VERY slow loading of a >> > buffer. This occurs because we reload Buffer::getBibkeyList from any >> > BibTeX files for each and every citation key. >> >> Mike Ressler has been testing this patch for me and discovered another >> >> shortcoming: >> > On Thu, 18 Apr 2002, Angus Leeming wrote: >> > > the problem with your files is that you have used natbib but not used >> > > BibTeX and the current, rather clunky, solution can't cope. I have >> > > "fixed" things here so that you get the old, uninformative labels in >> > > this case. >> > >> > Okay. BibTeX usage is exceedingly uncommon in astronomical journals. In >> > fact, I don't think there is any facility in AASTeX for dealing with it. >> > Thus it never even occurred to me to try BibTeX. >> >> I guess that this shows the benefit of asking users what they need! Anyway, >> that problem is very easy to fix and the patch, attached, solves it. In >> fact, I'd like to apply it. It gives LyX WYSIWYG citation labels when using >> natbib and the boring old ones when not. >> >> Lars? >> >> Angus > | If I've had no NO, I'll apply this patch later today. Silence is not approval. I want to hear J-M's opinion, since he has look at this case earlier... -- Lgb
Re: natbib citations
On Tuesday 23 April 2002 9:19 am, Lars Gullik Bjønnes wrote: > Silence is not approval. > I want to hear J-M's opinion, since he has look at this case > earlier... Fair enough. I just wanted to trigger some response. Jean-Marc, the patch I submitted yesterday contained a bug that lead to the occasional crash (an invalid iterator). However, that has now been fixed. See attached. Angus cite.diff.gz Description: GNU Zip compressed data
Re: natbib citations
On Monday 22 April 2002 8:12 pm, Mike Ressler wrote: > On Mon, 22 Apr 2002, Angus Leeming wrote: > > On Monday 22 April 2002 11:00 am, Angus Leeming wrote: > > > This might make you happy... > > > > > > If you could test it a little, that'd make me happy too. > > Had a few minutes to play with it - beautifully done. I'll try it a bit > more fully later today, but it already appears to do everything I need. > > > and, perhaps not unexpectedly, it leads occasionally to a crash. Now > > fixed. Sorry for the email bombardment... > > No problem. As a return favor, could you look at the ProvidesNatbib patch > I sent out Friday? The patch itself is trivial, but you might be able to > address my question about how "ProvidesNatbib 1" in the layout file might > automatically turn on the GUI support provided by clicking on "Use > Natbib". Mike, I _think_ that all you need to do is modify InsetCitation::validate void InsetCitation::validate(LaTeXFeatures & features) const { + BufferParams & params = features.bufferParams(); + if (params.use_natbib && + !params.textclass.provides(LyXTextClass::natbib)) - if (features.bufferParams().use_natbib) features.require("natbib"); } Angus
Re: natbib citations
On Tuesday 16 April 2002 10:31 am, Angus Leeming wrote: On Monday 15 April 2002 4:40 pm, Angus Leeming wrote: I think that the screen label part of the patch is fine, although I've modified it to work with numerical natbib citations and to cache the label. Attached are my re-workings. [snip] I have tested this patch pretty thoroughly myself and have decided that it's only real shortcoming is that it results in VERY slow loading of a buffer. This occurs because we reload Buffer::getBibkeyList from any BibTeX files for each and every citation key. Mike Ressler has been testing this patch for me and discovered another shortcoming: On Thu, 18 Apr 2002, Angus Leeming wrote: the problem with your files is that you have used natbib but not used BibTeX and the current, rather clunky, solution can't cope. I have fixed things here so that you get the old, uninformative labels in this case. Okay. BibTeX usage is exceedingly uncommon in astronomical journals. In fact, I don't think there is any facility in AASTeX for dealing with it. Thus it never even occurred to me to try BibTeX. I guess that this shows the benefit of asking users what they need! Anyway, that problem is very easy to fix and the patch, attached, solves it. In fact, I'd like to apply it. It gives LyX WYSIWYG citation labels when using natbib and the boring old ones when not. Lars? Angus cite.diff.gz Description: GNU Zip compressed data
Re: natbib citations
On Tuesday 16 April 2002 10:31 am, Angus Leeming wrote: > On Monday 15 April 2002 4:40 pm, Angus Leeming wrote: > > I think that the screen label part of the patch is fine, although I've > > modified it to work with numerical natbib citations and to cache the > > label. > > > > Attached are my re-workings. > > [snip] > > I have tested this patch pretty thoroughly myself and have decided that > it's only real shortcoming is that it results in VERY slow loading of a > buffer. This occurs because we reload Buffer::getBibkeyList from any BibTeX > files for each and every citation key. Mike Ressler has been testing this patch for me and discovered another shortcoming: > On Thu, 18 Apr 2002, Angus Leeming wrote: > > the problem with your files is that you have used natbib but not used > > BibTeX and the current, rather clunky, solution can't cope. I have > > "fixed" things here so that you get the old, uninformative labels in this > > case. > > Okay. BibTeX usage is exceedingly uncommon in astronomical journals. In > fact, I don't think there is any facility in AASTeX for dealing with it. > Thus it never even occurred to me to try BibTeX. I guess that this shows the benefit of asking users what they need! Anyway, that problem is very easy to fix and the patch, attached, solves it. In fact, I'd like to apply it. It gives LyX WYSIWYG citation labels when using natbib and the boring old ones when not. Lars? Angus cite.diff.gz Description: GNU Zip compressed data
Re: natbib citations
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus I have tested this patch pretty thoroughly myself and have Angus decided that it's only real shortcoming is that it results in Angus VERY slow loading of a buffer. This occurs because we reload Angus Buffer::getBibkeyList from any BibTeX files for each and every Angus citation key. Angus The real solution is for Buffer::getBibkeyList to reload the Angus BibTeX keys only when the BibTeX files change but, for now, a Angus working alternative is to cache the keys used by InsetCitation. Angus I have created a mapBuffer const *, bool loading_buffer; Angus which is set to loading_buffer[buffer] = false; in Angus InsetCitation::edit(). Why did not you add a 'bool loading' member to Buffer? This seems simpler. And maybe the cache could be part of the buffer too. JMarc
Re: natbib citations
On Tuesday 16 April 2002 12:58 pm, Jean-Marc Lasgouttes wrote: Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus I have tested this patch pretty thoroughly myself and have Angus decided that it's only real shortcoming is that it results in Angus VERY slow loading of a buffer. This occurs because we reload Angus Buffer::getBibkeyList from any BibTeX files for each and every Angus citation key. Angus The real solution is for Buffer::getBibkeyList to reload the Angus BibTeX keys only when the BibTeX files change but, for now, a Angus working alternative is to cache the keys used by InsetCitation. Angus I have created a mapBuffer const *, bool loading_buffer; Angus which is set to loading_buffer[buffer] = false; in Angus InsetCitation::edit(). Why did not you add a 'bool loading' member to Buffer? This seems simpler. And maybe the cache could be part of the buffer too. JMarc 1. Buffer is already horribly bloated. 2. I have plans to create a BibtexCache for 1.3. 3. Most importantly, I want to minimise the footprint of any changes I'm making. The current patch affects the citation inset only and either works or doesn't work. In this case, _I_ think that it works, is efficient, is pretty clean and could happily go in 1.2. I'd prefer it to be tested by possible users though. Having said all this, I'm happy to add a bool to Buffer. Do you think that that is a Good Idea at this stage? As an aside, I have implemented ascii export too here. A.
Re: natbib citations
All works very well here, but I'd like some volunteer testers please. No testers, no apply... applied patch but compile breaks down... g++ -DHAVE_CONFIG_H -I. -I. -I../../src -I./../ -I../.. -I../../boost -isystem /usr/X11R6/include -g -O -fno-exceptions -W -Wall -c insetcite.C -MT insetcite.lo -MD -MP -MF .deps/insetcite.TPlo In file included from ../../src/Lsstream.h:20, from ../../src/support/lstrings.h:24, from insetcite.C:28: /usr/include/g++-3/sstream: In method `int stringbuf::sync ()': /usr/include/g++-3/sstream:171: warning: comparison between signed and unsigned integer expressions insetcite.C: In function `const string {unnamed}::getNatbibLabel (const Buffer *, const string , const string , const string , const string , bool)': insetcite.C:65: passing `const Buffer' as `this' argument of `const vectorpairstring, string, allocatorpairstring, string Buffer::getBibkeyList ()' discards qualifiers make[3]: *** [insetcite.lo] Error 1 make[3]: Leaving directory `/home/leuven/cvs/lyx-devel/src/insets' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/leuven/cvs/lyx-devel/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/leuven/cvs/lyx-devel/
Re: natbib citations
On Tuesday 16 April 2002 1:26 pm, Edwin Leuven wrote: All works very well here, but I'd like some volunteer testers please. No testers, no apply... applied patch but compile breaks down... I think that this is saying that Buffer::getBibkeyList() is non-const so a Buffer const * can't access it. You should cvs update because in current cvs Buffer::getBibkeyList() is const. Angus g++ -DHAVE_CONFIG_H -I. -I. -I../../src -I./../ -I../.. -I../../boost -isystem /usr/X11R6/include -g -O -fno-exceptions -W -Wall -c insetcite.C -MT insetcite.lo -MD -MP -MF .deps/insetcite.TPlo In file included from ../../src/Lsstream.h:20, from ../../src/support/lstrings.h:24, from insetcite.C:28: /usr/include/g++-3/sstream: In method `int stringbuf::sync ()': /usr/include/g++-3/sstream:171: warning: comparison between signed and unsigned integer expressions insetcite.C: In function `const string {unnamed}::getNatbibLabel (const Buffer *, const string , const string , const string , const string , bool)': insetcite.C:65: passing `const Buffer' as `this' argument of `const vectorpairstring, string, allocatorpairstring, string Buffer::getBibkeyList ()' discards qualifiers make[3]: *** [insetcite.lo] Error 1 make[3]: Leaving directory `/home/leuven/cvs/lyx-devel/src/insets' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/leuven/cvs/lyx-devel/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/leuven/cvs/lyx-devel/
Re: natbib citations
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus 3. Most importantly, I want to Angus minimise the footprint of any changes I'm making. The current Angus patch affects the citation inset only and either works or Angus doesn't work. That makes sense. Angus Having said all this, I'm happy to add a bool to Buffer. Do you Angus think that that is a Good Idea at this stage? No, you're probably right. Angus As an aside, I have implemented ascii export too here. Good. JMarc
Re: natbib citations
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> I have tested this patch pretty thoroughly myself and have Angus> decided that it's only real shortcoming is that it results in Angus> VERY slow loading of a buffer. This occurs because we reload Angus> Buffer::getBibkeyList from any BibTeX files for each and every Angus> citation key. Angus> The real solution is for Buffer::getBibkeyList to reload the Angus> BibTeX keys only when the BibTeX files change but, for now, a Angus> working alternative is to cache the keys used by InsetCitation. Angus> I have created a map loading_buffer; Angus> which is set to loading_buffer[buffer] = false; in Angus> InsetCitation::edit(). Why did not you add a 'bool loading' member to Buffer? This seems simpler. And maybe the cache could be part of the buffer too. JMarc
Re: natbib citations
On Tuesday 16 April 2002 12:58 pm, Jean-Marc Lasgouttes wrote: > > "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: > > Angus> I have tested this patch pretty thoroughly myself and have > Angus> decided that it's only real shortcoming is that it results in > Angus> VERY slow loading of a buffer. This occurs because we reload > Angus> Buffer::getBibkeyList from any BibTeX files for each and every > Angus> citation key. > > Angus> The real solution is for Buffer::getBibkeyList to reload the > Angus> BibTeX keys only when the BibTeX files change but, for now, a > Angus> working alternative is to cache the keys used by InsetCitation. > > Angus> I have created a map loading_buffer; > Angus> which is set to loading_buffer[buffer] = false; in > Angus> InsetCitation::edit(). > > Why did not you add a 'bool loading' member to Buffer? This seems > simpler. And maybe the cache could be part of the buffer too. > > JMarc 1. Buffer is already horribly bloated. 2. I have plans to create a BibtexCache for 1.3. 3. Most importantly, I want to minimise the footprint of any changes I'm making. The current patch affects the citation inset only and either works or doesn't work. In this case, _I_ think that it works, is efficient, is pretty clean and could happily go in 1.2. I'd prefer it to be tested by possible users though. Having said all this, I'm happy to add a bool to Buffer. Do you think that that is a Good Idea at this stage? As an aside, I have implemented ascii export too here. A.
Re: natbib citations
> All works very well here, but I'd like some volunteer testers please. No > testers, no apply... applied patch but compile breaks down... g++ -DHAVE_CONFIG_H -I. -I. -I../../src -I./../ -I../.. -I../../boost -isystem /usr/X11R6/include -g -O -fno-exceptions -W -Wall -c insetcite.C -MT insetcite.lo -MD -MP -MF .deps/insetcite.TPlo In file included from ../../src/Lsstream.h:20, from ../../src/support/lstrings.h:24, from insetcite.C:28: /usr/include/g++-3/sstream: In method `int stringbuf::sync ()': /usr/include/g++-3/sstream:171: warning: comparison between signed and unsigned integer expressions insetcite.C: In function `const string {unnamed}::getNatbibLabel (const Buffer *, const string &, const string &, const string &, const string &, bool)': insetcite.C:65: passing `const Buffer' as `this' argument of `const vector, allocator > > Buffer::getBibkeyList ()' discards qualifiers make[3]: *** [insetcite.lo] Error 1 make[3]: Leaving directory `/home/leuven/cvs/lyx-devel/src/insets' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/leuven/cvs/lyx-devel/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/leuven/cvs/lyx-devel/
Re: natbib citations
On Tuesday 16 April 2002 1:26 pm, Edwin Leuven wrote: > > All works very well here, but I'd like some volunteer testers please. No > > testers, no apply... > > applied patch but compile breaks down... I think that this is saying that Buffer::getBibkeyList() is non-const so a Buffer const * can't access it. You should "cvs update" because in current cvs Buffer::getBibkeyList() is const. Angus > g++ -DHAVE_CONFIG_H -I. -I. -I../../src -I./../ -I../.. -I../../boost > -isystem /usr/X11R6/include -g -O -fno-exceptions -W -Wall -c insetcite.C > -MT insetcite.lo -MD -MP -MF .deps/insetcite.TPlo > In file included from ../../src/Lsstream.h:20, > from ../../src/support/lstrings.h:24, > from insetcite.C:28: > /usr/include/g++-3/sstream: In method `int stringbuf::sync ()': > /usr/include/g++-3/sstream:171: warning: comparison between signed and > unsigned integer expressions > insetcite.C: In function `const string {unnamed}::getNatbibLabel (const > Buffer *, const string &, const string &, const string &, const string > &, bool)': > insetcite.C:65: passing `const Buffer' as `this' argument of `const > vector, allocator > > > Buffer::getBibkeyList ()' discards qualifiers > make[3]: *** [insetcite.lo] Error 1 > make[3]: Leaving directory `/home/leuven/cvs/lyx-devel/src/insets' > make[2]: *** [all-recursive] Error 1 > make[2]: Leaving directory `/home/leuven/cvs/lyx-devel/src' > make[1]: *** [all] Error 2 > make[1]: Leaving directory `/home/leuven/cvs/lyx-devel/
Re: natbib citations
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> 3. Most importantly, I want to Angus> minimise the footprint of any changes I'm making. The current Angus> patch affects the citation inset only and either works or Angus> doesn't work. That makes sense. Angus> Having said all this, I'm happy to add a bool to Buffer. Do you Angus> think that that is a Good Idea at this stage? No, you're probably right. Angus> As an aside, I have implemented ascii export too here. Good. JMarc
Re: natbib citations
Herbert == Herbert Voss [EMAIL PROTECTED] writes: Herbert a diff which - gives wysiwyg natbib labels and standard Herbert behaviour without natbib. - supports the before input Herbert textfield in the gui - fixes another bug with familyName in Herbert biblio.C Herbert, could you post a reduced patch now that Angus has applied the easy parts? I did not tried it but looks at the patch, and I like it much more than the previous one. I am willing to apply it if it works (or wait until 1.2.1 if lars says so). JMarc
Re: natbib citations
On Monday 15 April 2002 4:06 pm, Jean-Marc Lasgouttes wrote: Herbert == Herbert Voss [EMAIL PROTECTED] writes: Herbert a diff which - gives wysiwyg natbib labels and standard Herbert behaviour without natbib. - supports the before input Herbert textfield in the gui - fixes another bug with familyName in Herbert biblio.C Herbert, could you post a reduced patch now that Angus has applied the easy parts? I did not tried it but looks at the patch, and I like it much more than the previous one. I am willing to apply it if it works (or wait until 1.2.1 if lars says so). JMarc Herbert, please don't bother. I am extremely ambivalent about the (before)(after) stuff and so have stripped out the screen label stuff on it's own. I have also got this thing working with numerical bibtex citation style. Moreover, I cache the label as it's a lot of work to compute it. I'll resubmit my re-workings of your patch if a little while (half hour or so). This touches just insetcite.[Ch]. We can then verify that all works as desired. We can then either leave things as they are for 1.2 or add the before/after stuff as a separate patch. Regards, Angus
Re: natbib citations
On Sunday 14 April 2002 5:17 pm, Herbert Voss wrote: a diff which - gives wysiwyg natbib labels and standard behaviour without natbib. - supports the before input textfield in the gui - fixes another bug with familyName in biblio.C the citation-string looks like: \citet[before/endbeforeafter/endafter]{...bibkeys...} switching between the different modes and between with or without a bibtex-datafile is no problem. Herbert I've already applied the easy parts of your patch. I'm extremely ambivalent about the before/after parts. I don't think we should change the LyX file format before 1.2. I think that the screen label part of the patch is fine, although I've modified it to work with numerical natbib citations and to cache the label. Attached are my re-workings. Note that, should we decide to add the before/after part, then this will not affect the stuff here. It will just work. Could those out there who use natbib test this patch to destruction please. Regards, Angus insetcite.diff.gz Description: GNU Zip compressed data
Re: natbib citations
> "Herbert" == Herbert Voss <[EMAIL PROTECTED]> writes: Herbert> a diff which - gives wysiwyg natbib labels and standard Herbert> behaviour without natbib. - supports the "before" input Herbert> textfield in the gui - fixes another bug with familyName in Herbert> biblio.C Herbert, could you post a reduced patch now that Angus has applied the easy parts? I did not tried it but looks at the patch, and I like it much more than the previous one. I am willing to apply it if it works (or wait until 1.2.1 if lars says so). JMarc
Re: natbib citations
On Monday 15 April 2002 4:06 pm, Jean-Marc Lasgouttes wrote: > > "Herbert" == Herbert Voss <[EMAIL PROTECTED]> writes: > > Herbert> a diff which - gives wysiwyg natbib labels and standard > Herbert> behaviour without natbib. - supports the "before" input > Herbert> textfield in the gui - fixes another bug with familyName in > Herbert> biblio.C > > Herbert, could you post a reduced patch now that Angus has applied the > easy parts? I did not tried it but looks at the patch, and I like it > much more than the previous one. I am willing to apply it if it works > (or wait until 1.2.1 if lars says so). > > JMarc Herbert, please don't bother. I am extremely ambivalent about the (before)(after) stuff and so have stripped out the screen label stuff on it's own. I have also got this thing working with numerical bibtex citation style. Moreover, I cache the label as it's a lot of work to compute it. I'll resubmit my re-workings of your patch if a little while (half hour or so). This "touches" just insetcite.[Ch]. We can then verify that all works as desired. We can then either leave things as they are for 1.2 or add the before/after stuff as a separate patch. Regards, Angus
Re: natbib citations
On Sunday 14 April 2002 5:17 pm, Herbert Voss wrote: > a diff which > - gives wysiwyg natbib labels and standard behaviour >without natbib. > - supports the "before" input textfield in the gui > - fixes another bug with familyName in biblio.C > > > the citation-string looks like: > > \citet[]{...bibkeys...} > > switching between the different modes and between with or without > a bibtex-datafile is no problem. > > Herbert I've already applied the "easy" parts of your patch. I'm extremely ambivalent about the before/after parts. I don't think we should change the LyX file format before 1.2. I think that the screen label part of the patch is fine, although I've modified it to work with numerical natbib citations and to cache the label. Attached are my re-workings. Note that, should we decide to add the before/after part, then this will not affect the stuff here. It will just work. Could those out there who use natbib test this patch to destruction please. Regards, Angus insetcite.diff.gz Description: GNU Zip compressed data
natbib citations
a diff which - gives wysiwyg natbib labels and standard behaviour without natbib. - supports the before input textfield in the gui - fixes another bug with familyName in biblio.C the citation-string looks like: \citet[before/endbeforeafter/endafter]{...bibkeys...} switching between the different modes and between with or without a bibtex-datafile is no problem. Herbert -- http://www.lyx.org/help/ Index: src/frontends/controllers/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.159 diff -u -r1.159 ChangeLog --- src/frontends/controllers/ChangeLog 12 Apr 2002 15:25:11 - 1.159 +++ src/frontends/controllers/ChangeLog 14 Apr 2002 16:11:26 - @@ -1,3 +1,12 @@ +2002-04-14 Herbert Voss [EMAIL PROTECTED] + + * ControlCitation.[Ch] + * biblio.[Ch]: show natbib citationlabels in wysiwyg. handle + before and after strings for citations + + * helper_funcs.[Ch]: move the getVectorFromString and the vice versa + into the support/lstrings for better use in other programs + 2002-04-11 Herbert Voss [EMAIL PROTECTED] * ControlGraphics.C: expand browse-string to all available formats Index: src/frontends/controllers/ControlCitation.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCitation.C,v retrieving revision 1.18 diff -u -r1.18 ControlCitation.C --- src/frontends/controllers/ControlCitation.C 21 Mar 2002 21:21:27 - 1.18 +++ src/frontends/controllers/ControlCitation.C 14 Apr 2002 16:11:26 - @@ -1,14 +1,10 @@ -/* This file is part of - * == - * - * LyX, The Document Processor - * - * Copyright 2001 The LyX Team. - * - * == - * +/** * \file ControlCitation.C - * \author Angus Leeming [EMAIL PROTECTED] + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, [EMAIL PROTECTED] + * \author Herbert Voss, [EMAIL PROTECTED] 2002-03-17 */ #include config.h @@ -25,13 +21,14 @@ #include Dialogs.h #include LyXView.h +#include support/lstrings.h + // need to #include this in _one_ of the ControlCommand-derived classses in // order to instantiate // ControlInsetInsetCommand, InsetCommandParams::showInset // ControlInsetInsetCommand, InsetCommandParams::createInset #include ControlInset.tmpl - using std::pair; using std::vector; using SigC::slot; @@ -100,4 +97,51 @@ styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs); return styles; +} + + +string const ControlCitation::getBeforeString() const +{ + string const options = params().getOptions(); + if (!contains(options,\\before)) + return string(); + else { + string::size_type start, countChars; + start = options.find(\\before)+9; + countChars = options.find(\\end_before)-start; + return options.substr(start,countChars); + } +} + + +string const ControlCitation::getAfterString() const +{ + string const options = params().getOptions(); + if (!contains(options,\\after)) + return string(); + else { + string::size_type start, countChars; + start = options.find(\\after)+8; + countChars = options.find(\\end_after)-start; + return options.substr(start,countChars); + } +} + + +void ControlCitation::setCiteOptions( + string const before, + string const after) { + // we save the oiptions in the form + // before.../endbeforeafter.../endafter + // until we have multiple options for citations + if (!usingNatbib()) + params().setOptions(after); + else { + string ba; // holds the before- and after-part + if (!before.empty()) + ba += (\\before+before+\\end_before); + if (!after.empty()) + ba += (\\after+after+\\end_after); + params().setOptions(ba); + } } Index: src/frontends/controllers/ControlCitation.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCitation.h,v retrieving revision 1.12 diff -u -r1.12 ControlCitation.h --- src/frontends/controllers/ControlCitation.h 21 Mar 2002 21:21:27 - 1.12 +++ src/frontends/controllers/ControlCitation.h 14 Apr 2002 16:11:26 - @@ -42,6 +42,17 @@ static std::vectorbiblio::CiteStyle const getCiteStyles() { return citeStyles_; } + /// return the before-part of the option string + string const getBeforeString() const; + + /// return the after-part
natbib citations
a diff which - gives wysiwyg natbib labels and standard behaviour without natbib. - supports the "before" input textfield in the gui - fixes another bug with familyName in biblio.C the citation-string looks like: \citet[]{...bibkeys...} switching between the different modes and between with or without a bibtex-datafile is no problem. Herbert -- http://www.lyx.org/help/ Index: src/frontends/controllers/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.159 diff -u -r1.159 ChangeLog --- src/frontends/controllers/ChangeLog 12 Apr 2002 15:25:11 - 1.159 +++ src/frontends/controllers/ChangeLog 14 Apr 2002 16:11:26 - @@ -1,3 +1,12 @@ +2002-04-14 Herbert Voss <[EMAIL PROTECTED]> + + * ControlCitation.[Ch] + * biblio.[Ch]: show natbib citationlabels in wysiwyg. handle + before and after strings for citations + + * helper_funcs.[Ch]: move the getVectorFromString and the vice versa + into the support/lstrings for better use in other programs + 2002-04-11 Herbert Voss <[EMAIL PROTECTED]> * ControlGraphics.C: expand "browse-string" to all available formats Index: src/frontends/controllers/ControlCitation.C === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCitation.C,v retrieving revision 1.18 diff -u -r1.18 ControlCitation.C --- src/frontends/controllers/ControlCitation.C 21 Mar 2002 21:21:27 - 1.18 +++ src/frontends/controllers/ControlCitation.C 14 Apr 2002 16:11:26 - @@ -1,14 +1,10 @@ -/* This file is part of - * == - * - * LyX, The Document Processor - * - * Copyright 2001 The LyX Team. - * - * == - * +/** * \file ControlCitation.C - * \author Angus Leeming <[EMAIL PROTECTED]> + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, [EMAIL PROTECTED] + * \author Herbert Voss, [EMAIL PROTECTED] 2002-03-17 */ #include @@ -25,13 +21,14 @@ #include "Dialogs.h" #include "LyXView.h" +#include "support/lstrings.h" + // need to #include this in _one_ of the ControlCommand-derived classses in // order to instantiate // ControlInset::showInset // ControlInset ::createInset #include "ControlInset.tmpl" - using std::pair; using std::vector; using SigC::slot; @@ -100,4 +97,51 @@ styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs); return styles; +} + + +string const ControlCitation::getBeforeString() const +{ + string const options = params().getOptions(); + if (!contains(options,"<\\before>")) + return string(); + else { + string::size_type start, countChars; + start = options.find("<\\before>")+9; + countChars = options.find("<\\end_before>")-start; + return options.substr(start,countChars); + } +} + + +string const ControlCitation::getAfterString() const +{ + string const options = params().getOptions(); + if (!contains(options,"<\\after>")) + return string(); + else { + string::size_type start, countChars; + start = options.find("<\\after>")+8; + countChars = options.find("<\\end_after>")-start; + return options.substr(start,countChars); + } +} + + +void ControlCitation::setCiteOptions( + string const & before, + string const & after) { + // we save the oiptions in the form + // .. + // until we have multiple options for citations + if (!usingNatbib()) + params().setOptions(after); + else { + string ba; // holds the before- and after-part + if (!before.empty()) + ba += ("<\\before>"+before+"<\\end_before>"); + if (!after.empty()) + ba += ("<\\after>"+after+"<\\end_after>"); + params().setOptions(ba); + } } Index: src/frontends/controllers/ControlCitation.h === RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCitation.h,v retrieving revision 1.12 diff -u -r1.12 ControlCitation.h --- src/frontends/controllers/ControlCitation.h 21 Mar 2002 21:21:27 - 1.12 +++ src/frontends/controllers/ControlCitation.h 14 Apr 2002 16:11:26 - @@ -42,6 +42,17 @@ static std::vector const & getCiteStyles() { return citeStyles_; } + /// return the "before"-part of the option string + string const getBeforeString() const; + + /// return the "after"-part of the option