mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
Buffer param \cite_engine_type (authoryear|numerical).
To avoid duplicity, remove natbib_authoryear and natbib_numerical and replace them by natbib, and keep track of the engine `type' in the new \cite_engine_type document setting. This will make it easier to add more citation engines. LyX format incremented to 424. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40592 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
db9e633b7f
commit
e3f65fd088
@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2012-01-09 Julien Rioux <jrioux@lyx.org>
|
||||
* Format incremented to 424 (r40592)
|
||||
New buffer param \cite_engine_type to specify the type of
|
||||
citation labels being used, authoryear or numerical.
|
||||
|
||||
2012-01-05 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
* Format incremented to 423 (r40574)
|
||||
support for the LaTeX-package mathtools (fix bug 7949)
|
||||
|
@ -419,6 +419,37 @@ def revert_use_mathtools(document):
|
||||
i = j
|
||||
|
||||
|
||||
def convert_cite_engine_type(document):
|
||||
"Determine the \\cite_engine_type from the citation engine."
|
||||
i = find_token(document.header, "\\cite_engine", 0)
|
||||
if i == -1:
|
||||
return
|
||||
engine = get_value(document.header, "\\cite_engine", i)
|
||||
if "_" in engine:
|
||||
engine, type = engine.split("_")
|
||||
else:
|
||||
type = {"basic": "numerical", "jurabib": "authoryear"}[engine]
|
||||
document.header[i] = "\\cite_engine " + engine
|
||||
document.header.insert(i + 1, "\\cite_engine_type " + type)
|
||||
|
||||
|
||||
def revert_cite_engine_type(document):
|
||||
"Natbib had the type appended with an underscore."
|
||||
engine_type = "numerical"
|
||||
i = find_token(document.header, "\\cite_engine_type" , 0)
|
||||
if i == -1:
|
||||
document.warning("No \\cite_engine_type line. Assuming numerical.")
|
||||
else:
|
||||
engine_type = get_value(document.header, "\\cite_engine_type", i)
|
||||
del document.header[i]
|
||||
|
||||
# We are looking for the natbib citation engine
|
||||
i = find_token(document.header, "\\cite_engine natbib", i)
|
||||
if i == -1:
|
||||
return
|
||||
document.header[i] = "\\cite_engine natbib_" + engine_type
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -435,9 +466,11 @@ convert = [
|
||||
[421, [convert_longtable_captions]],
|
||||
[422, [convert_use_packages]],
|
||||
[423, [convert_use_mathtools]],
|
||||
[424, [convert_cite_engine_type]],
|
||||
]
|
||||
|
||||
revert = [
|
||||
[423, [revert_cite_engine_type]],
|
||||
[422, [revert_use_mathtools]],
|
||||
[421, [revert_use_packages]],
|
||||
[420, [revert_longtable_captions]],
|
||||
|
@ -692,8 +692,8 @@ bool BiblioInfo::isBibtex(docstring const & key) const
|
||||
vector<docstring> const BiblioInfo::getCiteStrings(
|
||||
docstring const & key, Buffer const & buf) const
|
||||
{
|
||||
CiteEngine const engine = buf.params().citeEngine();
|
||||
if (engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL)
|
||||
CiteEngineType const engine_type = buf.params().citeEngineType();
|
||||
if (engine_type == ENGINE_TYPE_NUMERICAL)
|
||||
return getNumericalStrings(key, buf);
|
||||
else
|
||||
return getAuthorYearStrings(key, buf);
|
||||
@ -711,7 +711,8 @@ vector<docstring> const BiblioInfo::getNumericalStrings(
|
||||
if (author.empty() || year.empty())
|
||||
return vector<docstring>();
|
||||
|
||||
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine());
|
||||
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine(),
|
||||
buf.params().citeEngineType());
|
||||
|
||||
vector<docstring> vec(styles.size());
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
@ -770,7 +771,8 @@ vector<docstring> const BiblioInfo::getAuthorYearStrings(
|
||||
if (author.empty() || year.empty())
|
||||
return vector<docstring>();
|
||||
|
||||
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine());
|
||||
vector<CiteStyle> const & styles = citeStyles(buf.params().citeEngine(),
|
||||
buf.params().citeEngineType());
|
||||
|
||||
vector<docstring> vec(styles.size());
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
@ -892,9 +894,8 @@ void BiblioInfo::collectCitedEntries(Buffer const & buf)
|
||||
void BiblioInfo::makeCitationLabels(Buffer const & buf)
|
||||
{
|
||||
collectCitedEntries(buf);
|
||||
CiteEngine const engine = buf.params().citeEngine();
|
||||
bool const numbers =
|
||||
(engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL);
|
||||
CiteEngineType const engine_type = buf.params().citeEngineType();
|
||||
bool const numbers = (engine_type == ENGINE_TYPE_NUMERICAL);
|
||||
|
||||
int keynumber = 0;
|
||||
char modifier = 0;
|
||||
@ -1025,17 +1026,18 @@ string citationStyleToString(const CitationStyle & s)
|
||||
return cite;
|
||||
}
|
||||
|
||||
vector<CiteStyle> citeStyles(CiteEngine engine)
|
||||
vector<CiteStyle> citeStyles(CiteEngine engine, CiteEngineType engine_type)
|
||||
{
|
||||
vector<CiteStyle> styles(0);
|
||||
|
||||
switch (engine) {
|
||||
if (engine_type == ENGINE_TYPE_AUTHORYEAR) {
|
||||
switch (engine) {
|
||||
case ENGINE_BASIC:
|
||||
styles.push_back(CITE);
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
styles.push_back(CITE);
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
case ENGINE_NATBIB:
|
||||
styles.push_back(CITET);
|
||||
styles.push_back(CITEP);
|
||||
styles.push_back(CITEALT);
|
||||
@ -1044,7 +1046,15 @@ vector<CiteStyle> citeStyles(CiteEngine engine)
|
||||
styles.push_back(CITEYEAR);
|
||||
styles.push_back(CITEYEARPAR);
|
||||
break;
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
}
|
||||
} else {
|
||||
switch (engine) {
|
||||
case ENGINE_BASIC:
|
||||
styles.push_back(CITE);
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
styles.push_back(CITE);
|
||||
case ENGINE_NATBIB:
|
||||
styles.push_back(CITET);
|
||||
styles.push_back(CITEALT);
|
||||
styles.push_back(CITEAUTHOR);
|
||||
@ -1053,6 +1063,7 @@ vector<CiteStyle> citeStyles(CiteEngine engine)
|
||||
styles.push_back(CITEYEAR);
|
||||
styles.push_back(CITEYEARPAR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
styles.push_back(NOCITE);
|
||||
|
@ -29,7 +29,7 @@ class Buffer;
|
||||
|
||||
/// FIXME: To Citation.cpp?
|
||||
/// Returns a vector of available Citation styles.
|
||||
std::vector<CiteStyle> citeStyles(CiteEngine);
|
||||
std::vector<CiteStyle> citeStyles(CiteEngine, CiteEngineType);
|
||||
/// \param latex_str a LaTeX command, "cite", "Citep*", etc
|
||||
CitationStyle citationStyleFromString(std::string const & latex_str);
|
||||
/// the other way round
|
||||
|
@ -265,8 +265,7 @@ typedef Translator<string, CiteEngine> CiteEngineTranslator;
|
||||
CiteEngineTranslator const init_citeenginetranslator()
|
||||
{
|
||||
CiteEngineTranslator translator("basic", ENGINE_BASIC);
|
||||
translator.addPair("natbib_numerical", ENGINE_NATBIB_NUMERICAL);
|
||||
translator.addPair("natbib_authoryear", ENGINE_NATBIB_AUTHORYEAR);
|
||||
translator.addPair("natbib", ENGINE_NATBIB);
|
||||
translator.addPair("jurabib", ENGINE_JURABIB);
|
||||
return translator;
|
||||
}
|
||||
@ -279,6 +278,24 @@ CiteEngineTranslator const & citeenginetranslator()
|
||||
}
|
||||
|
||||
|
||||
typedef Translator<string, CiteEngineType> CiteEngineTypeTranslator;
|
||||
|
||||
|
||||
CiteEngineTypeTranslator const init_citeenginetypetranslator()
|
||||
{
|
||||
CiteEngineTypeTranslator translator("authoryear", ENGINE_TYPE_AUTHORYEAR);
|
||||
translator.addPair("numerical", ENGINE_TYPE_NUMERICAL);
|
||||
return translator;
|
||||
}
|
||||
|
||||
|
||||
CiteEngineTypeTranslator const & citeenginetypetranslator()
|
||||
{
|
||||
static CiteEngineTypeTranslator translator = init_citeenginetypetranslator();
|
||||
return translator;
|
||||
}
|
||||
|
||||
|
||||
// Spacing
|
||||
typedef Translator<string, Spacing::Space> SpaceTranslator;
|
||||
|
||||
@ -362,6 +379,7 @@ BufferParams::BufferParams()
|
||||
orientation = ORIENTATION_PORTRAIT;
|
||||
use_geometry = false;
|
||||
cite_engine_ = ENGINE_BASIC;
|
||||
cite_engine_type_ = ENGINE_TYPE_NUMERICAL;
|
||||
biblio_style = "plain";
|
||||
use_bibtopic = false;
|
||||
use_indices = false;
|
||||
@ -711,6 +729,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
string engine;
|
||||
lex >> engine;
|
||||
cite_engine_ = citeenginetranslator().find(engine);
|
||||
} else if (token == "\\cite_engine_type") {
|
||||
string engine_type;
|
||||
lex >> engine_type;
|
||||
cite_engine_type_ = citeenginetypetranslator().find(engine_type);
|
||||
} else if (token == "\\biblio_style") {
|
||||
lex.eatLine();
|
||||
biblio_style = lex.getString();
|
||||
@ -1016,6 +1038,7 @@ void BufferParams::writeFile(ostream & os) const
|
||||
os << "\n\\use_package " << packages[i] << ' '
|
||||
<< use_package(packages[i]);
|
||||
os << "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
|
||||
<< "\n\\cite_engine_type " << citeenginetypetranslator().find(cite_engine_type_)
|
||||
<< "\n\\biblio_style " << biblio_style
|
||||
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
|
||||
<< "\n\\use_indices " << convert<string>(use_indices)
|
||||
@ -2922,9 +2945,8 @@ CiteEngine BufferParams::citeEngine() const
|
||||
{
|
||||
// FIXME the class should provide the numerical/
|
||||
// authoryear choice
|
||||
if (documentClass().provides("natbib")
|
||||
&& cite_engine_ != ENGINE_NATBIB_NUMERICAL)
|
||||
return ENGINE_NATBIB_AUTHORYEAR;
|
||||
if (documentClass().provides("natbib"))
|
||||
return ENGINE_NATBIB;
|
||||
return cite_engine_;
|
||||
}
|
||||
|
||||
|
@ -409,6 +409,13 @@ public:
|
||||
///
|
||||
void setCiteEngine(CiteEngine const);
|
||||
|
||||
/// the type of cite engine (authoryear or numerical)
|
||||
CiteEngineType const & citeEngineType() const
|
||||
{ return cite_engine_type_; }
|
||||
/// set the cite engine type
|
||||
void setCiteEngineType(CiteEngineType const & engine_type)
|
||||
{ cite_engine_type_ = engine_type; }
|
||||
|
||||
/// the default BibTeX style file for the document
|
||||
std::string biblio_style;
|
||||
|
||||
@ -472,6 +479,8 @@ private:
|
||||
mutable DefaultFlavorCache default_flavors_;
|
||||
/// for use with natbib
|
||||
CiteEngine cite_engine_;
|
||||
/// the type of cite engine (authoryear or numerical)
|
||||
CiteEngineType cite_engine_type_;
|
||||
///
|
||||
DocumentClass * doc_class_;
|
||||
///
|
||||
|
@ -18,11 +18,15 @@ class Buffer;
|
||||
|
||||
enum CiteEngine {
|
||||
ENGINE_BASIC,
|
||||
ENGINE_NATBIB_AUTHORYEAR,
|
||||
ENGINE_NATBIB_NUMERICAL,
|
||||
ENGINE_NATBIB,
|
||||
ENGINE_JURABIB
|
||||
};
|
||||
|
||||
enum CiteEngineType {
|
||||
ENGINE_TYPE_AUTHORYEAR = 1,
|
||||
ENGINE_TYPE_NUMERICAL = 2,
|
||||
};
|
||||
|
||||
enum CiteStyle {
|
||||
CITE,
|
||||
CITET,
|
||||
|
@ -769,7 +769,7 @@ string const LaTeXFeatures::getPackages() const
|
||||
// This special case is indicated by the "natbib-internal" key.
|
||||
if (mustProvide("natbib") && !tclass.provides("natbib-internal")) {
|
||||
packages << "\\usepackage[";
|
||||
if (params_.citeEngine() == ENGINE_NATBIB_NUMERICAL)
|
||||
if (params_.citeEngineType() == ENGINE_TYPE_NUMERICAL)
|
||||
packages << "numbers";
|
||||
else
|
||||
packages << "authoryear";
|
||||
|
@ -510,10 +510,7 @@ QString GuiBibtex::styleFile() const
|
||||
case ENGINE_BASIC:
|
||||
defaultstyle = "plain";
|
||||
break;
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
defaultstyle = "plainnat";
|
||||
break;
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
case ENGINE_NATBIB:
|
||||
defaultstyle = "plainnat";
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
|
@ -211,9 +211,7 @@ void GuiCitation::updateControls(BiblioInfo const & bi)
|
||||
void GuiCitation::updateFormatting(CiteStyle currentStyle)
|
||||
{
|
||||
CiteEngine const engine = citeEngine();
|
||||
bool const natbib_engine =
|
||||
engine == ENGINE_NATBIB_AUTHORYEAR ||
|
||||
engine == ENGINE_NATBIB_NUMERICAL;
|
||||
bool const natbib_engine = engine == ENGINE_NATBIB;
|
||||
bool const basic_engine = engine == ENGINE_BASIC;
|
||||
|
||||
bool const haveSelection =
|
||||
@ -624,7 +622,8 @@ bool GuiCitation::initialiseParams(string const & data)
|
||||
{
|
||||
InsetCommand::string2params(data, params_);
|
||||
CiteEngine const engine = citeEngine();
|
||||
citeStyles_ = citeStyles(engine);
|
||||
CiteEngineType const engine_type = citeEngineType();
|
||||
citeStyles_ = citeStyles(engine, engine_type);
|
||||
init();
|
||||
return true;
|
||||
}
|
||||
@ -664,6 +663,12 @@ CiteEngine GuiCitation::citeEngine() const
|
||||
}
|
||||
|
||||
|
||||
CiteEngineType GuiCitation::citeEngineType() const
|
||||
{
|
||||
return documentBuffer().params().citeEngineType();
|
||||
}
|
||||
|
||||
|
||||
// Escape special chars.
|
||||
// All characters are literals except: '.|*?+(){}[]^$\'
|
||||
// These characters are literals when preceded by a "\", which is done here
|
||||
|
@ -134,6 +134,8 @@ private:
|
||||
std::vector<docstring> & keyVector, docstring entryType);
|
||||
///
|
||||
CiteEngine citeEngine() const;
|
||||
///
|
||||
CiteEngineType citeEngineType() const;
|
||||
|
||||
/// Search a given string within the passed keys.
|
||||
/// \return the vector of matched keys.
|
||||
|
@ -1132,6 +1132,10 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
|
||||
// biblio
|
||||
biblioModule = new UiWidget<Ui::BiblioUi>;
|
||||
connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(setNumerical(bool)));
|
||||
connect(biblioModule->citeJurabibRB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(setAuthorYear(bool)));
|
||||
connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
|
||||
biblioModule->citationStyleL, SLOT(setEnabled(bool)));
|
||||
connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
|
||||
@ -2045,6 +2049,22 @@ void GuiDocument::bibtexChanged(int n)
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::setAuthorYear(bool authoryear)
|
||||
{
|
||||
if (authoryear)
|
||||
biblioModule->citeStyleCO->setCurrentIndex(0);
|
||||
biblioChanged();
|
||||
}
|
||||
|
||||
|
||||
void GuiDocument::setNumerical(bool numerical)
|
||||
{
|
||||
if (numerical)
|
||||
biblioModule->citeStyleCO->setCurrentIndex(1);
|
||||
biblioChanged();
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
// FIXME unicode
|
||||
// both of these should take a vector<docstring>
|
||||
@ -2279,17 +2299,16 @@ void GuiDocument::applyView()
|
||||
// biblio
|
||||
bp_.setCiteEngine(ENGINE_BASIC);
|
||||
|
||||
if (biblioModule->citeNatbibRB->isChecked()) {
|
||||
bool const use_numerical_citations =
|
||||
biblioModule->citeStyleCO->currentIndex();
|
||||
if (use_numerical_citations)
|
||||
bp_.setCiteEngine(ENGINE_NATBIB_NUMERICAL);
|
||||
else
|
||||
bp_.setCiteEngine(ENGINE_NATBIB_AUTHORYEAR);
|
||||
|
||||
} else if (biblioModule->citeJurabibRB->isChecked())
|
||||
if (biblioModule->citeNatbibRB->isChecked())
|
||||
bp_.setCiteEngine(ENGINE_NATBIB);
|
||||
else if (biblioModule->citeJurabibRB->isChecked())
|
||||
bp_.setCiteEngine(ENGINE_JURABIB);
|
||||
|
||||
if (biblioModule->citeStyleCO->currentIndex())
|
||||
bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
|
||||
else
|
||||
bp_.setCiteEngineType(ENGINE_TYPE_AUTHORYEAR);
|
||||
|
||||
bp_.use_bibtopic =
|
||||
biblioModule->bibtopicCB->isChecked();
|
||||
|
||||
@ -2692,11 +2711,10 @@ void GuiDocument::paramsToDialog()
|
||||
bp_.citeEngine() == ENGINE_BASIC);
|
||||
|
||||
biblioModule->citeNatbibRB->setChecked(
|
||||
bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
|
||||
bp_.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
|
||||
bp_.citeEngine() == ENGINE_NATBIB);
|
||||
|
||||
biblioModule->citeStyleCO->setCurrentIndex(
|
||||
bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL);
|
||||
bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
|
||||
|
||||
biblioModule->citeJurabibRB->setChecked(
|
||||
bp_.citeEngine() == ENGINE_JURABIB);
|
||||
|
@ -107,6 +107,8 @@ private Q_SLOTS:
|
||||
void languagePackageChanged(int);
|
||||
void biblioChanged();
|
||||
void bibtexChanged(int);
|
||||
void setAuthorYear(bool);
|
||||
void setNumerical(bool);
|
||||
void updateModuleInfo();
|
||||
void modulesChanged();
|
||||
void changeBackgroundColor();
|
||||
|
@ -1490,7 +1490,8 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv)
|
||||
if (contains(key, ','))
|
||||
key = qstring_to_ucs4(toqstr(key).split(',')[0]);
|
||||
|
||||
vector<CiteStyle> citeStyleList = citeStyles(buf->params().citeEngine());
|
||||
vector<CiteStyle> citeStyleList = citeStyles(buf->params().citeEngine(),
|
||||
buf->params().citeEngineType());
|
||||
docstring_list citeStrings =
|
||||
buf->masterBibInfo().getCiteStrings(key, bv->buffer());
|
||||
|
||||
|
@ -936,9 +936,8 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
|
||||
{
|
||||
BiblioInfo const & bibinfo = buffer().masterBibInfo();
|
||||
vector<docstring> const & cites = bibinfo.citedEntries();
|
||||
CiteEngine const engine = buffer().params().citeEngine();
|
||||
bool const numbers =
|
||||
(engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL);
|
||||
CiteEngineType const engine_type = buffer().params().citeEngineType();
|
||||
bool const numbers = (engine_type == ENGINE_TYPE_NUMERICAL);
|
||||
|
||||
docstring reflabel = from_ascii("References");
|
||||
Language const * l = buffer().params().language;
|
||||
|
@ -143,18 +143,18 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
|
||||
namespace {
|
||||
|
||||
// FIXME See the header for the issue.
|
||||
string defaultCiteCommand(CiteEngine engine)
|
||||
string defaultCiteCommand(CiteEngine engine, CiteEngineType engine_type)
|
||||
{
|
||||
string str;
|
||||
switch (engine) {
|
||||
case ENGINE_BASIC:
|
||||
str = "cite";
|
||||
break;
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
str = "citet";
|
||||
break;
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
str = "citep";
|
||||
case ENGINE_NATBIB:
|
||||
if (engine_type == ENGINE_TYPE_AUTHORYEAR)
|
||||
str = "citet";
|
||||
else
|
||||
str = "citep";
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
str = "cite";
|
||||
@ -164,9 +164,10 @@ string defaultCiteCommand(CiteEngine engine)
|
||||
}
|
||||
|
||||
|
||||
string asValidLatexCommand(string const & input, CiteEngine const engine)
|
||||
string asValidLatexCommand(string const & input, CiteEngine const engine,
|
||||
CiteEngineType const engine_type)
|
||||
{
|
||||
string const default_str = defaultCiteCommand(engine);
|
||||
string const default_str = defaultCiteCommand(engine, engine_type);
|
||||
if (!InsetCitation::isCompatibleCommand(input))
|
||||
return default_str;
|
||||
|
||||
@ -179,8 +180,7 @@ string asValidLatexCommand(string const & input, CiteEngine const engine)
|
||||
output = default_str;
|
||||
break;
|
||||
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
case ENGINE_NATBIB:
|
||||
if (input == "cite" || input == "citefield"
|
||||
|| input == "citetitle" || input == "cite*")
|
||||
output = default_str;
|
||||
@ -259,8 +259,9 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
|
||||
// CITE: author/<before field>
|
||||
|
||||
CiteEngine const engine = buffer().params().citeEngine();
|
||||
CiteEngineType const engine_type = buffer().params().citeEngineType();
|
||||
// We don't currently use the full or forceUCase fields.
|
||||
string cite_type = asValidLatexCommand(getCmdName(), engine);
|
||||
string cite_type = asValidLatexCommand(getCmdName(), engine, engine_type);
|
||||
if (cite_type[0] == 'C')
|
||||
// If we were going to use them, this would mean ForceUCase
|
||||
cite_type = string(1, 'c') + cite_type.substr(1);
|
||||
@ -350,13 +351,13 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
|
||||
// authors_last (<before> year, <after>)
|
||||
else if (cite_type == "citet") {
|
||||
switch (engine) {
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
label += author + op_str + before_str +
|
||||
wrapCitation(*it, year, for_xhtml) + cp + sep_str;
|
||||
break;
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
label += author + op_str + before_str +
|
||||
wrapCitation(*it, citenum, for_xhtml) + cp + sep_str;
|
||||
case ENGINE_NATBIB:
|
||||
if (engine_type == ENGINE_TYPE_AUTHORYEAR)
|
||||
label += author + op_str + before_str +
|
||||
wrapCitation(*it, year, for_xhtml) + cp + sep_str;
|
||||
else
|
||||
label += author + op_str + before_str +
|
||||
wrapCitation(*it, citenum, for_xhtml) + cp + sep_str;
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
label += before_str + author + op_str +
|
||||
@ -369,7 +370,7 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
|
||||
// author, year; author, year; ...
|
||||
else if (cite_type == "citep" ||
|
||||
cite_type == "citealp") {
|
||||
if (engine == ENGINE_NATBIB_NUMERICAL) {
|
||||
if (engine_type == ENGINE_TYPE_NUMERICAL) {
|
||||
label += wrapCitation(*it, citenum, for_xhtml) + sep_str;
|
||||
} else {
|
||||
label += wrapCitation(*it, author + ", " + year, for_xhtml) + sep_str;
|
||||
@ -380,13 +381,13 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
|
||||
// authors_last <before> year, <after>)
|
||||
else if (cite_type == "citealt") {
|
||||
switch (engine) {
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
label += author + ' ' + before_str +
|
||||
wrapCitation(*it, year, for_xhtml) + sep_str;
|
||||
break;
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
label += author + ' ' + before_str + '#' +
|
||||
wrapCitation(*it, citenum, for_xhtml) + sep_str;
|
||||
case ENGINE_NATBIB:
|
||||
if (engine_type == ENGINE_TYPE_AUTHORYEAR)
|
||||
label += author + ' ' + before_str +
|
||||
wrapCitation(*it, year, for_xhtml) + sep_str;
|
||||
else
|
||||
label += author + ' ' + before_str + '#' +
|
||||
wrapCitation(*it, citenum, for_xhtml) + sep_str;
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
label += before_str +
|
||||
@ -416,7 +417,8 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
|
||||
label.insert(label.size() - 1, after_str);
|
||||
} else {
|
||||
bool const add =
|
||||
!(engine == ENGINE_NATBIB_NUMERICAL &&
|
||||
!(engine == ENGINE_NATBIB &&
|
||||
engine_type == ENGINE_TYPE_NUMERICAL &&
|
||||
(cite_type == "citeauthor" ||
|
||||
cite_type == "citeyear"));
|
||||
if (add)
|
||||
@ -567,10 +569,11 @@ void InsetCitation::forToc(docstring & os, size_t) const
|
||||
void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
CiteEngine cite_engine = buffer().params().citeEngine();
|
||||
CiteEngineType cite_engine_type = buffer().params().citeEngineType();
|
||||
BiblioInfo const & bi = buffer().masterBibInfo();
|
||||
// FIXME UNICODE
|
||||
docstring const cite_str = from_utf8(
|
||||
asValidLatexCommand(getCmdName(), cite_engine));
|
||||
asValidLatexCommand(getCmdName(), cite_engine, cite_engine_type));
|
||||
|
||||
if (runparams.inulemcmd)
|
||||
os << "\\mbox{";
|
||||
@ -600,8 +603,7 @@ void InsetCitation::validate(LaTeXFeatures & features) const
|
||||
switch (features.bufferParams().citeEngine()) {
|
||||
case ENGINE_BASIC:
|
||||
break;
|
||||
case ENGINE_NATBIB_AUTHORYEAR:
|
||||
case ENGINE_NATBIB_NUMERICAL:
|
||||
case ENGINE_NATBIB:
|
||||
features.require("natbib");
|
||||
break;
|
||||
case ENGINE_JURABIB:
|
||||
|
@ -30,7 +30,7 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 423 // baum : \\use_package mathtools
|
||||
#define LYX_FORMAT_LYX 424 // jrioux : \cite_engine_type (authoryear|numerical)
|
||||
#define LYX_FORMAT_TEX2LYX 423
|
||||
|
||||
#if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX
|
||||
|
Loading…
Reference in New Issue
Block a user