I was approached by Manuel de la Torre Juáz from Jet Propulsion Lab with
this problem: it doesn't work, although it ought to.

Digging produced the following status.

- There is a mechanism for detecting whether the class file loads by
itself natbib. This is the .layout file entry

ProvidesNatbib          1

- Unfortunately this doesn't work:

1) It doesn't bring up the citep, citet etc. alternatives in the
citation dialog. Only manually loading natbib does.

2) Even if 1) is fixed, it doesn't output citep, citet etc. to LaTeX.

The attached patches make both these mechanisms respond to the
ProvidesNatbib textclass flag. I am not sure I did this right -- 
I am especially uncertain about the handling of the numeric vs.
author-year thing. Shouldn't this also be in the .layout file if the
class is loading natbib?

I suppose that if this solution is acceptable, it should go into 1.4
also. So Manuel will get it in time for the April EGS meeting in Vienna
:-)

- Martin

Index: egs.layout
===================================================================
--- egs.layout  (revision 17353)
+++ egs.layout  (working copy)
@@ -12,6 +12,7 @@
 Columns                 2
 Sides                   1
 PageStyle               Plain
+ProvidesNatbib          1
 
 
 Style Standard
Index: insets/insetcite.C
===================================================================
--- insets/insetcite.C  (revision 17353)
+++ insets/insetcite.C  (working copy)
@@ -424,7 +424,11 @@
 int InsetCitation::latex(Buffer const & buffer, odocstream & os,
                          OutputParams const &) const
 {
-       biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+       biblio::CiteEngine cite_engine;
+       if (buffer.params().getLyXTextClass().provides(LyXTextClass::natbib))
+               cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+       else    
+               cite_engine = buffer.params().cite_engine;
        // FIXME UNICODE
        docstring const cite_str = from_utf8(
                biblio::asValidLatexCommand(getCmdName(), cite_engine));
@@ -451,7 +455,8 @@
                break;
        case biblio::ENGINE_NATBIB_AUTHORYEAR:
        case biblio::ENGINE_NATBIB_NUMERICAL:
-               features.require("natbib");
+               if 
(!features.bufferParams().getLyXTextClass().provides(LyXTextClass::natbib))
+                       features.require("natbib");
                break;
        case biblio::ENGINE_JURABIB:
                features.require("jurabib");
Index: frontends/controllers/biblio.C
===================================================================
--- frontends/controllers/biblio.C      (revision 17353)
+++ frontends/controllers/biblio.C      (working copy)
@@ -690,7 +690,14 @@
 
 CiteEngine_enum getEngine(Buffer const & buffer)
 {
-       return buffer.params().cite_engine;
+       BufferParams const & p = buffer.params();
+       if (p.getLyXTextClass().provides(LyXTextClass::natbib)) {
+               if (p.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL)
+                       return ENGINE_NATBIB_NUMERICAL;
+               else
+                       return ENGINE_NATBIB_AUTHORYEAR;
+       } else
+               return p.cite_engine;
 }
 
 

Attachment: pgpafAz082vws.pgp
Description: PGP signature

Reply via email to