hyperref warns when using cleveref in sectionObtain expansion of crefAmsbook: Theoremstyles definition and remark identical?Hyperlinking problems when using subequations, hyperref and cleverefHow to reference chapter/section title when using cleverefhow to correctly customize section and equation using cleverefCleveref messes up theoremstylesHow to cross-reference an unnumbered theorem using hyperref and cleverefCryptic error message when using cleveref and hyperref with subequationsUltimate proof at the end/in appendix: different sections, with references to proof/theorem, restate, and synctex

How can I say "I want to" as a short response, omitting the main verb?

Are there objective criteria for classifying consonance v. dissonance?

In what state are satellites left in when they are left in a graveyard orbit?

Bash awk command with quotes

Why is belonging not transitive?

Permutations in Disguise

Exam design: give maximum score per question or not?

Impossible Scrabble Words

If I want an interpretable model, are there methods other than Linear Regression?

Importance of the current postdoc advisor's letter in TT job search

How To Make Earth's Oceans as Brackish as Lyr's

How do certain apps show new notifications when internet access is restricted to them?

'Overwrote' files, space still occupied, are they lost?

How to draw a Venn diagram for X - (Y intersect Z)?

What is a "major country" as named in Bernie Sanders' Healthcare debate answers?

Work done by spring force

Why is it called a stateful and a stateless firewall?

Pronunciation of "солнце"

Does a large scratch in an ND filter affect image quality?

How do we know that black holes are spinning?

Ethernet, Wifi and a little human psychology

Test to know when to use GLM over Linear Regression?

A command to output each line forward then backwards

How would you control supersoldiers in a late iron-age society?



hyperref warns when using cleveref in section


Obtain expansion of crefAmsbook: Theoremstyles definition and remark identical?Hyperlinking problems when using subequations, hyperref and cleverefHow to reference chapter/section title when using cleverefhow to correctly customize section and equation using cleverefCleveref messes up theoremstylesHow to cross-reference an unnumbered theorem using hyperref and cleverefCryptic error message when using cleveref and hyperref with subequationsUltimate proof at the end/in appendix: different sections, with references to proof/theorem, restate, and synctex






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I encounter a small but annoying problem with the following MWE



documentclassarticle

usepackagehyperref,cleveref
newtheoremthmTheorem

begindocument

beginthmlabelgood
Cleveref is good
endthm

sectionProof of Crefgood
It is trivial.

enddocument


The compiler (pdflatex) complains




Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `@ifnextchar' on input line 13.



Also the PDF TOC shows Proof of good instead of Proof Theorem 1.
Is their any solution other than saying sectionProof of Theorem ref...?
After all, the whole point of using cleveref is not to repeat the fact that good is a theorem.



PS1. I also want a solution for amsart or more general document classes.
(That is, the order of usepackages is more or less fixed)



PS2. Feel free to mark duplicate.
Although other MWEs I saw on this site are far from minimal.










share|improve this question



















  • 2





    The issue is that cleveref's machinery is not expandable (@ifnextchar, for example, isn't), so it can't be turned into a PDF string. The crossreftools package provides an expandable alternative. Possible duplicate? tex.stackexchange.com/q/381513/134574

    – Phelype Oleinik
    8 hours ago












  • @PhelypeOleinik I got an error complaining Use of refstepcounter@optarg doesn't match its definition when I use crtCref.

    – Symbol 1
    8 hours ago











  • Indeed, after leaving the comment I went to try my suggestion (I should probably try and then comment :-). This problem is because cleveref inserts some non-expandable MakeUppercase in the reference to the theorem, and when crossreftools tries to use it in an expansion-only context, hell breaks loose. I'll investigate :-)

    – Phelype Oleinik
    8 hours ago


















2















I encounter a small but annoying problem with the following MWE



documentclassarticle

usepackagehyperref,cleveref
newtheoremthmTheorem

begindocument

beginthmlabelgood
Cleveref is good
endthm

sectionProof of Crefgood
It is trivial.

enddocument


The compiler (pdflatex) complains




Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `@ifnextchar' on input line 13.



Also the PDF TOC shows Proof of good instead of Proof Theorem 1.
Is their any solution other than saying sectionProof of Theorem ref...?
After all, the whole point of using cleveref is not to repeat the fact that good is a theorem.



PS1. I also want a solution for amsart or more general document classes.
(That is, the order of usepackages is more or less fixed)



PS2. Feel free to mark duplicate.
Although other MWEs I saw on this site are far from minimal.










share|improve this question



















  • 2





    The issue is that cleveref's machinery is not expandable (@ifnextchar, for example, isn't), so it can't be turned into a PDF string. The crossreftools package provides an expandable alternative. Possible duplicate? tex.stackexchange.com/q/381513/134574

    – Phelype Oleinik
    8 hours ago












  • @PhelypeOleinik I got an error complaining Use of refstepcounter@optarg doesn't match its definition when I use crtCref.

    – Symbol 1
    8 hours ago











  • Indeed, after leaving the comment I went to try my suggestion (I should probably try and then comment :-). This problem is because cleveref inserts some non-expandable MakeUppercase in the reference to the theorem, and when crossreftools tries to use it in an expansion-only context, hell breaks loose. I'll investigate :-)

    – Phelype Oleinik
    8 hours ago














2












2








2








I encounter a small but annoying problem with the following MWE



documentclassarticle

usepackagehyperref,cleveref
newtheoremthmTheorem

begindocument

beginthmlabelgood
Cleveref is good
endthm

sectionProof of Crefgood
It is trivial.

enddocument


The compiler (pdflatex) complains




Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `@ifnextchar' on input line 13.



Also the PDF TOC shows Proof of good instead of Proof Theorem 1.
Is their any solution other than saying sectionProof of Theorem ref...?
After all, the whole point of using cleveref is not to repeat the fact that good is a theorem.



PS1. I also want a solution for amsart or more general document classes.
(That is, the order of usepackages is more or less fixed)



PS2. Feel free to mark duplicate.
Although other MWEs I saw on this site are far from minimal.










share|improve this question














I encounter a small but annoying problem with the following MWE



documentclassarticle

usepackagehyperref,cleveref
newtheoremthmTheorem

begindocument

beginthmlabelgood
Cleveref is good
endthm

sectionProof of Crefgood
It is trivial.

enddocument


The compiler (pdflatex) complains




Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `@ifnextchar' on input line 13.



Also the PDF TOC shows Proof of good instead of Proof Theorem 1.
Is their any solution other than saying sectionProof of Theorem ref...?
After all, the whole point of using cleveref is not to repeat the fact that good is a theorem.



PS1. I also want a solution for amsart or more general document classes.
(That is, the order of usepackages is more or less fixed)



PS2. Feel free to mark duplicate.
Although other MWEs I saw on this site are far from minimal.







theorems cleveref






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









Symbol 1Symbol 1

26.8k2 gold badges44 silver badges128 bronze badges




26.8k2 gold badges44 silver badges128 bronze badges










  • 2





    The issue is that cleveref's machinery is not expandable (@ifnextchar, for example, isn't), so it can't be turned into a PDF string. The crossreftools package provides an expandable alternative. Possible duplicate? tex.stackexchange.com/q/381513/134574

    – Phelype Oleinik
    8 hours ago












  • @PhelypeOleinik I got an error complaining Use of refstepcounter@optarg doesn't match its definition when I use crtCref.

    – Symbol 1
    8 hours ago











  • Indeed, after leaving the comment I went to try my suggestion (I should probably try and then comment :-). This problem is because cleveref inserts some non-expandable MakeUppercase in the reference to the theorem, and when crossreftools tries to use it in an expansion-only context, hell breaks loose. I'll investigate :-)

    – Phelype Oleinik
    8 hours ago













  • 2





    The issue is that cleveref's machinery is not expandable (@ifnextchar, for example, isn't), so it can't be turned into a PDF string. The crossreftools package provides an expandable alternative. Possible duplicate? tex.stackexchange.com/q/381513/134574

    – Phelype Oleinik
    8 hours ago












  • @PhelypeOleinik I got an error complaining Use of refstepcounter@optarg doesn't match its definition when I use crtCref.

    – Symbol 1
    8 hours ago











  • Indeed, after leaving the comment I went to try my suggestion (I should probably try and then comment :-). This problem is because cleveref inserts some non-expandable MakeUppercase in the reference to the theorem, and when crossreftools tries to use it in an expansion-only context, hell breaks loose. I'll investigate :-)

    – Phelype Oleinik
    8 hours ago








2




2





The issue is that cleveref's machinery is not expandable (@ifnextchar, for example, isn't), so it can't be turned into a PDF string. The crossreftools package provides an expandable alternative. Possible duplicate? tex.stackexchange.com/q/381513/134574

– Phelype Oleinik
8 hours ago






The issue is that cleveref's machinery is not expandable (@ifnextchar, for example, isn't), so it can't be turned into a PDF string. The crossreftools package provides an expandable alternative. Possible duplicate? tex.stackexchange.com/q/381513/134574

– Phelype Oleinik
8 hours ago














@PhelypeOleinik I got an error complaining Use of refstepcounter@optarg doesn't match its definition when I use crtCref.

– Symbol 1
8 hours ago





@PhelypeOleinik I got an error complaining Use of refstepcounter@optarg doesn't match its definition when I use crtCref.

– Symbol 1
8 hours ago













Indeed, after leaving the comment I went to try my suggestion (I should probably try and then comment :-). This problem is because cleveref inserts some non-expandable MakeUppercase in the reference to the theorem, and when crossreftools tries to use it in an expansion-only context, hell breaks loose. I'll investigate :-)

– Phelype Oleinik
8 hours ago






Indeed, after leaving the comment I went to try my suggestion (I should probably try and then comment :-). This problem is because cleveref inserts some non-expandable MakeUppercase in the reference to the theorem, and when crossreftools tries to use it in an expansion-only context, hell breaks loose. I'll investigate :-)

– Phelype Oleinik
8 hours ago











1 Answer
1






active

oldest

votes


















3
















As I said in the comment, the issue is that cleveref's machinery is not expandable (the @ifnextchar that hyperref complains about, for example, isn't expandable), so it can't be turned into a PDF string.



The crossreftools package provides an expandable alternative for cross referencing commands. For cleverref you can replace cref by crtcref and Cref by crtCref.



However, as you noted in your comment, only using that breaks badly. The reason is that cleverref redefines some internals of the theorems and inserts some MakeUppercase and MakeLowercase (which aren't expandable). The issue boils down to the fact that these commands end up in the cross reference code, which is expected to contain only text. When hyperref tries to expand that, chaos ensues.



I tried to find a proper fix, but most of them led to a can of worms of code which would then be incompatible with everything. An easier way out, which preserves cleveref's functionality and leaves the cross reference text expandable, is to use expl3's case changing functions. I used etoolbox's patchcmd to replace the two occurrences of MakeUppercase and one of MakeLowercase by tl_upper_case:n and tl_upper_case:n, respectively, from the commands @othm, @xnthm, and @ynthm. After patching that, the expandability problem is no more :-)



The pdf:




enter image description here




and the pdf bookmark file:



BOOKMARK [1][-]section.1Proof of Theorem 1% 1


Code:



documentclassarticle

usepackageexpl3,etoolbox

usepackagehyperref,cleveref
usepackagecrossreftools

% This patch must be after loading cleverref and before defining a new theorem
ExplSyntaxOn
makeatletter
clist_map_inline:nn @othm, @xnthm, @ynthm

patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
patchcmd #1 MakeLowercase tl_lower_case:n FAILED:

makeatother
ExplSyntaxOff

newtheoremthmTheorem

begindocument

beginthmlabelgood
Cleveref is good. expl3 is awesome :D
endthm

sectionProof of crtCrefgood
It is trivial.

enddocument





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/4.0/"u003ecc by-sa 4.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%2f508319%2fhyperref-warns-when-using-cleveref-in-section%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









    3
















    As I said in the comment, the issue is that cleveref's machinery is not expandable (the @ifnextchar that hyperref complains about, for example, isn't expandable), so it can't be turned into a PDF string.



    The crossreftools package provides an expandable alternative for cross referencing commands. For cleverref you can replace cref by crtcref and Cref by crtCref.



    However, as you noted in your comment, only using that breaks badly. The reason is that cleverref redefines some internals of the theorems and inserts some MakeUppercase and MakeLowercase (which aren't expandable). The issue boils down to the fact that these commands end up in the cross reference code, which is expected to contain only text. When hyperref tries to expand that, chaos ensues.



    I tried to find a proper fix, but most of them led to a can of worms of code which would then be incompatible with everything. An easier way out, which preserves cleveref's functionality and leaves the cross reference text expandable, is to use expl3's case changing functions. I used etoolbox's patchcmd to replace the two occurrences of MakeUppercase and one of MakeLowercase by tl_upper_case:n and tl_upper_case:n, respectively, from the commands @othm, @xnthm, and @ynthm. After patching that, the expandability problem is no more :-)



    The pdf:




    enter image description here




    and the pdf bookmark file:



    BOOKMARK [1][-]section.1Proof of Theorem 1% 1


    Code:



    documentclassarticle

    usepackageexpl3,etoolbox

    usepackagehyperref,cleveref
    usepackagecrossreftools

    % This patch must be after loading cleverref and before defining a new theorem
    ExplSyntaxOn
    makeatletter
    clist_map_inline:nn @othm, @xnthm, @ynthm

    patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
    patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
    patchcmd #1 MakeLowercase tl_lower_case:n FAILED:

    makeatother
    ExplSyntaxOff

    newtheoremthmTheorem

    begindocument

    beginthmlabelgood
    Cleveref is good. expl3 is awesome :D
    endthm

    sectionProof of crtCrefgood
    It is trivial.

    enddocument





    share|improve this answer





























      3
















      As I said in the comment, the issue is that cleveref's machinery is not expandable (the @ifnextchar that hyperref complains about, for example, isn't expandable), so it can't be turned into a PDF string.



      The crossreftools package provides an expandable alternative for cross referencing commands. For cleverref you can replace cref by crtcref and Cref by crtCref.



      However, as you noted in your comment, only using that breaks badly. The reason is that cleverref redefines some internals of the theorems and inserts some MakeUppercase and MakeLowercase (which aren't expandable). The issue boils down to the fact that these commands end up in the cross reference code, which is expected to contain only text. When hyperref tries to expand that, chaos ensues.



      I tried to find a proper fix, but most of them led to a can of worms of code which would then be incompatible with everything. An easier way out, which preserves cleveref's functionality and leaves the cross reference text expandable, is to use expl3's case changing functions. I used etoolbox's patchcmd to replace the two occurrences of MakeUppercase and one of MakeLowercase by tl_upper_case:n and tl_upper_case:n, respectively, from the commands @othm, @xnthm, and @ynthm. After patching that, the expandability problem is no more :-)



      The pdf:




      enter image description here




      and the pdf bookmark file:



      BOOKMARK [1][-]section.1Proof of Theorem 1% 1


      Code:



      documentclassarticle

      usepackageexpl3,etoolbox

      usepackagehyperref,cleveref
      usepackagecrossreftools

      % This patch must be after loading cleverref and before defining a new theorem
      ExplSyntaxOn
      makeatletter
      clist_map_inline:nn @othm, @xnthm, @ynthm

      patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
      patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
      patchcmd #1 MakeLowercase tl_lower_case:n FAILED:

      makeatother
      ExplSyntaxOff

      newtheoremthmTheorem

      begindocument

      beginthmlabelgood
      Cleveref is good. expl3 is awesome :D
      endthm

      sectionProof of crtCrefgood
      It is trivial.

      enddocument





      share|improve this answer



























        3














        3










        3









        As I said in the comment, the issue is that cleveref's machinery is not expandable (the @ifnextchar that hyperref complains about, for example, isn't expandable), so it can't be turned into a PDF string.



        The crossreftools package provides an expandable alternative for cross referencing commands. For cleverref you can replace cref by crtcref and Cref by crtCref.



        However, as you noted in your comment, only using that breaks badly. The reason is that cleverref redefines some internals of the theorems and inserts some MakeUppercase and MakeLowercase (which aren't expandable). The issue boils down to the fact that these commands end up in the cross reference code, which is expected to contain only text. When hyperref tries to expand that, chaos ensues.



        I tried to find a proper fix, but most of them led to a can of worms of code which would then be incompatible with everything. An easier way out, which preserves cleveref's functionality and leaves the cross reference text expandable, is to use expl3's case changing functions. I used etoolbox's patchcmd to replace the two occurrences of MakeUppercase and one of MakeLowercase by tl_upper_case:n and tl_upper_case:n, respectively, from the commands @othm, @xnthm, and @ynthm. After patching that, the expandability problem is no more :-)



        The pdf:




        enter image description here




        and the pdf bookmark file:



        BOOKMARK [1][-]section.1Proof of Theorem 1% 1


        Code:



        documentclassarticle

        usepackageexpl3,etoolbox

        usepackagehyperref,cleveref
        usepackagecrossreftools

        % This patch must be after loading cleverref and before defining a new theorem
        ExplSyntaxOn
        makeatletter
        clist_map_inline:nn @othm, @xnthm, @ynthm

        patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
        patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
        patchcmd #1 MakeLowercase tl_lower_case:n FAILED:

        makeatother
        ExplSyntaxOff

        newtheoremthmTheorem

        begindocument

        beginthmlabelgood
        Cleveref is good. expl3 is awesome :D
        endthm

        sectionProof of crtCrefgood
        It is trivial.

        enddocument





        share|improve this answer













        As I said in the comment, the issue is that cleveref's machinery is not expandable (the @ifnextchar that hyperref complains about, for example, isn't expandable), so it can't be turned into a PDF string.



        The crossreftools package provides an expandable alternative for cross referencing commands. For cleverref you can replace cref by crtcref and Cref by crtCref.



        However, as you noted in your comment, only using that breaks badly. The reason is that cleverref redefines some internals of the theorems and inserts some MakeUppercase and MakeLowercase (which aren't expandable). The issue boils down to the fact that these commands end up in the cross reference code, which is expected to contain only text. When hyperref tries to expand that, chaos ensues.



        I tried to find a proper fix, but most of them led to a can of worms of code which would then be incompatible with everything. An easier way out, which preserves cleveref's functionality and leaves the cross reference text expandable, is to use expl3's case changing functions. I used etoolbox's patchcmd to replace the two occurrences of MakeUppercase and one of MakeLowercase by tl_upper_case:n and tl_upper_case:n, respectively, from the commands @othm, @xnthm, and @ynthm. After patching that, the expandability problem is no more :-)



        The pdf:




        enter image description here




        and the pdf bookmark file:



        BOOKMARK [1][-]section.1Proof of Theorem 1% 1


        Code:



        documentclassarticle

        usepackageexpl3,etoolbox

        usepackagehyperref,cleveref
        usepackagecrossreftools

        % This patch must be after loading cleverref and before defining a new theorem
        ExplSyntaxOn
        makeatletter
        clist_map_inline:nn @othm, @xnthm, @ynthm

        patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
        patchcmd #1 MakeUppercase tl_upper_case:n FAILED:
        patchcmd #1 MakeLowercase tl_lower_case:n FAILED:

        makeatother
        ExplSyntaxOff

        newtheoremthmTheorem

        begindocument

        beginthmlabelgood
        Cleveref is good. expl3 is awesome :D
        endthm

        sectionProof of crtCrefgood
        It is trivial.

        enddocument






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        Phelype OleinikPhelype Oleinik

        33.9k7 gold badges57 silver badges113 bronze badges




        33.9k7 gold badges57 silver badges113 bronze badges































            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%2f508319%2fhyperref-warns-when-using-cleveref-in-section%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

            ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

            Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу