How to disable nesting in hyperrefs?











up vote
3
down vote

favorite
1












Is there a way to disable nesting in hyperrefs? Here is an example:



documentclass{article}
usepackage{hyperref}
usepackage{nameref}

begin{document}

tableofcontents
newpage

section{One}
label{sec:one}
newpage

section{nameref{sec:one} Two}

end{document}


The hyperref of the second section in the table of contents will consist of two hyperrefs one for "One" that leads to the first section and one for "One Two" that leads to the second section where "One" lays over the link for "One Two".



But I would like to have only one link there that leads to the second section if clicks anywhere on "One Two" in the TOC entry for the second section. So, I would like hyperrefs not to be nested into others.










share|improve this question


























    up vote
    3
    down vote

    favorite
    1












    Is there a way to disable nesting in hyperrefs? Here is an example:



    documentclass{article}
    usepackage{hyperref}
    usepackage{nameref}

    begin{document}

    tableofcontents
    newpage

    section{One}
    label{sec:one}
    newpage

    section{nameref{sec:one} Two}

    end{document}


    The hyperref of the second section in the table of contents will consist of two hyperrefs one for "One" that leads to the first section and one for "One Two" that leads to the second section where "One" lays over the link for "One Two".



    But I would like to have only one link there that leads to the second section if clicks anywhere on "One Two" in the TOC entry for the second section. So, I would like hyperrefs not to be nested into others.










    share|improve this question
























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      Is there a way to disable nesting in hyperrefs? Here is an example:



      documentclass{article}
      usepackage{hyperref}
      usepackage{nameref}

      begin{document}

      tableofcontents
      newpage

      section{One}
      label{sec:one}
      newpage

      section{nameref{sec:one} Two}

      end{document}


      The hyperref of the second section in the table of contents will consist of two hyperrefs one for "One" that leads to the first section and one for "One Two" that leads to the second section where "One" lays over the link for "One Two".



      But I would like to have only one link there that leads to the second section if clicks anywhere on "One Two" in the TOC entry for the second section. So, I would like hyperrefs not to be nested into others.










      share|improve this question













      Is there a way to disable nesting in hyperrefs? Here is an example:



      documentclass{article}
      usepackage{hyperref}
      usepackage{nameref}

      begin{document}

      tableofcontents
      newpage

      section{One}
      label{sec:one}
      newpage

      section{nameref{sec:one} Two}

      end{document}


      The hyperref of the second section in the table of contents will consist of two hyperrefs one for "One" that leads to the first section and one for "One Two" that leads to the second section where "One" lays over the link for "One Two".



      But I would like to have only one link there that leads to the second section if clicks anywhere on "One Two" in the TOC entry for the second section. So, I would like hyperrefs not to be nested into others.







      hyperref nesting






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 9 at 15:14









      Daniel

      623413




      623413






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          More recent releases of the hyperref-bundle and the nameref-package provide so-called "starred" variants of referencing-commands that do produce textual phrases but do not produce hyperlinks.



          Within your section-command you can use the starred variant of nameref.



          But there are some pitfalls:



          Be aware that with page-style "headings" arguments of sectioning-macros also go into page-headers while everything within the page-header gets "uppercased" after expansion which includes names of labels occurring within the arguments of sectioning-macros—a circumstance which in turn might lead to undefined-reference-errors.



          This example does exhibit the problem:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}


          With this example, you will never get rid of the message about undefined references. The reason is that within page-headers due to uppercase it is attempted to refer to a label "SEC:ONE" while it should be "sec:one".



          You might get the idea of using referencing-labels whose names consist of uppercase-letters only. If you do so, referencing works but unlike the other things within the page-headers the result of referencing will not be in uppercase letters within the page-headers:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{SEC:ONE}
          newpage

          section{nameref*{SEC:ONE} Two}

          end{document}


          Therefore I suggest using the expandable referencing-commands of the refcount-package within the arguments of sectioning-commands.



          Solution 1:



          In case you don't like hyperlinks at all:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {nameref*{sec:one} Two} %<- This goes to main text.

          end{document}


          Solution 2:



          In case you wish hyperlinks in the main text:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {texorpdfstring{nameref}{nameref*}{sec:one} Two} %<- This goes to main text.

          end{document}





          share|improve this answer























          • Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
            – Daniel
            Dec 9 at 16:12








          • 1




            @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
            – Ulrich Diez
            Dec 9 at 16:18










          • Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
            – Daniel
            Dec 9 at 16:26


















          up vote
          4
          down vote













          Use the starred nameref:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}





          share|improve this answer





















          • Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
            – Daniel
            Dec 9 at 15:38










          • Yes, but it would more sensible to do a search and replace - it can't take really long.
            – Ulrike Fischer
            Dec 9 at 15:43












          • Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
            – Daniel
            Dec 9 at 15:46












          • @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
            – Daniel
            Dec 9 at 16:09











          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%2f463957%2fhow-to-disable-nesting-in-hyperrefs%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
          4
          down vote



          accepted










          More recent releases of the hyperref-bundle and the nameref-package provide so-called "starred" variants of referencing-commands that do produce textual phrases but do not produce hyperlinks.



          Within your section-command you can use the starred variant of nameref.



          But there are some pitfalls:



          Be aware that with page-style "headings" arguments of sectioning-macros also go into page-headers while everything within the page-header gets "uppercased" after expansion which includes names of labels occurring within the arguments of sectioning-macros—a circumstance which in turn might lead to undefined-reference-errors.



          This example does exhibit the problem:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}


          With this example, you will never get rid of the message about undefined references. The reason is that within page-headers due to uppercase it is attempted to refer to a label "SEC:ONE" while it should be "sec:one".



          You might get the idea of using referencing-labels whose names consist of uppercase-letters only. If you do so, referencing works but unlike the other things within the page-headers the result of referencing will not be in uppercase letters within the page-headers:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{SEC:ONE}
          newpage

          section{nameref*{SEC:ONE} Two}

          end{document}


          Therefore I suggest using the expandable referencing-commands of the refcount-package within the arguments of sectioning-commands.



          Solution 1:



          In case you don't like hyperlinks at all:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {nameref*{sec:one} Two} %<- This goes to main text.

          end{document}


          Solution 2:



          In case you wish hyperlinks in the main text:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {texorpdfstring{nameref}{nameref*}{sec:one} Two} %<- This goes to main text.

          end{document}





          share|improve this answer























          • Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
            – Daniel
            Dec 9 at 16:12








          • 1




            @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
            – Ulrich Diez
            Dec 9 at 16:18










          • Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
            – Daniel
            Dec 9 at 16:26















          up vote
          4
          down vote



          accepted










          More recent releases of the hyperref-bundle and the nameref-package provide so-called "starred" variants of referencing-commands that do produce textual phrases but do not produce hyperlinks.



          Within your section-command you can use the starred variant of nameref.



          But there are some pitfalls:



          Be aware that with page-style "headings" arguments of sectioning-macros also go into page-headers while everything within the page-header gets "uppercased" after expansion which includes names of labels occurring within the arguments of sectioning-macros—a circumstance which in turn might lead to undefined-reference-errors.



          This example does exhibit the problem:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}


          With this example, you will never get rid of the message about undefined references. The reason is that within page-headers due to uppercase it is attempted to refer to a label "SEC:ONE" while it should be "sec:one".



          You might get the idea of using referencing-labels whose names consist of uppercase-letters only. If you do so, referencing works but unlike the other things within the page-headers the result of referencing will not be in uppercase letters within the page-headers:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{SEC:ONE}
          newpage

          section{nameref*{SEC:ONE} Two}

          end{document}


          Therefore I suggest using the expandable referencing-commands of the refcount-package within the arguments of sectioning-commands.



          Solution 1:



          In case you don't like hyperlinks at all:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {nameref*{sec:one} Two} %<- This goes to main text.

          end{document}


          Solution 2:



          In case you wish hyperlinks in the main text:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {texorpdfstring{nameref}{nameref*}{sec:one} Two} %<- This goes to main text.

          end{document}





          share|improve this answer























          • Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
            – Daniel
            Dec 9 at 16:12








          • 1




            @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
            – Ulrich Diez
            Dec 9 at 16:18










          • Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
            – Daniel
            Dec 9 at 16:26













          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          More recent releases of the hyperref-bundle and the nameref-package provide so-called "starred" variants of referencing-commands that do produce textual phrases but do not produce hyperlinks.



          Within your section-command you can use the starred variant of nameref.



          But there are some pitfalls:



          Be aware that with page-style "headings" arguments of sectioning-macros also go into page-headers while everything within the page-header gets "uppercased" after expansion which includes names of labels occurring within the arguments of sectioning-macros—a circumstance which in turn might lead to undefined-reference-errors.



          This example does exhibit the problem:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}


          With this example, you will never get rid of the message about undefined references. The reason is that within page-headers due to uppercase it is attempted to refer to a label "SEC:ONE" while it should be "sec:one".



          You might get the idea of using referencing-labels whose names consist of uppercase-letters only. If you do so, referencing works but unlike the other things within the page-headers the result of referencing will not be in uppercase letters within the page-headers:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{SEC:ONE}
          newpage

          section{nameref*{SEC:ONE} Two}

          end{document}


          Therefore I suggest using the expandable referencing-commands of the refcount-package within the arguments of sectioning-commands.



          Solution 1:



          In case you don't like hyperlinks at all:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {nameref*{sec:one} Two} %<- This goes to main text.

          end{document}


          Solution 2:



          In case you wish hyperlinks in the main text:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {texorpdfstring{nameref}{nameref*}{sec:one} Two} %<- This goes to main text.

          end{document}





          share|improve this answer














          More recent releases of the hyperref-bundle and the nameref-package provide so-called "starred" variants of referencing-commands that do produce textual phrases but do not produce hyperlinks.



          Within your section-command you can use the starred variant of nameref.



          But there are some pitfalls:



          Be aware that with page-style "headings" arguments of sectioning-macros also go into page-headers while everything within the page-header gets "uppercased" after expansion which includes names of labels occurring within the arguments of sectioning-macros—a circumstance which in turn might lead to undefined-reference-errors.



          This example does exhibit the problem:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}


          With this example, you will never get rid of the message about undefined references. The reason is that within page-headers due to uppercase it is attempted to refer to a label "SEC:ONE" while it should be "sec:one".



          You might get the idea of using referencing-labels whose names consist of uppercase-letters only. If you do so, referencing works but unlike the other things within the page-headers the result of referencing will not be in uppercase letters within the page-headers:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{SEC:ONE}
          newpage

          section{nameref*{SEC:ONE} Two}

          end{document}


          Therefore I suggest using the expandable referencing-commands of the refcount-package within the arguments of sectioning-commands.



          Solution 1:



          In case you don't like hyperlinks at all:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {nameref*{sec:one} Two} %<- This goes to main text.

          end{document}


          Solution 2:



          In case you wish hyperlinks in the main text:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}
          usepackage{refcount}

          makeatletter
          newcommandquestionmarks{texorpdfstring{nfss@text{reset@fontbfseries??}}{??}}
          makeatother

          pagestyle{headings}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section[getrefbykeydefault{sec:one}{name}{questionmarks} Two]%<- This goes to toc and pdf-bookmarks (and page-headers).
          {texorpdfstring{nameref}{nameref*}{sec:one} Two} %<- This goes to main text.

          end{document}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 9 at 17:34

























          answered Dec 9 at 16:01









          Ulrich Diez

          4,005615




          4,005615












          • Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
            – Daniel
            Dec 9 at 16:12








          • 1




            @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
            – Ulrich Diez
            Dec 9 at 16:18










          • Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
            – Daniel
            Dec 9 at 16:26


















          • Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
            – Daniel
            Dec 9 at 16:12








          • 1




            @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
            – Ulrich Diez
            Dec 9 at 16:18










          • Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
            – Daniel
            Dec 9 at 16:26
















          Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
          – Daniel
          Dec 9 at 16:12






          Unfortunately, I can't follow what the problem is. Is it a general problem or only when using nameref*? Maybe you can change the document so it shows the problem?
          – Daniel
          Dec 9 at 16:12






          1




          1




          @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
          – Ulrich Diez
          Dec 9 at 16:18




          @Daniel It is a general problem that occurs when using pagestyle{headings} and nameref within arguments of sectioning-commands: That page-style does print headings consisting of the sectioning-title in uppercased letters. For one thing the letters forming names of referencing-labels will get uppercased, too, which might cause "undefined references"-errors. For another thing, if you use label-names with uppercase-letters, the results of referencing will not be uppercased. Solution: expandable referencing-macros of the refcount-package.
          – Ulrich Diez
          Dec 9 at 16:18












          Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
          – Daniel
          Dec 9 at 16:26




          Okay, I think I got it, thanks. I still have to figure out what other trouble looms since I am not only using nameref for headings.
          – Daniel
          Dec 9 at 16:26










          up vote
          4
          down vote













          Use the starred nameref:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}





          share|improve this answer





















          • Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
            – Daniel
            Dec 9 at 15:38










          • Yes, but it would more sensible to do a search and replace - it can't take really long.
            – Ulrike Fischer
            Dec 9 at 15:43












          • Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
            – Daniel
            Dec 9 at 15:46












          • @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
            – Daniel
            Dec 9 at 16:09















          up vote
          4
          down vote













          Use the starred nameref:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}





          share|improve this answer





















          • Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
            – Daniel
            Dec 9 at 15:38










          • Yes, but it would more sensible to do a search and replace - it can't take really long.
            – Ulrike Fischer
            Dec 9 at 15:43












          • Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
            – Daniel
            Dec 9 at 15:46












          • @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
            – Daniel
            Dec 9 at 16:09













          up vote
          4
          down vote










          up vote
          4
          down vote









          Use the starred nameref:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}





          share|improve this answer












          Use the starred nameref:



          documentclass{article}
          usepackage{hyperref}
          usepackage{nameref}

          begin{document}

          tableofcontents
          newpage

          section{One}
          label{sec:one}
          newpage

          section{nameref*{sec:one} Two}

          end{document}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 9 at 15:22









          Ulrike Fischer

          185k7289666




          185k7289666












          • Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
            – Daniel
            Dec 9 at 15:38










          • Yes, but it would more sensible to do a search and replace - it can't take really long.
            – Ulrike Fischer
            Dec 9 at 15:43












          • Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
            – Daniel
            Dec 9 at 15:46












          • @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
            – Daniel
            Dec 9 at 16:09


















          • Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
            – Daniel
            Dec 9 at 15:38










          • Yes, but it would more sensible to do a search and replace - it can't take really long.
            – Ulrike Fischer
            Dec 9 at 15:43












          • Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
            – Daniel
            Dec 9 at 15:46












          • @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
            – Daniel
            Dec 9 at 16:09
















          Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
          – Daniel
          Dec 9 at 15:38




          Works great. I cannot add stars to all my namerefs. Do you happen to know how to replace the nameref command with the nameref* command?
          – Daniel
          Dec 9 at 15:38












          Yes, but it would more sensible to do a search and replace - it can't take really long.
          – Ulrike Fischer
          Dec 9 at 15:43






          Yes, but it would more sensible to do a search and replace - it can't take really long.
          – Ulrike Fischer
          Dec 9 at 15:43














          Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
          – Daniel
          Dec 9 at 15:46






          Yes, but unfortunately, I cannot do a search and replace since I am using LyX. (And apparently, it does not currently support the starred commands. Though I will suggest it to the developers.)
          – Daniel
          Dec 9 at 15:46














          @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
          – Daniel
          Dec 9 at 16:09




          @UlrikeFischer Okay, I might have understood why replacing one with the other command is not a good idea. It will not only get rid of nested hyperlinks but also non-nested hyperlinks which is undesirable. I guess I could use LyX's functionality of inserting just the name of a label and then build my own nameref* inset.
          – Daniel
          Dec 9 at 16:09


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f463957%2fhow-to-disable-nesting-in-hyperrefs%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

          Сан-Квентин

          8-я гвардейская общевойсковая армия

          Алькесар