Why do all of my hyperrefs take me to the same page?











up vote
5
down vote

favorite












I can't reproduce this in miniature outside of my document, so I'm asking more debugging help on how I can fix it within the document I have.



The problem is, I have a section with something like:



First is hyperref[P1]{Item I}, go there.  hyperref[P2]{Next} is item 2, and finally is hyperref[P3]{Item III}.
newpage

%% later...
section*{Item I}
label{P1}
stuff
section*{Item II}
label{P2}
stuff
section*{Item III}
label{P3}
stuff


Suppose




  • Item I, P1 is on page 1.

  • Item II, P2 is on page 6.

  • Item III, P3 is on page 20.


No matter what I change, hyperref[P3]{Item III} points to page 5, instead of 20.



I have tried the following debugs:





  1. Did I actually mislabel P3 as P2? No, it's P3.


  2. Did I actually fail to update the original hyperref, so it still says P2? No, it says P3.


  3. Am I sure? How about I call it something totally different, like LOCATION. hyperref[LOCATION]{Item III} section*{Item III}label{LOCATION} Still points to page 5, not page 20!


  4. Is there an error I'm missing, such as: LaTeX Warning: There were undefined references.? Nope, there are no missing references.


  5. How about completely remove label{P2} and see if P3 is still pointing there? Removed, yes, it still points to page 5, which now has zero labels intentionally pointing to it.


  6. What about debugging the pages themselves? pageref{P1} pageref{P2} pageref{P3} prints 2 7 21 Close enough, but this tells me in fact pageref{P2} is also incorrect. It's not pointing at P2, but at the end of P1, just as P3 is pointing at the end of P1.


Beyond this, I have no idea how to make any refs defined after the first one work, and by that I mean point elsewhere than at page 5. What could be going on?










share|improve this question


























    up vote
    5
    down vote

    favorite












    I can't reproduce this in miniature outside of my document, so I'm asking more debugging help on how I can fix it within the document I have.



    The problem is, I have a section with something like:



    First is hyperref[P1]{Item I}, go there.  hyperref[P2]{Next} is item 2, and finally is hyperref[P3]{Item III}.
    newpage

    %% later...
    section*{Item I}
    label{P1}
    stuff
    section*{Item II}
    label{P2}
    stuff
    section*{Item III}
    label{P3}
    stuff


    Suppose




    • Item I, P1 is on page 1.

    • Item II, P2 is on page 6.

    • Item III, P3 is on page 20.


    No matter what I change, hyperref[P3]{Item III} points to page 5, instead of 20.



    I have tried the following debugs:





    1. Did I actually mislabel P3 as P2? No, it's P3.


    2. Did I actually fail to update the original hyperref, so it still says P2? No, it says P3.


    3. Am I sure? How about I call it something totally different, like LOCATION. hyperref[LOCATION]{Item III} section*{Item III}label{LOCATION} Still points to page 5, not page 20!


    4. Is there an error I'm missing, such as: LaTeX Warning: There were undefined references.? Nope, there are no missing references.


    5. How about completely remove label{P2} and see if P3 is still pointing there? Removed, yes, it still points to page 5, which now has zero labels intentionally pointing to it.


    6. What about debugging the pages themselves? pageref{P1} pageref{P2} pageref{P3} prints 2 7 21 Close enough, but this tells me in fact pageref{P2} is also incorrect. It's not pointing at P2, but at the end of P1, just as P3 is pointing at the end of P1.


    Beyond this, I have no idea how to make any refs defined after the first one work, and by that I mean point elsewhere than at page 5. What could be going on?










    share|improve this question
























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      I can't reproduce this in miniature outside of my document, so I'm asking more debugging help on how I can fix it within the document I have.



      The problem is, I have a section with something like:



      First is hyperref[P1]{Item I}, go there.  hyperref[P2]{Next} is item 2, and finally is hyperref[P3]{Item III}.
      newpage

      %% later...
      section*{Item I}
      label{P1}
      stuff
      section*{Item II}
      label{P2}
      stuff
      section*{Item III}
      label{P3}
      stuff


      Suppose




      • Item I, P1 is on page 1.

      • Item II, P2 is on page 6.

      • Item III, P3 is on page 20.


      No matter what I change, hyperref[P3]{Item III} points to page 5, instead of 20.



      I have tried the following debugs:





      1. Did I actually mislabel P3 as P2? No, it's P3.


      2. Did I actually fail to update the original hyperref, so it still says P2? No, it says P3.


      3. Am I sure? How about I call it something totally different, like LOCATION. hyperref[LOCATION]{Item III} section*{Item III}label{LOCATION} Still points to page 5, not page 20!


      4. Is there an error I'm missing, such as: LaTeX Warning: There were undefined references.? Nope, there are no missing references.


      5. How about completely remove label{P2} and see if P3 is still pointing there? Removed, yes, it still points to page 5, which now has zero labels intentionally pointing to it.


      6. What about debugging the pages themselves? pageref{P1} pageref{P2} pageref{P3} prints 2 7 21 Close enough, but this tells me in fact pageref{P2} is also incorrect. It's not pointing at P2, but at the end of P1, just as P3 is pointing at the end of P1.


      Beyond this, I have no idea how to make any refs defined after the first one work, and by that I mean point elsewhere than at page 5. What could be going on?










      share|improve this question













      I can't reproduce this in miniature outside of my document, so I'm asking more debugging help on how I can fix it within the document I have.



      The problem is, I have a section with something like:



      First is hyperref[P1]{Item I}, go there.  hyperref[P2]{Next} is item 2, and finally is hyperref[P3]{Item III}.
      newpage

      %% later...
      section*{Item I}
      label{P1}
      stuff
      section*{Item II}
      label{P2}
      stuff
      section*{Item III}
      label{P3}
      stuff


      Suppose




      • Item I, P1 is on page 1.

      • Item II, P2 is on page 6.

      • Item III, P3 is on page 20.


      No matter what I change, hyperref[P3]{Item III} points to page 5, instead of 20.



      I have tried the following debugs:





      1. Did I actually mislabel P3 as P2? No, it's P3.


      2. Did I actually fail to update the original hyperref, so it still says P2? No, it says P3.


      3. Am I sure? How about I call it something totally different, like LOCATION. hyperref[LOCATION]{Item III} section*{Item III}label{LOCATION} Still points to page 5, not page 20!


      4. Is there an error I'm missing, such as: LaTeX Warning: There were undefined references.? Nope, there are no missing references.


      5. How about completely remove label{P2} and see if P3 is still pointing there? Removed, yes, it still points to page 5, which now has zero labels intentionally pointing to it.


      6. What about debugging the pages themselves? pageref{P1} pageref{P2} pageref{P3} prints 2 7 21 Close enough, but this tells me in fact pageref{P2} is also incorrect. It's not pointing at P2, but at the end of P1, just as P3 is pointing at the end of P1.


      Beyond this, I have no idea how to make any refs defined after the first one work, and by that I mean point elsewhere than at page 5. What could be going on?







      hyperref cross-referencing href






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 6 at 16:26









      Mittenchops

      444149




      444149






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          7
          down vote



          accepted










          You need to use



          phantomsection
          section*{<title>}
          label{<label>}


          since there is no hyper target set with section* like there is with section. If you're only using section* within your document, you could automate this process using



          letoldsectionsection % Copy section into oldsection
          renewcommand{section}{%
          phantomsection % Set hyper target
          oldsection*
          }


          in your preamble






          share|improve this answer





















          • This is so reasonable I wish it were the default. The macro helps a lot, thank you!
            – Mittenchops
            Nov 6 at 18:19






          • 3




            @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
            – Werner
            Nov 6 at 18:22


















          up vote
          3
          down vote













          Another approachs with hyperref and nameref that do not need phantomsections:



          mwe



          documentclass{article}
          usepackage[colorlinks,linkcolor=blue]{hyperref}
          usepackage{lipsum}
          usepackage{nameref}
          begin{document}

          First is Nameref{P1}, go there. par
          hyperlink{X}{Here} is nameref{P2} (Nameref{P2}).par
          But there are a Nameref{P3}.par
          And there are not three without hyperlink{Y}{four} in page pageref{P4}

          newpage

          section*{Item I}
          label{P1}
          lipsum[1-20]
          section*{Item II}
          label{P2}hypertarget{X}
          lipsum[21-40]
          section*{Item III}
          label{P3}
          lipsum[41-50]
          section*{Item IV}
          label{P4}
          hypertarget{Y}
          lipsum[1]

          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',
            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%2f458674%2fwhy-do-all-of-my-hyperrefs-take-me-to-the-same-page%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








            up vote
            7
            down vote



            accepted










            You need to use



            phantomsection
            section*{<title>}
            label{<label>}


            since there is no hyper target set with section* like there is with section. If you're only using section* within your document, you could automate this process using



            letoldsectionsection % Copy section into oldsection
            renewcommand{section}{%
            phantomsection % Set hyper target
            oldsection*
            }


            in your preamble






            share|improve this answer





















            • This is so reasonable I wish it were the default. The macro helps a lot, thank you!
              – Mittenchops
              Nov 6 at 18:19






            • 3




              @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
              – Werner
              Nov 6 at 18:22















            up vote
            7
            down vote



            accepted










            You need to use



            phantomsection
            section*{<title>}
            label{<label>}


            since there is no hyper target set with section* like there is with section. If you're only using section* within your document, you could automate this process using



            letoldsectionsection % Copy section into oldsection
            renewcommand{section}{%
            phantomsection % Set hyper target
            oldsection*
            }


            in your preamble






            share|improve this answer





















            • This is so reasonable I wish it were the default. The macro helps a lot, thank you!
              – Mittenchops
              Nov 6 at 18:19






            • 3




              @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
              – Werner
              Nov 6 at 18:22













            up vote
            7
            down vote



            accepted







            up vote
            7
            down vote



            accepted






            You need to use



            phantomsection
            section*{<title>}
            label{<label>}


            since there is no hyper target set with section* like there is with section. If you're only using section* within your document, you could automate this process using



            letoldsectionsection % Copy section into oldsection
            renewcommand{section}{%
            phantomsection % Set hyper target
            oldsection*
            }


            in your preamble






            share|improve this answer












            You need to use



            phantomsection
            section*{<title>}
            label{<label>}


            since there is no hyper target set with section* like there is with section. If you're only using section* within your document, you could automate this process using



            letoldsectionsection % Copy section into oldsection
            renewcommand{section}{%
            phantomsection % Set hyper target
            oldsection*
            }


            in your preamble







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 6 at 16:55









            Werner

            430k599441621




            430k599441621












            • This is so reasonable I wish it were the default. The macro helps a lot, thank you!
              – Mittenchops
              Nov 6 at 18:19






            • 3




              @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
              – Werner
              Nov 6 at 18:22


















            • This is so reasonable I wish it were the default. The macro helps a lot, thank you!
              – Mittenchops
              Nov 6 at 18:19






            • 3




              @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
              – Werner
              Nov 6 at 18:22
















            This is so reasonable I wish it were the default. The macro helps a lot, thank you!
            – Mittenchops
            Nov 6 at 18:19




            This is so reasonable I wish it were the default. The macro helps a lot, thank you!
            – Mittenchops
            Nov 6 at 18:19




            3




            3




            @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
            – Werner
            Nov 6 at 18:22




            @Mittenchops: The default for section is to issue refstepcounter. This sets a reference point and also steps the counter (section in this case). However, with section* there is no counter to step. Moreover, if you use label-ref, the result is the previous counter that was stepped. So, it's just that there's nothing appropriate to reference in general. The onus is therefore shifted to the end-user.
            – Werner
            Nov 6 at 18:22










            up vote
            3
            down vote













            Another approachs with hyperref and nameref that do not need phantomsections:



            mwe



            documentclass{article}
            usepackage[colorlinks,linkcolor=blue]{hyperref}
            usepackage{lipsum}
            usepackage{nameref}
            begin{document}

            First is Nameref{P1}, go there. par
            hyperlink{X}{Here} is nameref{P2} (Nameref{P2}).par
            But there are a Nameref{P3}.par
            And there are not three without hyperlink{Y}{four} in page pageref{P4}

            newpage

            section*{Item I}
            label{P1}
            lipsum[1-20]
            section*{Item II}
            label{P2}hypertarget{X}
            lipsum[21-40]
            section*{Item III}
            label{P3}
            lipsum[41-50]
            section*{Item IV}
            label{P4}
            hypertarget{Y}
            lipsum[1]

            end{document}





            share|improve this answer

























              up vote
              3
              down vote













              Another approachs with hyperref and nameref that do not need phantomsections:



              mwe



              documentclass{article}
              usepackage[colorlinks,linkcolor=blue]{hyperref}
              usepackage{lipsum}
              usepackage{nameref}
              begin{document}

              First is Nameref{P1}, go there. par
              hyperlink{X}{Here} is nameref{P2} (Nameref{P2}).par
              But there are a Nameref{P3}.par
              And there are not three without hyperlink{Y}{four} in page pageref{P4}

              newpage

              section*{Item I}
              label{P1}
              lipsum[1-20]
              section*{Item II}
              label{P2}hypertarget{X}
              lipsum[21-40]
              section*{Item III}
              label{P3}
              lipsum[41-50]
              section*{Item IV}
              label{P4}
              hypertarget{Y}
              lipsum[1]

              end{document}





              share|improve this answer























                up vote
                3
                down vote










                up vote
                3
                down vote









                Another approachs with hyperref and nameref that do not need phantomsections:



                mwe



                documentclass{article}
                usepackage[colorlinks,linkcolor=blue]{hyperref}
                usepackage{lipsum}
                usepackage{nameref}
                begin{document}

                First is Nameref{P1}, go there. par
                hyperlink{X}{Here} is nameref{P2} (Nameref{P2}).par
                But there are a Nameref{P3}.par
                And there are not three without hyperlink{Y}{four} in page pageref{P4}

                newpage

                section*{Item I}
                label{P1}
                lipsum[1-20]
                section*{Item II}
                label{P2}hypertarget{X}
                lipsum[21-40]
                section*{Item III}
                label{P3}
                lipsum[41-50]
                section*{Item IV}
                label{P4}
                hypertarget{Y}
                lipsum[1]

                end{document}





                share|improve this answer












                Another approachs with hyperref and nameref that do not need phantomsections:



                mwe



                documentclass{article}
                usepackage[colorlinks,linkcolor=blue]{hyperref}
                usepackage{lipsum}
                usepackage{nameref}
                begin{document}

                First is Nameref{P1}, go there. par
                hyperlink{X}{Here} is nameref{P2} (Nameref{P2}).par
                But there are a Nameref{P3}.par
                And there are not three without hyperlink{Y}{four} in page pageref{P4}

                newpage

                section*{Item I}
                label{P1}
                lipsum[1-20]
                section*{Item II}
                label{P2}hypertarget{X}
                lipsum[21-40]
                section*{Item III}
                label{P3}
                lipsum[41-50]
                section*{Item IV}
                label{P4}
                hypertarget{Y}
                lipsum[1]

                end{document}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 6 at 22:35









                Fran

                49.6k6110172




                49.6k6110172






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458674%2fwhy-do-all-of-my-hyperrefs-take-me-to-the-same-page%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







                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini