Hyperlinks, theorems, enumerate, and autoref












2















Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:



documentclass{amsart}

usepackage{hyperref}

newtheorem{theorem}{Theorem}

begin{document}

begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}

Let's prove Theorem~ref{bigthm}.

end{document}


This produces a warning:



pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one


and the hyperlink doesn’t work.



(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)



One solution is to add leavevmode right after label{bigthm}:



begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]


This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.



A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:



begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]


Now everything works. Great!



However, this better solution does not work with autoref, alas:



Let's prove~autoref{bigthm}.


now produces Let’s prove section 1. (albeit with a working hyperlink).



So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?










share|improve this question























  • Just try leavevmodelabel{bigthm}, without phantomsection

    – Christian Hupfer
    Jun 2 '17 at 15:39











  • @ChristianHupfer But that changes the formatting. I don’t want to start a new line.

    – Marco Varisco
    Jun 2 '17 at 15:57











  • Without leavevmode the first item starts on the line of header line of the environment, which looks very ugly

    – Christian Hupfer
    Jun 2 '17 at 16:06











  • I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.

    – Marco Varisco
    Jun 2 '17 at 16:10
















2















Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:



documentclass{amsart}

usepackage{hyperref}

newtheorem{theorem}{Theorem}

begin{document}

begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}

Let's prove Theorem~ref{bigthm}.

end{document}


This produces a warning:



pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one


and the hyperlink doesn’t work.



(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)



One solution is to add leavevmode right after label{bigthm}:



begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]


This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.



A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:



begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]


Now everything works. Great!



However, this better solution does not work with autoref, alas:



Let's prove~autoref{bigthm}.


now produces Let’s prove section 1. (albeit with a working hyperlink).



So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?










share|improve this question























  • Just try leavevmodelabel{bigthm}, without phantomsection

    – Christian Hupfer
    Jun 2 '17 at 15:39











  • @ChristianHupfer But that changes the formatting. I don’t want to start a new line.

    – Marco Varisco
    Jun 2 '17 at 15:57











  • Without leavevmode the first item starts on the line of header line of the environment, which looks very ugly

    – Christian Hupfer
    Jun 2 '17 at 16:06











  • I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.

    – Marco Varisco
    Jun 2 '17 at 16:10














2












2








2








Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:



documentclass{amsart}

usepackage{hyperref}

newtheorem{theorem}{Theorem}

begin{document}

begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}

Let's prove Theorem~ref{bigthm}.

end{document}


This produces a warning:



pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one


and the hyperlink doesn’t work.



(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)



One solution is to add leavevmode right after label{bigthm}:



begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]


This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.



A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:



begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]


Now everything works. Great!



However, this better solution does not work with autoref, alas:



Let's prove~autoref{bigthm}.


now produces Let’s prove section 1. (albeit with a working hyperlink).



So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?










share|improve this question














Hyperlinks to theorem-like environments that begin with a nested itemize or enumerate are often broken (see for example http://tex.stackexchange.com/a/187647).
Here is a MWE:



documentclass{amsart}

usepackage{hyperref}

newtheorem{theorem}{Theorem}

begin{document}

begin{theorem}
label{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}

Let's prove Theorem~ref{bigthm}.

end{document}


This produces a warning:



pdfTeX warning (dest): name{theorem.1} has been
referenced but does not exist, replaced by a fixed one


and the hyperlink doesn’t work.



(By the way, if we use article instead of amsart, then everything works as expected. What makes the AMS document class behave differently?)



One solution is to add leavevmode right after label{bigthm}:



begin{theorem}
label{bigthm}leavevmode
begin{itemize}[...]


This fixes the hyperlink, but of course it also changes the formatting, which I don’t want.



A better solution (thanks, Simon!), which does not change the formatting, is to add phantomsection right before label{bigthm}:



begin{theorem}
phantomsectionlabel{bigthm}
begin{itemize}[...]


Now everything works. Great!



However, this better solution does not work with autoref, alas:



Let's prove~autoref{bigthm}.


now produces Let’s prove section 1. (albeit with a working hyperlink).



So my question is this: Is there a way to fix the hyperlink that works with autoref without changing the formatting?







pdftex hyperref autoref






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 2 '17 at 15:18









Marco VariscoMarco Varisco

300314




300314













  • Just try leavevmodelabel{bigthm}, without phantomsection

    – Christian Hupfer
    Jun 2 '17 at 15:39











  • @ChristianHupfer But that changes the formatting. I don’t want to start a new line.

    – Marco Varisco
    Jun 2 '17 at 15:57











  • Without leavevmode the first item starts on the line of header line of the environment, which looks very ugly

    – Christian Hupfer
    Jun 2 '17 at 16:06











  • I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.

    – Marco Varisco
    Jun 2 '17 at 16:10



















  • Just try leavevmodelabel{bigthm}, without phantomsection

    – Christian Hupfer
    Jun 2 '17 at 15:39











  • @ChristianHupfer But that changes the formatting. I don’t want to start a new line.

    – Marco Varisco
    Jun 2 '17 at 15:57











  • Without leavevmode the first item starts on the line of header line of the environment, which looks very ugly

    – Christian Hupfer
    Jun 2 '17 at 16:06











  • I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.

    – Marco Varisco
    Jun 2 '17 at 16:10

















Just try leavevmodelabel{bigthm}, without phantomsection

– Christian Hupfer
Jun 2 '17 at 15:39





Just try leavevmodelabel{bigthm}, without phantomsection

– Christian Hupfer
Jun 2 '17 at 15:39













@ChristianHupfer But that changes the formatting. I don’t want to start a new line.

– Marco Varisco
Jun 2 '17 at 15:57





@ChristianHupfer But that changes the formatting. I don’t want to start a new line.

– Marco Varisco
Jun 2 '17 at 15:57













Without leavevmode the first item starts on the line of header line of the environment, which looks very ugly

– Christian Hupfer
Jun 2 '17 at 16:06





Without leavevmode the first item starts on the line of header line of the environment, which looks very ugly

– Christian Hupfer
Jun 2 '17 at 16:06













I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.

– Marco Varisco
Jun 2 '17 at 16:10





I know, but that’s exactly where I need the first item to start. I don’t particularly like it either, but the house styles of some publishers don’t allow line breaks right after theorem headers.

– Marco Varisco
Jun 2 '17 at 16:10










2 Answers
2






active

oldest

votes


















2














A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.



This is basically the same what phantomsection does, but using the correct environment name.



The problem is known and mentioned in the documentation of amsart:




• Other problems inherent in amsthm.



◦ Hyperlinking the first item
when a theorem begins with a list




documentclass{amsart}



usepackage{hyperref}
newtheorem{theorem}{Theorem}

makeatletter
newcommand{fakephantomsection}{%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}
makeatother



begin{document}

tableofcontents

clearpage
section{Foo}
begin{theorem}
fakephantomsectionlabel{bigthm}
begin{itemize}
item A claim.
item Another claim.
end{itemize}
end{theorem}

Let's prove Theorem~ref{bigthm} autoref{bigthm}.

end{document}


enter image description here






share|improve this answer


























  • This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

    – Marco Varisco
    Jun 2 '17 at 17:13











  • @MarcoVarisco: You're welcome. Happy TeXing!

    – Christian Hupfer
    Jun 3 '17 at 19:50



















0














I am using this modification of the command proposed in the other answer:



newcommand*{fakephantomsection}{%
Hy@GlobalStepCountHy@linkcounter%
Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
}





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%2f372922%2fhyperlinks-theorems-enumerate-and-autoref%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









    2














    A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.



    This is basically the same what phantomsection does, but using the correct environment name.



    The problem is known and mentioned in the documentation of amsart:




    • Other problems inherent in amsthm.



    ◦ Hyperlinking the first item
    when a theorem begins with a list




    documentclass{amsart}



    usepackage{hyperref}
    newtheorem{theorem}{Theorem}

    makeatletter
    newcommand{fakephantomsection}{%
    Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
    Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
    }
    makeatother



    begin{document}

    tableofcontents

    clearpage
    section{Foo}
    begin{theorem}
    fakephantomsectionlabel{bigthm}
    begin{itemize}
    item A claim.
    item Another claim.
    end{itemize}
    end{theorem}

    Let's prove Theorem~ref{bigthm} autoref{bigthm}.

    end{document}


    enter image description here






    share|improve this answer


























    • This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

      – Marco Varisco
      Jun 2 '17 at 17:13











    • @MarcoVarisco: You're welcome. Happy TeXing!

      – Christian Hupfer
      Jun 3 '17 at 19:50
















    2














    A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.



    This is basically the same what phantomsection does, but using the correct environment name.



    The problem is known and mentioned in the documentation of amsart:




    • Other problems inherent in amsthm.



    ◦ Hyperlinking the first item
    when a theorem begins with a list




    documentclass{amsart}



    usepackage{hyperref}
    newtheorem{theorem}{Theorem}

    makeatletter
    newcommand{fakephantomsection}{%
    Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
    Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
    }
    makeatother



    begin{document}

    tableofcontents

    clearpage
    section{Foo}
    begin{theorem}
    fakephantomsectionlabel{bigthm}
    begin{itemize}
    item A claim.
    item Another claim.
    end{itemize}
    end{theorem}

    Let's prove Theorem~ref{bigthm} autoref{bigthm}.

    end{document}


    enter image description here






    share|improve this answer


























    • This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

      – Marco Varisco
      Jun 2 '17 at 17:13











    • @MarcoVarisco: You're welcome. Happy TeXing!

      – Christian Hupfer
      Jun 3 '17 at 19:50














    2












    2








    2







    A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.



    This is basically the same what phantomsection does, but using the correct environment name.



    The problem is known and mentioned in the documentation of amsart:




    • Other problems inherent in amsthm.



    ◦ Hyperlinking the first item
    when a theorem begins with a list




    documentclass{amsart}



    usepackage{hyperref}
    newtheorem{theorem}{Theorem}

    makeatletter
    newcommand{fakephantomsection}{%
    Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
    Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
    }
    makeatother



    begin{document}

    tableofcontents

    clearpage
    section{Foo}
    begin{theorem}
    fakephantomsectionlabel{bigthm}
    begin{itemize}
    item A claim.
    item Another claim.
    end{itemize}
    end{theorem}

    Let's prove Theorem~ref{bigthm} autoref{bigthm}.

    end{document}


    enter image description here






    share|improve this answer















    A version with a fakephantomsection, that uses @currenvir, i.e. the current environment name in order to get the correct autoref name.



    This is basically the same what phantomsection does, but using the correct environment name.



    The problem is known and mentioned in the documentation of amsart:




    • Other problems inherent in amsthm.



    ◦ Hyperlinking the first item
    when a theorem begins with a list




    documentclass{amsart}



    usepackage{hyperref}
    newtheorem{theorem}{Theorem}

    makeatletter
    newcommand{fakephantomsection}{%
    Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}
    Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
    }
    makeatother



    begin{document}

    tableofcontents

    clearpage
    section{Foo}
    begin{theorem}
    fakephantomsectionlabel{bigthm}
    begin{itemize}
    item A claim.
    item Another claim.
    end{itemize}
    end{theorem}

    Let's prove Theorem~ref{bigthm} autoref{bigthm}.

    end{document}


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 2 '17 at 17:15

























    answered Jun 2 '17 at 16:35









    Christian HupferChristian Hupfer

    149k14196391




    149k14196391













    • This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

      – Marco Varisco
      Jun 2 '17 at 17:13











    • @MarcoVarisco: You're welcome. Happy TeXing!

      – Christian Hupfer
      Jun 3 '17 at 19:50



















    • This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

      – Marco Varisco
      Jun 2 '17 at 17:13











    • @MarcoVarisco: You're welcome. Happy TeXing!

      – Christian Hupfer
      Jun 3 '17 at 19:50

















    This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

    – Marco Varisco
    Jun 2 '17 at 17:13





    This is great. Thank you so much, Christian! And thanks also for answering my other parenthetical question.

    – Marco Varisco
    Jun 2 '17 at 17:13













    @MarcoVarisco: You're welcome. Happy TeXing!

    – Christian Hupfer
    Jun 3 '17 at 19:50





    @MarcoVarisco: You're welcome. Happy TeXing!

    – Christian Hupfer
    Jun 3 '17 at 19:50











    0














    I am using this modification of the command proposed in the other answer:



    newcommand*{fakephantomsection}{%
    Hy@GlobalStepCountHy@linkcounter%
    Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
    Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
    }





    share|improve this answer




























      0














      I am using this modification of the command proposed in the other answer:



      newcommand*{fakephantomsection}{%
      Hy@GlobalStepCountHy@linkcounter%
      Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
      Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
      }





      share|improve this answer


























        0












        0








        0







        I am using this modification of the command proposed in the other answer:



        newcommand*{fakephantomsection}{%
        Hy@GlobalStepCountHy@linkcounter%
        Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
        Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
        }





        share|improve this answer













        I am using this modification of the command proposed in the other answer:



        newcommand*{fakephantomsection}{%
        Hy@GlobalStepCountHy@linkcounter%
        Hy@MakeCurrentHref{@currenvir.theHy@linkcounter}%
        Hy@raisedlink{hyper@anchorstart{@currentHref}hyper@anchorend}%
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 19 at 15:27









        Lasse KliemannLasse Kliemann

        274




        274






























            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%2f372922%2fhyperlinks-theorems-enumerate-and-autoref%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 send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?