]> git.lyx.org Git - features.git/commitdiff
What is output as \eqref under prettyref needs to be handled differently
authorRichard Heck <rgheck@comcast.net>
Sun, 13 Mar 2011 20:29:52 +0000 (20:29 +0000)
committerRichard Heck <rgheck@comcast.net>
Sun, 13 Mar 2011 20:29:52 +0000 (20:29 +0000)
under refstyle, since (a) the default refstyle.cfg defines \eqref itself
and (b) does NOT define it the way AMS does. So we simply output:
(\ref{label})
in this case, to match what we say in the UI.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37918 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetRef.cpp

index 5322b3bba3efb52fdeba2021976a16e862a56c69..17184e51f6333291430073a9ddd586a2aa37556f 100644 (file)
@@ -82,7 +82,8 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
 // 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
@@ -139,7 +140,11 @@ docstring InsetRef::getEscapedLabel(OutputParams const & rp) const
 void InsetRef::latex(otexstream & os, OutputParams const & rp) const
 {
        string const cmd = getCmdName();
-       if (cmd != "formatted") {
+
+       // refstyle defines its own version of \eqref
+       if (cmd != "formatted" &&
+           !(cmd == "eqref" && buffer().params().use_refstyle)
+          ) {
                // 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);
@@ -147,10 +152,18 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const
                p["reference"] = ref;
                os << p.getCommand(rp);
                return;
-       } 
-       
-       // so we're doing a formatted reference.
+       }
+
+       // so we're doing a formatted reference of some kind.
        docstring const data = getEscapedLabel(rp);
+
+       // what we say in the UI is that an "eqref" is supposed to surround the
+       // reference with parentheses, so let's do that.
+       if (cmd == "eqref" /* && buffer().params().use_refstyle */) {
+               os << '(' << from_ascii("\\ref{") << data << from_ascii("})");
+               return;
+       }
+
        docstring label;
        docstring prefix;
        docstring const fcmd = getFormattedCmd(data, label, prefix);