X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetRef.cpp;h=bae4992f66f156cb22cf9126ec652698adf30bca;hb=9c4929ca406091267dafa40f5e083a27db046bf6;hp=4bbb38d46602071bf2985273a40ca67d8c0104af;hpb=72ad0bdfbf380743c9c5705f29ba62042e4360b1;p=lyx.git diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 4bbb38d466..bae4992f66 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -142,7 +142,14 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const string const cmd = getCmdName(); docstring const data = getEscapedLabel(rp); + if (rp.inulemcmd) + os << "\\mbox{"; + if (cmd == "eqref" && buffer().params().use_refstyle) { + // we advertise this as printing "(n)", so we'll do that, at least + // for refstyle, since refstlye's own \eqref prints, by default, + // "equation n". if one wants \eqref, one can get it by using a + // formatted label in this case. os << '(' << from_ascii("\\ref{") << data << from_ascii("})"); } else if (cmd == "formatted") { @@ -159,6 +166,9 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const p["reference"] = ref; os << p.getCommand(rp); } + + if (rp.inulemcmd) + os << "}"; } @@ -215,7 +225,7 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const 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") @@ -263,7 +273,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType) } label += ref; - if (!buffer().isLatex() && !getParam("name").empty()) { + if (!buffer().params().isLatex() && !getParam("name").empty()) { label += "||"; label += getParam("name"); } @@ -302,13 +312,13 @@ void InsetRef::validate(LaTeXFeatures & features) const 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}}}"; @@ -322,8 +332,8 @@ void InsetRef::validate(LaTeXFeatures & features) const if (prefix == "chap") features.addPreambleSnippet("\\let\\pr@chap=\\pr@cha"); } - } else if (getCmdName() == "eqref" && !buffer().params().use_refstyle) - // refstyle defines its own version + } else if (cmd == "eqref" && !buffer().params().use_refstyle) + // with refstyle, we simply output "(\ref{label})" features.require("amsmath"); else if (cmd == "nameref") features.require("nameref");