autoref and subequations












2















I have an issue with autoref and the subequations environment. I have added the () around the equation reference of autoref (as explained here) and it works fine with normal equations. On the other hand, there is a problem when I use the subequations environment: the letter indicating the subequation is outside the brackets, e.g. I have (3.1)a, both in reference and in the equation.



In the preamble, I have



makeatletter
letoldtheequationtheequation
renewcommandtagform@[1]{maketag@@@{ignorespaces#1unskip@@italiccorr}}
renewcommandtheequation{(oldtheequation)}
makeatother


What I would like to have is (3.1a), both for the equation and the reference. I guess I have to modify the code reported above but I am not sure how to.










share|improve this question



























    2















    I have an issue with autoref and the subequations environment. I have added the () around the equation reference of autoref (as explained here) and it works fine with normal equations. On the other hand, there is a problem when I use the subequations environment: the letter indicating the subequation is outside the brackets, e.g. I have (3.1)a, both in reference and in the equation.



    In the preamble, I have



    makeatletter
    letoldtheequationtheequation
    renewcommandtagform@[1]{maketag@@@{ignorespaces#1unskip@@italiccorr}}
    renewcommandtheequation{(oldtheequation)}
    makeatother


    What I would like to have is (3.1a), both for the equation and the reference. I guess I have to modify the code reported above but I am not sure how to.










    share|improve this question

























      2












      2








      2








      I have an issue with autoref and the subequations environment. I have added the () around the equation reference of autoref (as explained here) and it works fine with normal equations. On the other hand, there is a problem when I use the subequations environment: the letter indicating the subequation is outside the brackets, e.g. I have (3.1)a, both in reference and in the equation.



      In the preamble, I have



      makeatletter
      letoldtheequationtheequation
      renewcommandtagform@[1]{maketag@@@{ignorespaces#1unskip@@italiccorr}}
      renewcommandtheequation{(oldtheequation)}
      makeatother


      What I would like to have is (3.1a), both for the equation and the reference. I guess I have to modify the code reported above but I am not sure how to.










      share|improve this question














      I have an issue with autoref and the subequations environment. I have added the () around the equation reference of autoref (as explained here) and it works fine with normal equations. On the other hand, there is a problem when I use the subequations environment: the letter indicating the subequation is outside the brackets, e.g. I have (3.1)a, both in reference and in the equation.



      In the preamble, I have



      makeatletter
      letoldtheequationtheequation
      renewcommandtagform@[1]{maketag@@@{ignorespaces#1unskip@@italiccorr}}
      renewcommandtheequation{(oldtheequation)}
      makeatother


      What I would like to have is (3.1a), both for the equation and the reference. I guess I have to modify the code reported above but I am not sure how to.







      cross-referencing labels subequations ref autoref






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 12:20









      MattiaP9463MattiaP9463

      111




      111






















          1 Answer
          1






          active

          oldest

          votes


















          1














          I decided to modify autoref instead of theequation. My approach was to add the format to the name definition, so that one could also implement all the subfigure formats. This is not very efficient, but is more easily modified by users.



          documentclass{article}
          usepackage{amsmath}
          usepackage{xstring}
          usepackage{hyperref}

          defequationmyref#1{Equation~(ref*{#1})}% Note: eqref* not defined
          defAMSmyref#1{Equation~(ref*{#1})}% for tag
          deffiguremyref#1{figurename~ref*{#1}}%
          deftablemyref#1{tablename~ref*{#1}}%
          defpartmyref#1{partname~ref*{#1}}%
          defappendixmyref#1{appendixname~ref*{#1}}%
          deftheoremmyref#1{Theorem~ref*{#1}}%

          makeatletter
          newififmyrefstar

          defmyref{@ifstar{myrefstartruemy@ref}{myrefstarfalsemy@ref}}% handkr autoref* arguments

          newcommand{my@ref}[1]{@ifundefined{r@#1}{??}% #1 = label name
          {my@@ref{#1}{getrefbykeydefault{#1}{anchor}{Doc-Start}}}}

          newcommand{my@@ref}[2]% #1 = label, #2 = anchor
          {bgroup
          StrBefore{#2}{.}[myrefname]% parse anchor before {.}
          @ifundefined{myrefname myref}{defmy@@@ref##1{myrefname~ref*{##1}}}%
          {expandafterletexpandaftermy@@@refcsnamemyrefname myrefendcsname}%
          ifmyrefstar
          my@@@ref{#1}%
          else
          hyperlink{#2}{my@@@ref{#1}}%
          fi
          egroup}

          letautoref=myref

          begin{document}
          begin{subequations}
          begin{equation}label{test}
          a=b
          end{equation}
          end{subequations}
          autoref{test}
          autoref*{test}
          end{document}





          share|improve this answer


























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481339%2fautoref-and-subequations%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I decided to modify autoref instead of theequation. My approach was to add the format to the name definition, so that one could also implement all the subfigure formats. This is not very efficient, but is more easily modified by users.



            documentclass{article}
            usepackage{amsmath}
            usepackage{xstring}
            usepackage{hyperref}

            defequationmyref#1{Equation~(ref*{#1})}% Note: eqref* not defined
            defAMSmyref#1{Equation~(ref*{#1})}% for tag
            deffiguremyref#1{figurename~ref*{#1}}%
            deftablemyref#1{tablename~ref*{#1}}%
            defpartmyref#1{partname~ref*{#1}}%
            defappendixmyref#1{appendixname~ref*{#1}}%
            deftheoremmyref#1{Theorem~ref*{#1}}%

            makeatletter
            newififmyrefstar

            defmyref{@ifstar{myrefstartruemy@ref}{myrefstarfalsemy@ref}}% handkr autoref* arguments

            newcommand{my@ref}[1]{@ifundefined{r@#1}{??}% #1 = label name
            {my@@ref{#1}{getrefbykeydefault{#1}{anchor}{Doc-Start}}}}

            newcommand{my@@ref}[2]% #1 = label, #2 = anchor
            {bgroup
            StrBefore{#2}{.}[myrefname]% parse anchor before {.}
            @ifundefined{myrefname myref}{defmy@@@ref##1{myrefname~ref*{##1}}}%
            {expandafterletexpandaftermy@@@refcsnamemyrefname myrefendcsname}%
            ifmyrefstar
            my@@@ref{#1}%
            else
            hyperlink{#2}{my@@@ref{#1}}%
            fi
            egroup}

            letautoref=myref

            begin{document}
            begin{subequations}
            begin{equation}label{test}
            a=b
            end{equation}
            end{subequations}
            autoref{test}
            autoref*{test}
            end{document}





            share|improve this answer






























              1














              I decided to modify autoref instead of theequation. My approach was to add the format to the name definition, so that one could also implement all the subfigure formats. This is not very efficient, but is more easily modified by users.



              documentclass{article}
              usepackage{amsmath}
              usepackage{xstring}
              usepackage{hyperref}

              defequationmyref#1{Equation~(ref*{#1})}% Note: eqref* not defined
              defAMSmyref#1{Equation~(ref*{#1})}% for tag
              deffiguremyref#1{figurename~ref*{#1}}%
              deftablemyref#1{tablename~ref*{#1}}%
              defpartmyref#1{partname~ref*{#1}}%
              defappendixmyref#1{appendixname~ref*{#1}}%
              deftheoremmyref#1{Theorem~ref*{#1}}%

              makeatletter
              newififmyrefstar

              defmyref{@ifstar{myrefstartruemy@ref}{myrefstarfalsemy@ref}}% handkr autoref* arguments

              newcommand{my@ref}[1]{@ifundefined{r@#1}{??}% #1 = label name
              {my@@ref{#1}{getrefbykeydefault{#1}{anchor}{Doc-Start}}}}

              newcommand{my@@ref}[2]% #1 = label, #2 = anchor
              {bgroup
              StrBefore{#2}{.}[myrefname]% parse anchor before {.}
              @ifundefined{myrefname myref}{defmy@@@ref##1{myrefname~ref*{##1}}}%
              {expandafterletexpandaftermy@@@refcsnamemyrefname myrefendcsname}%
              ifmyrefstar
              my@@@ref{#1}%
              else
              hyperlink{#2}{my@@@ref{#1}}%
              fi
              egroup}

              letautoref=myref

              begin{document}
              begin{subequations}
              begin{equation}label{test}
              a=b
              end{equation}
              end{subequations}
              autoref{test}
              autoref*{test}
              end{document}





              share|improve this answer




























                1












                1








                1







                I decided to modify autoref instead of theequation. My approach was to add the format to the name definition, so that one could also implement all the subfigure formats. This is not very efficient, but is more easily modified by users.



                documentclass{article}
                usepackage{amsmath}
                usepackage{xstring}
                usepackage{hyperref}

                defequationmyref#1{Equation~(ref*{#1})}% Note: eqref* not defined
                defAMSmyref#1{Equation~(ref*{#1})}% for tag
                deffiguremyref#1{figurename~ref*{#1}}%
                deftablemyref#1{tablename~ref*{#1}}%
                defpartmyref#1{partname~ref*{#1}}%
                defappendixmyref#1{appendixname~ref*{#1}}%
                deftheoremmyref#1{Theorem~ref*{#1}}%

                makeatletter
                newififmyrefstar

                defmyref{@ifstar{myrefstartruemy@ref}{myrefstarfalsemy@ref}}% handkr autoref* arguments

                newcommand{my@ref}[1]{@ifundefined{r@#1}{??}% #1 = label name
                {my@@ref{#1}{getrefbykeydefault{#1}{anchor}{Doc-Start}}}}

                newcommand{my@@ref}[2]% #1 = label, #2 = anchor
                {bgroup
                StrBefore{#2}{.}[myrefname]% parse anchor before {.}
                @ifundefined{myrefname myref}{defmy@@@ref##1{myrefname~ref*{##1}}}%
                {expandafterletexpandaftermy@@@refcsnamemyrefname myrefendcsname}%
                ifmyrefstar
                my@@@ref{#1}%
                else
                hyperlink{#2}{my@@@ref{#1}}%
                fi
                egroup}

                letautoref=myref

                begin{document}
                begin{subequations}
                begin{equation}label{test}
                a=b
                end{equation}
                end{subequations}
                autoref{test}
                autoref*{test}
                end{document}





                share|improve this answer















                I decided to modify autoref instead of theequation. My approach was to add the format to the name definition, so that one could also implement all the subfigure formats. This is not very efficient, but is more easily modified by users.



                documentclass{article}
                usepackage{amsmath}
                usepackage{xstring}
                usepackage{hyperref}

                defequationmyref#1{Equation~(ref*{#1})}% Note: eqref* not defined
                defAMSmyref#1{Equation~(ref*{#1})}% for tag
                deffiguremyref#1{figurename~ref*{#1}}%
                deftablemyref#1{tablename~ref*{#1}}%
                defpartmyref#1{partname~ref*{#1}}%
                defappendixmyref#1{appendixname~ref*{#1}}%
                deftheoremmyref#1{Theorem~ref*{#1}}%

                makeatletter
                newififmyrefstar

                defmyref{@ifstar{myrefstartruemy@ref}{myrefstarfalsemy@ref}}% handkr autoref* arguments

                newcommand{my@ref}[1]{@ifundefined{r@#1}{??}% #1 = label name
                {my@@ref{#1}{getrefbykeydefault{#1}{anchor}{Doc-Start}}}}

                newcommand{my@@ref}[2]% #1 = label, #2 = anchor
                {bgroup
                StrBefore{#2}{.}[myrefname]% parse anchor before {.}
                @ifundefined{myrefname myref}{defmy@@@ref##1{myrefname~ref*{##1}}}%
                {expandafterletexpandaftermy@@@refcsnamemyrefname myrefendcsname}%
                ifmyrefstar
                my@@@ref{#1}%
                else
                hyperlink{#2}{my@@@ref{#1}}%
                fi
                egroup}

                letautoref=myref

                begin{document}
                begin{subequations}
                begin{equation}label{test}
                a=b
                end{equation}
                end{subequations}
                autoref{test}
                autoref*{test}
                end{document}






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 25 at 22:06

























                answered Mar 25 at 20:38









                John KormyloJohn Kormylo

                46.5k22672




                46.5k22672






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481339%2fautoref-and-subequations%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                    ComboBox Display Member on multiple fields

                    Is it possible to collect Nectar points via Trainline?