How to make cleveref cross-references match a modified equation label style?












4















I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.



Here goes a MWE:



documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}

makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother

begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}


This produces:



enter image description here



Then, my question is: how can I get the round parentheses to become square brackets?



Thank you all for your time.










share|improve this question




















  • 1





    See the mathtools package for its newtagform macro as well in order to simplify such styles of equation tags

    – Christian Hupfer
    Nov 9 '17 at 12:13








  • 1





    Do you mean that mathtools provides easier ways to do what I'm doing?

    – Héctor
    Nov 9 '17 at 12:14








  • 1





    Regarding the style of tags mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath

    – Christian Hupfer
    Nov 9 '17 at 12:15


















4















I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.



Here goes a MWE:



documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}

makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother

begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}


This produces:



enter image description here



Then, my question is: how can I get the round parentheses to become square brackets?



Thank you all for your time.










share|improve this question




















  • 1





    See the mathtools package for its newtagform macro as well in order to simplify such styles of equation tags

    – Christian Hupfer
    Nov 9 '17 at 12:13








  • 1





    Do you mean that mathtools provides easier ways to do what I'm doing?

    – Héctor
    Nov 9 '17 at 12:14








  • 1





    Regarding the style of tags mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath

    – Christian Hupfer
    Nov 9 '17 at 12:15
















4












4








4








I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.



Here goes a MWE:



documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}

makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother

begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}


This produces:



enter image description here



Then, my question is: how can I get the round parentheses to become square brackets?



Thank you all for your time.










share|improve this question
















I know that eqref exactly matches the style of the reference to the style of the equation label. However, I prefer to use cref from the cleveref package because (1) it allows me to place the word Equation before the number and because (2) it allows me type cref{eq1,eq2} quite comfortably. Further, following this question, I'm redefining the style of the equation number delimiters. Unluckily, such a change is not captured by the cleveref package.



Here goes a MWE:



documentclass{article}
usepackage{amsmath}
usepackage[capitalise,noabbrev,]{cleveref}

makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}
makeatother

begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}


This produces:



enter image description here



Then, my question is: how can I get the round parentheses to become square brackets?



Thank you all for your time.







equations cross-referencing cleveref






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 '17 at 18:18







Héctor

















asked Nov 9 '17 at 12:01









HéctorHéctor

809417




809417








  • 1





    See the mathtools package for its newtagform macro as well in order to simplify such styles of equation tags

    – Christian Hupfer
    Nov 9 '17 at 12:13








  • 1





    Do you mean that mathtools provides easier ways to do what I'm doing?

    – Héctor
    Nov 9 '17 at 12:14








  • 1





    Regarding the style of tags mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath

    – Christian Hupfer
    Nov 9 '17 at 12:15
















  • 1





    See the mathtools package for its newtagform macro as well in order to simplify such styles of equation tags

    – Christian Hupfer
    Nov 9 '17 at 12:13








  • 1





    Do you mean that mathtools provides easier ways to do what I'm doing?

    – Héctor
    Nov 9 '17 at 12:14








  • 1





    Regarding the style of tags mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath

    – Christian Hupfer
    Nov 9 '17 at 12:15










1




1





See the mathtools package for its newtagform macro as well in order to simplify such styles of equation tags

– Christian Hupfer
Nov 9 '17 at 12:13







See the mathtools package for its newtagform macro as well in order to simplify such styles of equation tags

– Christian Hupfer
Nov 9 '17 at 12:13






1




1





Do you mean that mathtools provides easier ways to do what I'm doing?

– Héctor
Nov 9 '17 at 12:14







Do you mean that mathtools provides easier ways to do what I'm doing?

– Héctor
Nov 9 '17 at 12:14






1




1





Regarding the style of tags mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath

– Christian Hupfer
Nov 9 '17 at 12:15







Regarding the style of tags mathtools is helping you definitely, but I think the cref issue still persists, however. mathtools loads amsmath (and extends it) so you will be able to use everything you already applied from amsmath

– Christian Hupfer
Nov 9 '17 at 12:15












2 Answers
2






active

oldest

votes


















5














In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.



creflabelformat{equation}{#2tagform@{#1}#3}


The #2 and #3 are reserved for hyperref targets.



Here's the full code.



documentclass{article}
usepackage{amsmath}

usepackage[capitalise,noabbrev,]{cleveref}


makeatletter
deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}

creflabelformat{equation}{#2tagform@{#1}#3}

makeatother





begin{document}
cref{eq1} is fancy
begin{equation}label{eq1}
a = b
end{equation}
end{document}


enter image description here






share|improve this answer































    3














    The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.



    documentclass{article}

    usepackage{mathtools} % for "newtagform" macro
    newtagform{brackets}{[}{]}
    usetagform{brackets} % employ square brackets as delimiters around eq. numbers

    usepackage[capitalise,noabbrev]{cleveref}
    creflabelformat{equation}{#2{upshape[#1]}#3}

    begin{document}
    cref{eq1} is fancy.
    begin{equation}label{eq1}
    a = b
    end{equation}
    end{document}





    share|improve this answer





















    • 1





      I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

      – Jim Ratliff
      Feb 26 at 6:41













    • @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

      – Mico
      Feb 26 at 8:45











    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%2f400470%2fhow-to-make-cleveref-cross-references-match-a-modified-equation-label-style%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.



    creflabelformat{equation}{#2tagform@{#1}#3}


    The #2 and #3 are reserved for hyperref targets.



    Here's the full code.



    documentclass{article}
    usepackage{amsmath}

    usepackage[capitalise,noabbrev,]{cleveref}


    makeatletter
    deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}

    creflabelformat{equation}{#2tagform@{#1}#3}

    makeatother





    begin{document}
    cref{eq1} is fancy
    begin{equation}label{eq1}
    a = b
    end{equation}
    end{document}


    enter image description here






    share|improve this answer




























      5














      In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.



      creflabelformat{equation}{#2tagform@{#1}#3}


      The #2 and #3 are reserved for hyperref targets.



      Here's the full code.



      documentclass{article}
      usepackage{amsmath}

      usepackage[capitalise,noabbrev,]{cleveref}


      makeatletter
      deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}

      creflabelformat{equation}{#2tagform@{#1}#3}

      makeatother





      begin{document}
      cref{eq1} is fancy
      begin{equation}label{eq1}
      a = b
      end{equation}
      end{document}


      enter image description here






      share|improve this answer


























        5












        5








        5







        In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.



        creflabelformat{equation}{#2tagform@{#1}#3}


        The #2 and #3 are reserved for hyperref targets.



        Here's the full code.



        documentclass{article}
        usepackage{amsmath}

        usepackage[capitalise,noabbrev,]{cleveref}


        makeatletter
        deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}

        creflabelformat{equation}{#2tagform@{#1}#3}

        makeatother





        begin{document}
        cref{eq1} is fancy
        begin{equation}label{eq1}
        a = b
        end{equation}
        end{document}


        enter image description here






        share|improve this answer













        In my point of view the easiest (though not most elegant, perhaps) way is to change creflabelformat for the equation counter as well, applying the tagform@ macro explicitly for this.



        creflabelformat{equation}{#2tagform@{#1}#3}


        The #2 and #3 are reserved for hyperref targets.



        Here's the full code.



        documentclass{article}
        usepackage{amsmath}

        usepackage[capitalise,noabbrev,]{cleveref}


        makeatletter
        deftagform@#1{maketag@@@{[ignorespaces#1unskip@@italiccorr]}}

        creflabelformat{equation}{#2tagform@{#1}#3}

        makeatother





        begin{document}
        cref{eq1} is fancy
        begin{equation}label{eq1}
        a = b
        end{equation}
        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 '17 at 12:09









        Christian HupferChristian Hupfer

        151k15199396




        151k15199396























            3














            The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.



            documentclass{article}

            usepackage{mathtools} % for "newtagform" macro
            newtagform{brackets}{[}{]}
            usetagform{brackets} % employ square brackets as delimiters around eq. numbers

            usepackage[capitalise,noabbrev]{cleveref}
            creflabelformat{equation}{#2{upshape[#1]}#3}

            begin{document}
            cref{eq1} is fancy.
            begin{equation}label{eq1}
            a = b
            end{equation}
            end{document}





            share|improve this answer





















            • 1





              I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

              – Jim Ratliff
              Feb 26 at 6:41













            • @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

              – Mico
              Feb 26 at 8:45
















            3














            The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.



            documentclass{article}

            usepackage{mathtools} % for "newtagform" macro
            newtagform{brackets}{[}{]}
            usetagform{brackets} % employ square brackets as delimiters around eq. numbers

            usepackage[capitalise,noabbrev]{cleveref}
            creflabelformat{equation}{#2{upshape[#1]}#3}

            begin{document}
            cref{eq1} is fancy.
            begin{equation}label{eq1}
            a = b
            end{equation}
            end{document}





            share|improve this answer





















            • 1





              I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

              – Jim Ratliff
              Feb 26 at 6:41













            • @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

              – Mico
              Feb 26 at 8:45














            3












            3








            3







            The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.



            documentclass{article}

            usepackage{mathtools} % for "newtagform" macro
            newtagform{brackets}{[}{]}
            usetagform{brackets} % employ square brackets as delimiters around eq. numbers

            usepackage[capitalise,noabbrev]{cleveref}
            creflabelformat{equation}{#2{upshape[#1]}#3}

            begin{document}
            cref{eq1} is fancy.
            begin{equation}label{eq1}
            a = b
            end{equation}
            end{document}





            share|improve this answer















            The following solution uses the newtagform and usetagform macros of the mathtools package and the creflabelformat macro of the cleveref package to achieve your formatting objective.



            documentclass{article}

            usepackage{mathtools} % for "newtagform" macro
            newtagform{brackets}{[}{]}
            usetagform{brackets} % employ square brackets as delimiters around eq. numbers

            usepackage[capitalise,noabbrev]{cleveref}
            creflabelformat{equation}{#2{upshape[#1]}#3}

            begin{document}
            cref{eq1} is fancy.
            begin{equation}label{eq1}
            a = b
            end{equation}
            end{document}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 26 at 8:44

























            answered Nov 9 '17 at 13:43









            MicoMico

            281k31385774




            281k31385774








            • 1





              I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

              – Jim Ratliff
              Feb 26 at 6:41













            • @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

              – Mico
              Feb 26 at 8:45














            • 1





              I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

              – Jim Ratliff
              Feb 26 at 6:41













            • @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

              – Mico
              Feb 26 at 8:45








            1




            1





            I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

            – Jim Ratliff
            Feb 26 at 6:41







            I wonder whether the second occurrence of #2 should instead be #3 (viz., in creflabelformat{equation}{#2{upshape[#1]}#2})? From the cleveref documentation, §8.1.2: The <format> argument “should contain the three arguments #1, #2 and #3, the first being the formatted version of the label counter, the others determining the beginning and end of the portion that becomes a hyperlink when the hyperref package is loaded…. #2 and #3 must appear in that order."

            – Jim Ratliff
            Feb 26 at 6:41















            @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

            – Mico
            Feb 26 at 8:45





            @JimRatliff - Many thanks for contacting me and for pointing out the error. I've fixed the code. Best, Mico

            – Mico
            Feb 26 at 8:45


















            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%2f400470%2fhow-to-make-cleveref-cross-references-match-a-modified-equation-label-style%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

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents