mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Fix a bug in getFormattedReference().
Also, change from using the "cha" prefix for chapters, a la prettyref, to the "chap" prefix, a la refstyle. We alias \pr@chap to \pr@cha for prettyref users. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36238 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8271acc48b
commit
6f76593069
@ -14,7 +14,7 @@ IfStyle Part
|
||||
End
|
||||
|
||||
IfStyle Chapter
|
||||
RefPrefix cha
|
||||
RefPrefix chap
|
||||
End
|
||||
|
||||
IfStyle Section
|
||||
|
@ -92,8 +92,15 @@ docstring InsetRef::getFormattedCmd(docstring const & ref,
|
||||
label = split(ref, prefix, ':');
|
||||
|
||||
// we have to have xxx:xxxxx...
|
||||
if (label.empty()) {
|
||||
LYXERR0("Label `" << ref << "' contains no prefix.");
|
||||
label = ref;
|
||||
prefix = from_ascii("");
|
||||
return defcmd;
|
||||
}
|
||||
|
||||
if (prefix.empty()) {
|
||||
LYXERR0("Label `" << label << "' contains no prefix.");
|
||||
// we have ":xxxx"
|
||||
label = ref;
|
||||
return defcmd;
|
||||
}
|
||||
@ -283,19 +290,25 @@ void InsetRef::validate(LaTeXFeatures & features) const
|
||||
if (cmd == "vref" || cmd == "vpageref")
|
||||
features.require("varioref");
|
||||
else if (getCmdName() == "formatted") {
|
||||
docstring const data = getEscapedLabel(features.runparams());
|
||||
docstring label;
|
||||
docstring prefix;
|
||||
if (buffer().params().use_refstyle) {
|
||||
features.require("refstyle");
|
||||
docstring const data = getEscapedLabel(features.runparams());
|
||||
docstring label;
|
||||
docstring prefix;
|
||||
string const fcmd = to_utf8(getFormattedCmd(data, label, prefix));
|
||||
if (!prefix.empty()) {
|
||||
string lcmd = "\\AtBeginDocument{\\providecommand" +
|
||||
fcmd + "[1]{\\ref{" + to_utf8(prefix) + ":#1}}}";
|
||||
features.addPreambleSnippet(lcmd);
|
||||
}
|
||||
} else
|
||||
} else if (prefix == "cha")
|
||||
features.addPreambleSnippet("\\let\\charef=\\chapref");
|
||||
} else {
|
||||
features.require("prettyref");
|
||||
// prettyref uses "cha" for chapters, so we provide a kind of
|
||||
// translation.
|
||||
if (prefix == "chap")
|
||||
features.addPreambleSnippet("\\let\\pr@chap=\\pr@cha");
|
||||
}
|
||||
} else if (getCmdName() == "eqref" && !buffer().params().use_refstyle)
|
||||
// refstyle defines its own version
|
||||
features.require("amsmath");
|
||||
|
Loading…
Reference in New Issue
Block a user