Sort symbol index by page occurence












4














SE, I have a problem ordering items in symbol index.
MWE:



documentclass[oneside,12pt,a4paper]{memoir}

renewcommand{baselinestretch}{1.15}

letmemoldbibsectionbibsection
letbibsectionrelax
%usepackage[nobysame]{amsrefs}
letbibsectionmemoldbibsection

usepackage[right=2.7cm,left=3.5cm, top=2.7cm, bottom=2.5cm,includehead]{geometry}


usepackage{amssymb, amsmath, amsthm}
usepackage{imakeidx}

makeindex[intoc, name=sym,title=Symbol index]

begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

%Multiple times Lorem Ipsum so that symbols end up in different pages

index[sym]{$(E, mathcal{E})$}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

index[sym]{$abc$}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

%Multiple times Lorem Ipsum so that symbols end up in different pages

index[sym]{$mu_{X}$}

index[sym]{$mu_{Y}$}


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

clearpage
chaptermark{Symbol index}
renewcommand{indexname}{Symbol index}
printindex[sym]


end{document}


Now as you will see by running this example the order in index does not reflect the order of occurence of the symbols.



How do I force index to be ordered by the number of page where the symbol first occured?










share|improve this question



























    4














    SE, I have a problem ordering items in symbol index.
    MWE:



    documentclass[oneside,12pt,a4paper]{memoir}

    renewcommand{baselinestretch}{1.15}

    letmemoldbibsectionbibsection
    letbibsectionrelax
    %usepackage[nobysame]{amsrefs}
    letbibsectionmemoldbibsection

    usepackage[right=2.7cm,left=3.5cm, top=2.7cm, bottom=2.5cm,includehead]{geometry}


    usepackage{amssymb, amsmath, amsthm}
    usepackage{imakeidx}

    makeindex[intoc, name=sym,title=Symbol index]

    begin{document}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

    %Multiple times Lorem Ipsum so that symbols end up in different pages

    index[sym]{$(E, mathcal{E})$}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

    index[sym]{$abc$}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

    %Multiple times Lorem Ipsum so that symbols end up in different pages

    index[sym]{$mu_{X}$}

    index[sym]{$mu_{Y}$}


    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

    clearpage
    chaptermark{Symbol index}
    renewcommand{indexname}{Symbol index}
    printindex[sym]


    end{document}


    Now as you will see by running this example the order in index does not reflect the order of occurence of the symbols.



    How do I force index to be ordered by the number of page where the symbol first occured?










    share|improve this question

























      4












      4








      4







      SE, I have a problem ordering items in symbol index.
      MWE:



      documentclass[oneside,12pt,a4paper]{memoir}

      renewcommand{baselinestretch}{1.15}

      letmemoldbibsectionbibsection
      letbibsectionrelax
      %usepackage[nobysame]{amsrefs}
      letbibsectionmemoldbibsection

      usepackage[right=2.7cm,left=3.5cm, top=2.7cm, bottom=2.5cm,includehead]{geometry}


      usepackage{amssymb, amsmath, amsthm}
      usepackage{imakeidx}

      makeindex[intoc, name=sym,title=Symbol index]

      begin{document}
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      %Multiple times Lorem Ipsum so that symbols end up in different pages

      index[sym]{$(E, mathcal{E})$}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      index[sym]{$abc$}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      %Multiple times Lorem Ipsum so that symbols end up in different pages

      index[sym]{$mu_{X}$}

      index[sym]{$mu_{Y}$}


      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      clearpage
      chaptermark{Symbol index}
      renewcommand{indexname}{Symbol index}
      printindex[sym]


      end{document}


      Now as you will see by running this example the order in index does not reflect the order of occurence of the symbols.



      How do I force index to be ordered by the number of page where the symbol first occured?










      share|improve this question













      SE, I have a problem ordering items in symbol index.
      MWE:



      documentclass[oneside,12pt,a4paper]{memoir}

      renewcommand{baselinestretch}{1.15}

      letmemoldbibsectionbibsection
      letbibsectionrelax
      %usepackage[nobysame]{amsrefs}
      letbibsectionmemoldbibsection

      usepackage[right=2.7cm,left=3.5cm, top=2.7cm, bottom=2.5cm,includehead]{geometry}


      usepackage{amssymb, amsmath, amsthm}
      usepackage{imakeidx}

      makeindex[intoc, name=sym,title=Symbol index]

      begin{document}
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      %Multiple times Lorem Ipsum so that symbols end up in different pages

      index[sym]{$(E, mathcal{E})$}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      index[sym]{$abc$}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      %Multiple times Lorem Ipsum so that symbols end up in different pages

      index[sym]{$mu_{X}$}

      index[sym]{$mu_{Y}$}


      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae laoreet eros. Nam dapibus ante nec suscipit mattis. Mauris tempus tortor nunc, sed suscipit neque varius vel. Duis semper elit libero, a porttitor tellus vehicula id. Maecenas semper lacinia lectus, et tempor mauris pulvinar vel. Vivamus placerat ipsum enim, sit amet dignissim purus placerat nec. Suspendisse mattis ipsum convallis bibendum mattis. Nullam gravida eros vitae enim aliquam venenatis. Duis faucibus tincidunt velit, id eleifend mauris fermentum malesuada. Nunc blandit metus turpis, nec auctor elit tristique non. Proin ut mattis elit. Nam ac nulla sodales, ullamcorper lacus porta, eleifend urna. Maecenas eget dui vitae turpis pulvinar auctor. Maecenas a porttitor dolor.

      clearpage
      chaptermark{Symbol index}
      renewcommand{indexname}{Symbol index}
      printindex[sym]


      end{document}


      Now as you will see by running this example the order in index does not reflect the order of occurence of the symbols.



      How do I force index to be ordered by the number of page where the symbol first occured?







      indexing sorting






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 12 '18 at 16:58









      data

      1554




      1554






















          1 Answer
          1






          active

          oldest

          votes


















          4














          You can record an auxiliary counter as the sorting part. This assumes you have less than 1000 symbols (but it can be extended if needed).



          In order to cope with multiple occurrences, the first one will set a key.



          documentclass[oneside,12pt,a4paper]{memoir}
          usepackage{imakeidx}

          makeindex[intoc, name=sym,title=Symbol index]

          newcounter{indexcount}
          newcommand{threedigit}[1]{ifnum #1<100 0fiifnum #1<10 0fi#1}

          newcommand{symindex}[1]{%
          ifcsnamedetokenize{SYM@@#1}endcsname
          index[sym]{csnamedetokenize{SYM@@#1}endcsname @#1}%
          else
          stepcounter{indexcount}%
          expandafterxdefcsname SYM@@detokenize{#1}endcsname{%
          expandafterthreedigitexpandafter{romannumeral-`Qtheindexcount}%
          }%
          index[sym]{threedigit{theindexcount}@unexpanded{unexpanded{#1}}}%
          fi
          }

          begin{document}

          Some text

          % The following two symbols are at page 1
          symindex{$(E, mathcal{E})$}
          symindex{$abc$}
          symindex{$abc$}

          clearpage

          Some text

          % this is at page 2
          symindex{$mu_{X}$}
          symindex{$(E, mathcal{E})$}

          clearpage

          Some text

          % this is at page 3
          symindex{$mu_{Y}$}

          printindex[sym]


          end{document}


          enter image description here






          share|improve this answer























          • this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
            – barbara beeton
            Dec 13 '18 at 1:07












          • @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
            – egreg
            Dec 13 '18 at 9:20












          • Awsome! This was exactly what I wanted. Thanks!
            – data
            Dec 13 '18 at 9:22










          • @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
            – data
            Dec 13 '18 at 18:45






          • 1




            @data Fixed. One needs a couple of unexpanded tokens around #1
            – egreg
            Dec 13 '18 at 18:48













          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%2f464559%2fsort-symbol-index-by-page-occurence%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          You can record an auxiliary counter as the sorting part. This assumes you have less than 1000 symbols (but it can be extended if needed).



          In order to cope with multiple occurrences, the first one will set a key.



          documentclass[oneside,12pt,a4paper]{memoir}
          usepackage{imakeidx}

          makeindex[intoc, name=sym,title=Symbol index]

          newcounter{indexcount}
          newcommand{threedigit}[1]{ifnum #1<100 0fiifnum #1<10 0fi#1}

          newcommand{symindex}[1]{%
          ifcsnamedetokenize{SYM@@#1}endcsname
          index[sym]{csnamedetokenize{SYM@@#1}endcsname @#1}%
          else
          stepcounter{indexcount}%
          expandafterxdefcsname SYM@@detokenize{#1}endcsname{%
          expandafterthreedigitexpandafter{romannumeral-`Qtheindexcount}%
          }%
          index[sym]{threedigit{theindexcount}@unexpanded{unexpanded{#1}}}%
          fi
          }

          begin{document}

          Some text

          % The following two symbols are at page 1
          symindex{$(E, mathcal{E})$}
          symindex{$abc$}
          symindex{$abc$}

          clearpage

          Some text

          % this is at page 2
          symindex{$mu_{X}$}
          symindex{$(E, mathcal{E})$}

          clearpage

          Some text

          % this is at page 3
          symindex{$mu_{Y}$}

          printindex[sym]


          end{document}


          enter image description here






          share|improve this answer























          • this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
            – barbara beeton
            Dec 13 '18 at 1:07












          • @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
            – egreg
            Dec 13 '18 at 9:20












          • Awsome! This was exactly what I wanted. Thanks!
            – data
            Dec 13 '18 at 9:22










          • @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
            – data
            Dec 13 '18 at 18:45






          • 1




            @data Fixed. One needs a couple of unexpanded tokens around #1
            – egreg
            Dec 13 '18 at 18:48


















          4














          You can record an auxiliary counter as the sorting part. This assumes you have less than 1000 symbols (but it can be extended if needed).



          In order to cope with multiple occurrences, the first one will set a key.



          documentclass[oneside,12pt,a4paper]{memoir}
          usepackage{imakeidx}

          makeindex[intoc, name=sym,title=Symbol index]

          newcounter{indexcount}
          newcommand{threedigit}[1]{ifnum #1<100 0fiifnum #1<10 0fi#1}

          newcommand{symindex}[1]{%
          ifcsnamedetokenize{SYM@@#1}endcsname
          index[sym]{csnamedetokenize{SYM@@#1}endcsname @#1}%
          else
          stepcounter{indexcount}%
          expandafterxdefcsname SYM@@detokenize{#1}endcsname{%
          expandafterthreedigitexpandafter{romannumeral-`Qtheindexcount}%
          }%
          index[sym]{threedigit{theindexcount}@unexpanded{unexpanded{#1}}}%
          fi
          }

          begin{document}

          Some text

          % The following two symbols are at page 1
          symindex{$(E, mathcal{E})$}
          symindex{$abc$}
          symindex{$abc$}

          clearpage

          Some text

          % this is at page 2
          symindex{$mu_{X}$}
          symindex{$(E, mathcal{E})$}

          clearpage

          Some text

          % this is at page 3
          symindex{$mu_{Y}$}

          printindex[sym]


          end{document}


          enter image description here






          share|improve this answer























          • this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
            – barbara beeton
            Dec 13 '18 at 1:07












          • @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
            – egreg
            Dec 13 '18 at 9:20












          • Awsome! This was exactly what I wanted. Thanks!
            – data
            Dec 13 '18 at 9:22










          • @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
            – data
            Dec 13 '18 at 18:45






          • 1




            @data Fixed. One needs a couple of unexpanded tokens around #1
            – egreg
            Dec 13 '18 at 18:48
















          4












          4








          4






          You can record an auxiliary counter as the sorting part. This assumes you have less than 1000 symbols (but it can be extended if needed).



          In order to cope with multiple occurrences, the first one will set a key.



          documentclass[oneside,12pt,a4paper]{memoir}
          usepackage{imakeidx}

          makeindex[intoc, name=sym,title=Symbol index]

          newcounter{indexcount}
          newcommand{threedigit}[1]{ifnum #1<100 0fiifnum #1<10 0fi#1}

          newcommand{symindex}[1]{%
          ifcsnamedetokenize{SYM@@#1}endcsname
          index[sym]{csnamedetokenize{SYM@@#1}endcsname @#1}%
          else
          stepcounter{indexcount}%
          expandafterxdefcsname SYM@@detokenize{#1}endcsname{%
          expandafterthreedigitexpandafter{romannumeral-`Qtheindexcount}%
          }%
          index[sym]{threedigit{theindexcount}@unexpanded{unexpanded{#1}}}%
          fi
          }

          begin{document}

          Some text

          % The following two symbols are at page 1
          symindex{$(E, mathcal{E})$}
          symindex{$abc$}
          symindex{$abc$}

          clearpage

          Some text

          % this is at page 2
          symindex{$mu_{X}$}
          symindex{$(E, mathcal{E})$}

          clearpage

          Some text

          % this is at page 3
          symindex{$mu_{Y}$}

          printindex[sym]


          end{document}


          enter image description here






          share|improve this answer














          You can record an auxiliary counter as the sorting part. This assumes you have less than 1000 symbols (but it can be extended if needed).



          In order to cope with multiple occurrences, the first one will set a key.



          documentclass[oneside,12pt,a4paper]{memoir}
          usepackage{imakeidx}

          makeindex[intoc, name=sym,title=Symbol index]

          newcounter{indexcount}
          newcommand{threedigit}[1]{ifnum #1<100 0fiifnum #1<10 0fi#1}

          newcommand{symindex}[1]{%
          ifcsnamedetokenize{SYM@@#1}endcsname
          index[sym]{csnamedetokenize{SYM@@#1}endcsname @#1}%
          else
          stepcounter{indexcount}%
          expandafterxdefcsname SYM@@detokenize{#1}endcsname{%
          expandafterthreedigitexpandafter{romannumeral-`Qtheindexcount}%
          }%
          index[sym]{threedigit{theindexcount}@unexpanded{unexpanded{#1}}}%
          fi
          }

          begin{document}

          Some text

          % The following two symbols are at page 1
          symindex{$(E, mathcal{E})$}
          symindex{$abc$}
          symindex{$abc$}

          clearpage

          Some text

          % this is at page 2
          symindex{$mu_{X}$}
          symindex{$(E, mathcal{E})$}

          clearpage

          Some text

          % this is at page 3
          symindex{$mu_{Y}$}

          printindex[sym]


          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 13 '18 at 18:48

























          answered Dec 12 '18 at 18:57









          egreg

          709k8618823165




          709k8618823165












          • this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
            – barbara beeton
            Dec 13 '18 at 1:07












          • @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
            – egreg
            Dec 13 '18 at 9:20












          • Awsome! This was exactly what I wanted. Thanks!
            – data
            Dec 13 '18 at 9:22










          • @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
            – data
            Dec 13 '18 at 18:45






          • 1




            @data Fixed. One needs a couple of unexpanded tokens around #1
            – egreg
            Dec 13 '18 at 18:48




















          • this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
            – barbara beeton
            Dec 13 '18 at 1:07












          • @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
            – egreg
            Dec 13 '18 at 9:20












          • Awsome! This was exactly what I wanted. Thanks!
            – data
            Dec 13 '18 at 9:22










          • @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
            – data
            Dec 13 '18 at 18:45






          • 1




            @data Fixed. One needs a couple of unexpanded tokens around #1
            – egreg
            Dec 13 '18 at 18:48


















          this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
          – barbara beeton
          Dec 13 '18 at 1:07






          this would be more compelling if the example showed multiple page numbers for a particular symbol. as i understand the question, a symbol can be listed as occurring in multiple places, but the sort order should be by the page number of the first occurrence; it would probably be nice if symbols on the "first" page were in the same order in which they actually appear on that page.
          – barbara beeton
          Dec 13 '18 at 1:07














          @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
          – egreg
          Dec 13 '18 at 9:20






          @barbarabeeton Thanks for the remarks; it turns out that recording the page number is actually not needed. Anyway, symbols were in the order of appearance in the page also in the previous version.
          – egreg
          Dec 13 '18 at 9:20














          Awsome! This was exactly what I wanted. Thanks!
          – data
          Dec 13 '18 at 9:22




          Awsome! This was exactly what I wanted. Thanks!
          – data
          Dec 13 '18 at 9:22












          @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
          – data
          Dec 13 '18 at 18:45




          @egreg I noticed that when I use your construction some in particular $langle$ is rendered as hA and $rangle$ as B. Do you know what might cause that? Before it rendered as one would expect.
          – data
          Dec 13 '18 at 18:45




          1




          1




          @data Fixed. One needs a couple of unexpanded tokens around #1
          – egreg
          Dec 13 '18 at 18:48






          @data Fixed. One needs a couple of unexpanded tokens around #1
          – egreg
          Dec 13 '18 at 18:48




















          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%2f464559%2fsort-symbol-index-by-page-occurence%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

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?