Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Directory display out of page after reconfiguration by \titlecontents (paging failure) #89

@FaterYU

Description

@FaterYU

The error is obviously as shown:

Image

My part of .cls

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{xxxx}[2025/04/01 v1.0.0 xxxx]
\LoadClass[a4paper,12pt]{report}

\renewcommand{\contentsname}{\hfill\bfseries\Large \zihao{-2} \hei \bfseries\quad\hfill}   
\renewcommand{\cftaftertoctitle}{\hfill}

\titlecontents{chapter}[0pt]
  {\zihao{-4} \song}
  {}
  {} 
  {\titlerule*[0.5pc]{.}\contentspage}

\titlecontents{section}[1.5em]
  {\zihao{-4} \song}
  {\thecontentslabel \hspace{1em}}
  {1em} 
  {\titlerule*[0.5pc]{.}\contentspage} 

\titlecontents{subsection}[3.5em
  {\zihao{-4} \song}
  {\thecontentslabel \hspace{1em}} 
  {}
  {\titlerule*[0.5pc]{.}\contentspage}
  % [\addvspace{0pt}]

\newcommand{\toc}{
  \clearpage
  \begingroup
  \singlespacing
  \setstretch{1.25}
  \tableofcontents
  \endgroup
  \clearpage
  \setcounter{page}{1}
  \pagenumbering{arabic}
  \setcounter{chapter}{0}
}

My main.tex:

\documentclass{xxxx}

\begin{document}
    \maketitle

    \begin{abstracten}
    \end{abstracten}

    \begin{abstractzh}
    \end{abstractzh}

    \toc

    \chapter{MAIN BODY}
    \section{Figures}
    \subsection{Example A}
    \section{Tables}
    \subsection{Example A}
    \section{Equations}
    \subsection{Example A}
    \subsection{Example B}
    \section{Citation}
    \subsection{Example A}
    \reference{reference}

    \chapter{MAIN BODY}
    \section{Figures}
    \subsection{Example A}
    \section{Tables}
    \subsection{Example A}
    \section{Equations}
    \subsection{Example A}
    \subsection{Example B}
    \section{Citation}
    \subsection{Example A}
    \reference{reference}

    \chapter{MAIN BODY}
    \section{Figures}
    \subsection{Example A}
    \section{Tables}
    \subsection{Example A}
    \section{Equations}
    \subsection{Example A}
    \subsection{Example B}
    \section{Citation}
    \subsection{Example A}
    \reference{reference}

    \chapter{MAIN BODY}
    \section{Figures}
    \subsection{Example A}
    \section{Tables}
    \subsection{Example A}
    \section{Equations}
    \subsection{Example A}
    \subsection{Example B}
    \section{Citation}
    \subsection{Example A}
    \reference{reference}

    \chapter{MAIN BODY}
    \section{Figures}
    \subsection{Example A}
    \section{Tables}
    \subsection{Example A}
    \section{Equations}
    \subsection{Example A}
    \subsection{Example B}
    \section{Citation}
    \subsection{Example A}
    \reference{reference}

    \appendix
    \section{Appendix A}
    \section{Appendix B}
    \section{Appendix C}

    \acknowledgements
\end{document}

Magically, when I delete one of \titlecontents{chapter}, \titlecontents{section}, \titlecontents{subsection}, normal page-changing occurs. But I need to reconfigure both of them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions