// the command: \pfxcmd{suffix}.
//
// for prettyref, we return "\prettyref" and put ref into label
-// and pfx into prefix. this is because prettyref
+// and pfx into prefix. this is because prettyref uses the whole
+// label, thus: \prettyref{pfx:suffix}.
//
docstring InsetRef::getFormattedCmd(docstring const & ref,
docstring & label, docstring & prefix) const
void InsetRef::latex(otexstream & os, OutputParams const & rp) const
{
string const cmd = getCmdName();
- if (cmd != "formatted") {
+ docstring const data = getEscapedLabel(rp);
+
+ if (cmd == "eqref" && buffer().params().use_refstyle) {
+ os << '(' << from_ascii("\\ref{") << data << from_ascii("})");
+ }
+ else if (cmd == "formatted") {
+ docstring label;
+ docstring prefix;
+ docstring const fcmd = getFormattedCmd(data, label, prefix);
+ os << fcmd << '{' << label << '}';
+ }
+ else {
// We don't want to output p_["name"], since that is only used
// in docbook. So we construct new params, without it, and use that.
InsetCommandParams p(REF_CODE, cmd);
docstring const ref = getParam("reference");
p["reference"] = ref;
os << p.getCommand(rp);
- return;
- }
-
- // so we're doing a formatted reference.
- docstring const data = getEscapedLabel(rp);
- docstring label;
- docstring prefix;
- docstring const fcmd = getFormattedCmd(data, label, prefix);
- os << fcmd << '{' << label << '}';
+ }
}
display_string = _("elsewhere");
else if (cmd == "eqref")
display_string = bformat(from_ascii("equation (%1$s)"), value);
- else if (cmd == "prettyref"
+ else if (cmd == "formatted"
// we don't really have the ability to handle these
// properly in XHTML output
|| cmd == "nameref")
}
label += ref;
- if (!buffer().isLatex() && !getParam("name").empty()) {
+ if (!buffer().params().isLatex() && !getParam("name").empty()) {
label += "||";
label += getParam("name");
}
string const cmd = getCmdName();
if (cmd == "vref" || cmd == "vpageref")
features.require("varioref");
- else if (getCmdName() == "formatted") {
+ else if (cmd == "formatted") {
docstring const data = getEscapedLabel(features.runparams());
docstring label;
docstring prefix;
+ string const fcmd = to_utf8(getFormattedCmd(data, label, prefix));
if (buffer().params().use_refstyle) {
features.require("refstyle");
- string const fcmd = to_utf8(getFormattedCmd(data, label, prefix));
if (!prefix.empty()) {
string lcmd = "\\AtBeginDocument{\\providecommand" +
fcmd + "[1]{\\ref{" + to_utf8(prefix) + ":#1}}}";
if (prefix == "chap")
features.addPreambleSnippet("\\let\\pr@chap=\\pr@cha");
}
- } else if (getCmdName() == "eqref" && !buffer().params().use_refstyle)
+ } else if (cmd == "eqref" && !buffer().params().use_refstyle)
// refstyle defines its own version
features.require("amsmath");
else if (cmd == "nameref")