mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix bug in fallback reference output with refstyle. Based on idea by
Jean-Pierre Chretien. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36211 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0c466ad007
commit
19aa16756c
@ -70,16 +70,25 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
|
||||
}
|
||||
|
||||
|
||||
// for refstyle, given pfx:suffix, we want to return "\\pfxcmd"
|
||||
// and put "suffix" into label.
|
||||
// otherwise, we put the reference into label.
|
||||
docstring InsetRef::getFormattedCmd(
|
||||
docstring const & ref, docstring & label) const
|
||||
// the ref argument is the label name we are referencing.
|
||||
// we expect ref to be in the form: pfx:suffix.
|
||||
//
|
||||
// if it isn't, then we can't produce a formatted reference,
|
||||
// so we return "\ref" and put ref into label.
|
||||
//
|
||||
// for refstyle, we return "\pfxcmd", and put suffix into
|
||||
// label and pfx into prefix. this is because refstyle expects
|
||||
// the command: \pfxcmd{suffix}.
|
||||
//
|
||||
// for prettyref, we return "\prettyref" and put ref into label
|
||||
// and pfx into prefix. this is because prettyref
|
||||
//
|
||||
docstring InsetRef::getFormattedCmd(docstring const & ref,
|
||||
docstring & label, docstring & prefix) const
|
||||
{
|
||||
static docstring const defcmd = from_ascii("\\ref");
|
||||
static docstring const prtcmd = from_ascii("\\prettyref");
|
||||
|
||||
docstring prefix;
|
||||
label = split(ref, prefix, ':');
|
||||
|
||||
// we have to have xxx:xxxxx...
|
||||
@ -134,7 +143,8 @@ int InsetRef::latex(odocstream & os, OutputParams const & rp) const
|
||||
// so we're doing a formatted reference.
|
||||
docstring const data = getEscapedLabel(rp);
|
||||
docstring label;
|
||||
docstring const fcmd = getFormattedCmd(data, label);
|
||||
docstring prefix;
|
||||
docstring const fcmd = getFormattedCmd(data, label, prefix);
|
||||
os << fcmd << '{' << label << '}';
|
||||
return 0;
|
||||
}
|
||||
@ -277,9 +287,11 @@ void InsetRef::validate(LaTeXFeatures & features) const
|
||||
features.require("refstyle");
|
||||
docstring const data = getEscapedLabel(features.runparams());
|
||||
docstring label;
|
||||
string const fcmd = to_utf8(getFormattedCmd(data, label));
|
||||
if (fcmd != "\\ref") {
|
||||
string lcmd = "\\AtBeginDocument{\\providecommand" + fcmd + "[1]{\\ref{#1}}}";
|
||||
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
|
||||
|
@ -101,8 +101,11 @@ private:
|
||||
/// \return the label with things that need to be escaped escaped
|
||||
docstring getEscapedLabel(OutputParams const &) const;
|
||||
/// \return the command for a formatted reference to ref
|
||||
/// \param label gets what follows the prefix, for refstyle
|
||||
docstring getFormattedCmd(docstring const & ref, docstring & label) const;
|
||||
/// \param label we're cross-referencing
|
||||
/// \param argument for reference command
|
||||
/// \param prefix of the label (before :)
|
||||
docstring getFormattedCmd(docstring const & ref, docstring & label,
|
||||
docstring & prefix) const;
|
||||
|
||||
///
|
||||
mutable docstring screen_label_;
|
||||
|
Loading…
Reference in New Issue
Block a user