Page numbers in ToC not right aligned











up vote
1
down vote

favorite












I have a problem with my ToC. If a Chapter title is as long as the width of the TOC, then the page number is forced into the next line. However, the page number is not aligned on the right hand side but on the left. I would like the page number to be in all cases on the right. May be there is a way to set this. I am using the titletoc package.



enter image description here



That is my code



documentclass[twoside,openany,10pt]{book}  
usepackage[paperwidth=5in, paperheight=8in, bindingoffset=0.375in, top=0.7in, bottom=0.7in, left=0.5in, right=0.5in]{geometry}
renewcommand{baselinestretch}{1.3}
usepackage{titlesec}
usepackage {setspace}
usepackage{librebaskerville}
usepackage[T1]{fontenc}
usepackage{anyfontsize}
usepackage{letterspace}
usepackage{fancyhdr}
usepackage{titletoc}%
usepackage{graphicx}
usepackage{float}
usepackage[overload]{textcase}
usepackage{microtype}
usepackage[symbol]{footmisc}
usepackage{enumerate}


renewcommand{thefootnote}{fnsymbol{footnote}}




titlecontents{chapter}% <section-type>
[2.3em]% <left>
{small}% <above-code>
{hspace*{-2.3em}makebox[2.3em][l]{thecontentslabel. }}% <numbered-entry-format>
{}% <numberless-entry-format>
{hfillcontentspage}% <filler-page-format>




%Begin Document
begin{document}

pagestyle{empty}
tableofcontents % Print table of contents
thispagestyle{empty}

%newcommand{chaptertolists}{}


%HERE BEGINS TEXT EDITING


mainmatter % only in book class (arabic page #s)
pagestyle{fancy}
renewcommand{chaptermark}[1]{
markboth{Thought Vibration} {#1}}
fancyhead[CO]{small itshape rightmark}
fancyhead[CE]{small itshape leftmark}
fancyhead[RE,LO]{}
fancyhead[LE,RO]{}
fancyfoot[CO, CE]{small thepage}



titleformat{chapter}[display]
{normalfonthugebfseriescentering}{lsstyleMakeUppercase{chaptertitlename} thechapter}{20pt}{normalfontLARGEitshape}
titlespacing*{chapter}{0pt}{30pt}{20pt}

pagenumbering{arabic}

%ONLY FOR COLLECTIONS
%addtocontents{toc}{protectthispagestyle{empty}}
%addcontentsline{toc}{part}{The Science of Getting Rich}
%part*{The Science of Getting Rich}

addtocontents{toc}{protectthispagestyle{empty}}
addcontentsline{toc}{chapter}{Preface}
markboth{Thought Vibration} {Preface}
chapter*{Preface}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

addtocontents{toc}{protectthispagestyle{empty}}
addcontentsline{toc}{chapter}{Foreword}
markboth{Thought Vibration} {Foreword}
chapter*{Foreword}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

addtocontents{toc}{protectthispagestyle{empty}}
addcontentsline{toc}{chapter}{My Working Creed}
markboth{Thought Vibration} {My Working Creed}
chapter*{My Working Creed}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

chapter{The Law Of Attraction In The Thought World}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

chapter{Thought‐Waves And Their Process Of Reproduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

end{document}


Thanks in advance. :)










share|improve this question














bumped to the homepage by Community 1 min ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.



















    up vote
    1
    down vote

    favorite












    I have a problem with my ToC. If a Chapter title is as long as the width of the TOC, then the page number is forced into the next line. However, the page number is not aligned on the right hand side but on the left. I would like the page number to be in all cases on the right. May be there is a way to set this. I am using the titletoc package.



    enter image description here



    That is my code



    documentclass[twoside,openany,10pt]{book}  
    usepackage[paperwidth=5in, paperheight=8in, bindingoffset=0.375in, top=0.7in, bottom=0.7in, left=0.5in, right=0.5in]{geometry}
    renewcommand{baselinestretch}{1.3}
    usepackage{titlesec}
    usepackage {setspace}
    usepackage{librebaskerville}
    usepackage[T1]{fontenc}
    usepackage{anyfontsize}
    usepackage{letterspace}
    usepackage{fancyhdr}
    usepackage{titletoc}%
    usepackage{graphicx}
    usepackage{float}
    usepackage[overload]{textcase}
    usepackage{microtype}
    usepackage[symbol]{footmisc}
    usepackage{enumerate}


    renewcommand{thefootnote}{fnsymbol{footnote}}




    titlecontents{chapter}% <section-type>
    [2.3em]% <left>
    {small}% <above-code>
    {hspace*{-2.3em}makebox[2.3em][l]{thecontentslabel. }}% <numbered-entry-format>
    {}% <numberless-entry-format>
    {hfillcontentspage}% <filler-page-format>




    %Begin Document
    begin{document}

    pagestyle{empty}
    tableofcontents % Print table of contents
    thispagestyle{empty}

    %newcommand{chaptertolists}{}


    %HERE BEGINS TEXT EDITING


    mainmatter % only in book class (arabic page #s)
    pagestyle{fancy}
    renewcommand{chaptermark}[1]{
    markboth{Thought Vibration} {#1}}
    fancyhead[CO]{small itshape rightmark}
    fancyhead[CE]{small itshape leftmark}
    fancyhead[RE,LO]{}
    fancyhead[LE,RO]{}
    fancyfoot[CO, CE]{small thepage}



    titleformat{chapter}[display]
    {normalfonthugebfseriescentering}{lsstyleMakeUppercase{chaptertitlename} thechapter}{20pt}{normalfontLARGEitshape}
    titlespacing*{chapter}{0pt}{30pt}{20pt}

    pagenumbering{arabic}

    %ONLY FOR COLLECTIONS
    %addtocontents{toc}{protectthispagestyle{empty}}
    %addcontentsline{toc}{part}{The Science of Getting Rich}
    %part*{The Science of Getting Rich}

    addtocontents{toc}{protectthispagestyle{empty}}
    addcontentsline{toc}{chapter}{Preface}
    markboth{Thought Vibration} {Preface}
    chapter*{Preface}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

    addtocontents{toc}{protectthispagestyle{empty}}
    addcontentsline{toc}{chapter}{Foreword}
    markboth{Thought Vibration} {Foreword}
    chapter*{Foreword}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

    addtocontents{toc}{protectthispagestyle{empty}}
    addcontentsline{toc}{chapter}{My Working Creed}
    markboth{Thought Vibration} {My Working Creed}
    chapter*{My Working Creed}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

    chapter{The Law Of Attraction In The Thought World}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

    chapter{Thought‐Waves And Their Process Of Reproduction}

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

    end{document}


    Thanks in advance. :)










    share|improve this question














    bumped to the homepage by Community 1 min ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a problem with my ToC. If a Chapter title is as long as the width of the TOC, then the page number is forced into the next line. However, the page number is not aligned on the right hand side but on the left. I would like the page number to be in all cases on the right. May be there is a way to set this. I am using the titletoc package.



      enter image description here



      That is my code



      documentclass[twoside,openany,10pt]{book}  
      usepackage[paperwidth=5in, paperheight=8in, bindingoffset=0.375in, top=0.7in, bottom=0.7in, left=0.5in, right=0.5in]{geometry}
      renewcommand{baselinestretch}{1.3}
      usepackage{titlesec}
      usepackage {setspace}
      usepackage{librebaskerville}
      usepackage[T1]{fontenc}
      usepackage{anyfontsize}
      usepackage{letterspace}
      usepackage{fancyhdr}
      usepackage{titletoc}%
      usepackage{graphicx}
      usepackage{float}
      usepackage[overload]{textcase}
      usepackage{microtype}
      usepackage[symbol]{footmisc}
      usepackage{enumerate}


      renewcommand{thefootnote}{fnsymbol{footnote}}




      titlecontents{chapter}% <section-type>
      [2.3em]% <left>
      {small}% <above-code>
      {hspace*{-2.3em}makebox[2.3em][l]{thecontentslabel. }}% <numbered-entry-format>
      {}% <numberless-entry-format>
      {hfillcontentspage}% <filler-page-format>




      %Begin Document
      begin{document}

      pagestyle{empty}
      tableofcontents % Print table of contents
      thispagestyle{empty}

      %newcommand{chaptertolists}{}


      %HERE BEGINS TEXT EDITING


      mainmatter % only in book class (arabic page #s)
      pagestyle{fancy}
      renewcommand{chaptermark}[1]{
      markboth{Thought Vibration} {#1}}
      fancyhead[CO]{small itshape rightmark}
      fancyhead[CE]{small itshape leftmark}
      fancyhead[RE,LO]{}
      fancyhead[LE,RO]{}
      fancyfoot[CO, CE]{small thepage}



      titleformat{chapter}[display]
      {normalfonthugebfseriescentering}{lsstyleMakeUppercase{chaptertitlename} thechapter}{20pt}{normalfontLARGEitshape}
      titlespacing*{chapter}{0pt}{30pt}{20pt}

      pagenumbering{arabic}

      %ONLY FOR COLLECTIONS
      %addtocontents{toc}{protectthispagestyle{empty}}
      %addcontentsline{toc}{part}{The Science of Getting Rich}
      %part*{The Science of Getting Rich}

      addtocontents{toc}{protectthispagestyle{empty}}
      addcontentsline{toc}{chapter}{Preface}
      markboth{Thought Vibration} {Preface}
      chapter*{Preface}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      addtocontents{toc}{protectthispagestyle{empty}}
      addcontentsline{toc}{chapter}{Foreword}
      markboth{Thought Vibration} {Foreword}
      chapter*{Foreword}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      addtocontents{toc}{protectthispagestyle{empty}}
      addcontentsline{toc}{chapter}{My Working Creed}
      markboth{Thought Vibration} {My Working Creed}
      chapter*{My Working Creed}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      chapter{The Law Of Attraction In The Thought World}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      chapter{Thought‐Waves And Their Process Of Reproduction}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      end{document}


      Thanks in advance. :)










      share|improve this question













      I have a problem with my ToC. If a Chapter title is as long as the width of the TOC, then the page number is forced into the next line. However, the page number is not aligned on the right hand side but on the left. I would like the page number to be in all cases on the right. May be there is a way to set this. I am using the titletoc package.



      enter image description here



      That is my code



      documentclass[twoside,openany,10pt]{book}  
      usepackage[paperwidth=5in, paperheight=8in, bindingoffset=0.375in, top=0.7in, bottom=0.7in, left=0.5in, right=0.5in]{geometry}
      renewcommand{baselinestretch}{1.3}
      usepackage{titlesec}
      usepackage {setspace}
      usepackage{librebaskerville}
      usepackage[T1]{fontenc}
      usepackage{anyfontsize}
      usepackage{letterspace}
      usepackage{fancyhdr}
      usepackage{titletoc}%
      usepackage{graphicx}
      usepackage{float}
      usepackage[overload]{textcase}
      usepackage{microtype}
      usepackage[symbol]{footmisc}
      usepackage{enumerate}


      renewcommand{thefootnote}{fnsymbol{footnote}}




      titlecontents{chapter}% <section-type>
      [2.3em]% <left>
      {small}% <above-code>
      {hspace*{-2.3em}makebox[2.3em][l]{thecontentslabel. }}% <numbered-entry-format>
      {}% <numberless-entry-format>
      {hfillcontentspage}% <filler-page-format>




      %Begin Document
      begin{document}

      pagestyle{empty}
      tableofcontents % Print table of contents
      thispagestyle{empty}

      %newcommand{chaptertolists}{}


      %HERE BEGINS TEXT EDITING


      mainmatter % only in book class (arabic page #s)
      pagestyle{fancy}
      renewcommand{chaptermark}[1]{
      markboth{Thought Vibration} {#1}}
      fancyhead[CO]{small itshape rightmark}
      fancyhead[CE]{small itshape leftmark}
      fancyhead[RE,LO]{}
      fancyhead[LE,RO]{}
      fancyfoot[CO, CE]{small thepage}



      titleformat{chapter}[display]
      {normalfonthugebfseriescentering}{lsstyleMakeUppercase{chaptertitlename} thechapter}{20pt}{normalfontLARGEitshape}
      titlespacing*{chapter}{0pt}{30pt}{20pt}

      pagenumbering{arabic}

      %ONLY FOR COLLECTIONS
      %addtocontents{toc}{protectthispagestyle{empty}}
      %addcontentsline{toc}{part}{The Science of Getting Rich}
      %part*{The Science of Getting Rich}

      addtocontents{toc}{protectthispagestyle{empty}}
      addcontentsline{toc}{chapter}{Preface}
      markboth{Thought Vibration} {Preface}
      chapter*{Preface}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      addtocontents{toc}{protectthispagestyle{empty}}
      addcontentsline{toc}{chapter}{Foreword}
      markboth{Thought Vibration} {Foreword}
      chapter*{Foreword}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      addtocontents{toc}{protectthispagestyle{empty}}
      addcontentsline{toc}{chapter}{My Working Creed}
      markboth{Thought Vibration} {My Working Creed}
      chapter*{My Working Creed}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      chapter{The Law Of Attraction In The Thought World}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      chapter{Thought‐Waves And Their Process Of Reproduction}

      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco

      end{document}


      Thanks in advance. :)







      table-of-contents page-numbering titletoc






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 1:17









      Lisa

      213




      213





      bumped to the homepage by Community 1 min ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 1 min ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You should use hangindent in the above code. I've made the change to your titlecontents (remember to delete old toc and double run it):



          titlecontents{chapter}
          [3.3em]
          {smallhangindent2.3em}% <- Change made here
          {makebox[2.3em][l]{thecontentslabel.}}
          {}%
          {hfillcontentspage}


          This compiles to the following:



          changed contents



          If possible, you can also use the chapter command to shorten the text displayed in the toc using the following syntax:



          chapter{short version}{long version}



          so that chapter{The Laws Of Attraction}{The Law Of Attraction In The Thought World}



          which compiles to the following:



          using chapter



          Hope this helps.






          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%2f459540%2fpage-numbers-in-toc-not-right-aligned%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








            up vote
            0
            down vote













            You should use hangindent in the above code. I've made the change to your titlecontents (remember to delete old toc and double run it):



            titlecontents{chapter}
            [3.3em]
            {smallhangindent2.3em}% <- Change made here
            {makebox[2.3em][l]{thecontentslabel.}}
            {}%
            {hfillcontentspage}


            This compiles to the following:



            changed contents



            If possible, you can also use the chapter command to shorten the text displayed in the toc using the following syntax:



            chapter{short version}{long version}



            so that chapter{The Laws Of Attraction}{The Law Of Attraction In The Thought World}



            which compiles to the following:



            using chapter



            Hope this helps.






            share|improve this answer



























              up vote
              0
              down vote













              You should use hangindent in the above code. I've made the change to your titlecontents (remember to delete old toc and double run it):



              titlecontents{chapter}
              [3.3em]
              {smallhangindent2.3em}% <- Change made here
              {makebox[2.3em][l]{thecontentslabel.}}
              {}%
              {hfillcontentspage}


              This compiles to the following:



              changed contents



              If possible, you can also use the chapter command to shorten the text displayed in the toc using the following syntax:



              chapter{short version}{long version}



              so that chapter{The Laws Of Attraction}{The Law Of Attraction In The Thought World}



              which compiles to the following:



              using chapter



              Hope this helps.






              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                You should use hangindent in the above code. I've made the change to your titlecontents (remember to delete old toc and double run it):



                titlecontents{chapter}
                [3.3em]
                {smallhangindent2.3em}% <- Change made here
                {makebox[2.3em][l]{thecontentslabel.}}
                {}%
                {hfillcontentspage}


                This compiles to the following:



                changed contents



                If possible, you can also use the chapter command to shorten the text displayed in the toc using the following syntax:



                chapter{short version}{long version}



                so that chapter{The Laws Of Attraction}{The Law Of Attraction In The Thought World}



                which compiles to the following:



                using chapter



                Hope this helps.






                share|improve this answer














                You should use hangindent in the above code. I've made the change to your titlecontents (remember to delete old toc and double run it):



                titlecontents{chapter}
                [3.3em]
                {smallhangindent2.3em}% <- Change made here
                {makebox[2.3em][l]{thecontentslabel.}}
                {}%
                {hfillcontentspage}


                This compiles to the following:



                changed contents



                If possible, you can also use the chapter command to shorten the text displayed in the toc using the following syntax:



                chapter{short version}{long version}



                so that chapter{The Laws Of Attraction}{The Law Of Attraction In The Thought World}



                which compiles to the following:



                using chapter



                Hope this helps.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 12 at 2:40

























                answered Nov 12 at 2:25









                Ole Anders

                341112




                341112






























                    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%2f459540%2fpage-numbers-in-toc-not-right-aligned%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

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt