2

Hello I'm trying to make table of contents manually, I mean I set the page of each of sections one by one. Here's my target: enter image description here and I'm using book class here. Help me please

Here's the code that I found

\documentclass[oneside]{book}
\renewcommand\contentsname{CONTENTS}
\renewcommand\listtablename{LIST OF TABLES}
\renewcommand\listfigurename{LIST OF FIGURES}
\addtocontents{toc}{{\bfseries Contents\hfill Page No.\bigskip\par}}
\addtocontents{lot}{{\bfseries No.\hfill Title\hfill\hfill Page No.\bigskip\par}}
\addtocontents{lof}{{\bfseries No.\hfill Title\hfill\hfill Page No.\bigskip\par}}

\usepackage[titles]{tocloft}
\usepackage{xcolor,xpatch}
\renewcommand\cftbeforechapskip{0ex}
\renewcommand\cftchapfont{\mdseries}
\renewcommand\cftchappagefont{\mdseries}
\renewcommand\cftchappresnum{Chapter~}
\renewcommand\cftchapaftersnum{. }
\newlength\tocindent
\settowidth\tocindent{\cftchapfont\cftchappresnum9\cftchapaftersnum}
\edef\cftchapnumwidth{\the\tocindent}
\edef\cftsecindent{\the\tocindent}
\advance\tocindent2.3em
\edef\cftsubsecindent{\the\tocindent}
\advance\tocindent3.2em
\edef\cftsubsubsecindent{\the\tocindent}
\renewcommand\cftsecdotsep{\cftnodots}
\renewcommand\cftsubsecdotsep{\cftnodots}
\renewcommand\cftsubsubsecdotsep{\cftnodots}
\newcommand\tocmainmatter
{\renewcommand\cftchappagefont{\color{white}}%
}
\xapptocmd\mainmatter{\addtocontents{toc}{\protect\tocmainmatter}}{}{}


\newif\ifschaptertoc
\makeatletter
\renewcommand\@makeschapterhead[1]%
{{\parindent \z@ \centering
    \normalfont
    \interlinepenalty\@M
    \Large \bfseries  #1\par\nobreak
    \vskip 20\p@
}%
\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
\ifschaptertoc
\addcontentsline{toc}{chapter}{#1}%
\fi
}
\makeatother

\usepackage{blindtext}

\begin{document}
\frontmatter

\tableofcontents
\schaptertoctrue

\chapter*{ACKNOWLEDGEMENTS}
\blindtext

\chapter*{ABSTRACT}
\blindtext

\listoftables

\listoffigures

\chapter*{ABBREVIATIONS}
\Blindtext

\chapter*{NOTATIONS}
\Blindtext

\mainmatter

\chapter{INTRODUCTION}
\blindtext

\section{General Background}
\blindtext

\section{Objective}
\blindtext
\subsection{Objective 1}
\blindtext
\subsection{Objective 2}
\blindtext
\subsection{Objective 3}
\blindtext

\section{Scheme}
\blindtext
\end{document}

I'm sorry that I cant provide you my own codes since I don't really know how to start,

  • Please can you put your minimal LaTeX code that reproduce your problem? It seems to me that the image is built with Word of Microsoft Office. – Sebastiano Oct 28 '18 at 21:29
  • 1
    @Sebastiano: Yes it is – SutMar Oct 28 '18 at 21:59
  • would you please help me out of this problem? – SutMar Oct 28 '18 at 23:29
  • There is an excellent answer of Fran. If you problem is solved, you check green mark to the @Fran' answer. – Sebastiano Oct 29 '18 at 12:27
5

I cannot figure why the hell nobody would want to do this. Maybe knowing the problem we can suggest a better solution that make a TOC manually. Nonetheless, the trick is simple: just open the auxiliary .toc file created after the compilation of the code your showed, then, just "copy & paste & modify as you want" in substitution of the \tableofcontents, or in a empty .tex document, and voilá, a manual TOC:

mwe

\documentclass{book}
\pagestyle{empty}
\begin{document}
\noindent{\bfseries{\huge Contents}\hfill Page No.\vspace \bigskipamount \par }
\contentsline {chapter}{ACKNOWLEDGEMENTS}{ii}
\contentsline {chapter}{ABSTRACT}{iii}
\contentsline {chapter}{LIST OF TABLES}{iv}
\contentsline {chapter}{LIST OF FIGURES}{v}
\contentsline {chapter}{ABBREVIATIONS}{vi}
\contentsline {chapter}{NOTATIONS}{viii}
\contentsline {chapter}{\numberline {1}INTRODUCTION}{1}
\contentsline {section}{\numberline {1.1}General Background}{1}
\contentsline {section}{\numberline {1.2}Objective}{3}
\contentsline {subsection}{\numberline {1.2.1}Objective 1}{5}
\contentsline {subsection}{\numberline {1.2.2}Objective 2}{12}
\contentsline {subsection}{\numberline {1.2.3}Objective 3}{15}
\contentsline {section}{\numberline {1.3}Scheme}{16}
\end{document}
  • Very good. You have created a very simple code. – Sebastiano Oct 29 '18 at 12:28
  • @Sebastiano. But really I have not created anything! If you editor does not hide/remove the auxiliary files, compile the MWE of the question and open the created .toc file by pdflatex. You can check that is nearly the same code. My "brilliant idea" here was only include it in a compilable document and change something. – Fran Oct 29 '18 at 18:30
  • For my opinion is very good and.....+1. – Sebastiano Oct 29 '18 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.