1

I want to create a report for my project and I wrote a code but it is showing some error in table of contents. The page numbering goes fine in the beginning but as chapter 1 starts its shows the numbering as 2 but in the document the page numbering is 1. The document should be about 50 pages. Here is the sample of the code I wrote:

  \documentclass[12pt,a4paper]{report}
  \usepackage{lipsum}
  \usepackage[explicit]{titlesec}
  \titleformat{\chapter}[display]{\bfseries\centering}{\huge Chapter \thechapter}{1em}{\Huge #1}
  \usepackage{pgf}
  \usepackage{pgfpages}

  \pgfpagesdeclarelayout{boxed}
  {
      \edef\pgfpageoptionborder{0pt}
  }
  {
       \pgfpagesphysicalpageoptions
        {%
             logical pages=1,%
        }
       \pgfpageslogicalpageoptions{1}
        {
              border code=\pgfsetlinewidth{2pt}\pgfstroke,%changes the width of border
              border shrink=\pgfpageoptionborder,%
              resized width=.95\pgfphysicalwidth,%change the size of border
              resized height=.95\pgfphysicalheight,%
              center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%make the border to 
              display in center
              }%
        }

 \pgfpagesuselayout{boxed}
 \usepackage[utf8]{inputenc}    
 \usepackage{listings}
 \usepackage{amsmath}
 \usepackage{amsfonts}
 \usepackage{amssymb}
 \usepackage[a4paper,left=1.5in,right=1in,top=1in,bottom=1in]{geometry}
 \usepackage{graphicx}
 \begin{document}
 \begin{center}
 \thispagestyle{empty}
 \parskip=8pt%
 \vspace*{1\parskip}%
 \textbf{SYNCHRONOUS \& ASYNCHRONOUS DESIGN}

 \textbf{Project Title}

 A Project Report Submitted in Partial Fulfillment of the Requirements for the Degree of
 \parskip=20pt

 \textbf{Course}
 \parskip=4pt

 \textbf{Branch}

 \textit{By}

 \parskip=8pt%
 \textbf{Name of Student}

 \textbf{College ID}

 \begin{figure}[ht]
 \includegraphics[width=2.2098cm, height=2.2098cm]{image1}
 \centering
 \label{4}
 \end{figure}

 \textit{Under the supervision of}
 \parskip=24pt%


 \textbf{Guide Name}
 \parskip=4pt

 \textbf{Guide Designation}

 \textbf{Company Address}
 \begin{figure}[ht]
 \includegraphics[width=2.8cm, height=2.8cm]{image}
 \centering
 \label{7}
 \end{figure}

 \textbf{College Department}\\
 \textbf{College name}\\
 \textbf{College Address}\\
 \textbf{Jan-June (2020)}
 \end{center}

 \addcontentsline{toc}{chapter}{CERTIFICATE}
 \chapter*{CERTIFICATE}
 \pagenumbering{roman}
  This is the certificate.

 \addcontentsline{toc}{chapter}{ACKNOWLEDGMENT}
 \chapter*{ACKNOWLEDGMENT}
  Acknowledgment 

 \addcontentsline{toc}{chapter}{ABSTRACT}
 \chapter*{ABSTRACT}
  Abstract goes here.....


 \addcontentsline{toc}{chapter}{CONTENTS}
 \tableofcontents


 \addcontentsline{toc}{chapter}{LIST OF FIGURES}
 \listoffigures


 \addcontentsline{toc}{chapter}{LIST OF TABLES}
 \listoftables


  \chapter{INTRODUCTION}
  \pagenumbering{arabic}
   Introduction

  \section{section}

  \subsection{part}

  \end{document}

I tried different solutions available online but none of them works for me. Can someone help me with this?

  • \phantomsection might help with your numbering problem - see this answer – fcbsd Mar 27 '20 at 16:33
  • The problem is caused by the \pgfpagesuselayout{boxed} --- don't use it and the ToC numbering is correct. I can't help with the \pgfpagesuselayout code but I don't like the result --- in your MWE the page numbers in the ToC extend into the black border. – Peter Wilson Mar 27 '20 at 18:46
  • I used \phantomsection command but it's still not working. Is there any other way? @fcbsd – Prachi Agrawal Mar 30 '20 at 09:09
  • @PrachiAgrawal The other way is described in the duplicate question (i.e., compile first one time without the boxed layout, then use the boxed layout with \nofiles and compile again). Arguably this is not a very convenient solution (and it can be called a bug in pgfpages, especially for logical pages=1), but it works. – Marijn Mar 30 '20 at 13:07
  • @Marijn I tried that too but then there is a difference in numbering of the pages before introduction, i.e., numbering of certificate, abstract, acknowledgement, etc. – Prachi Agrawal Mar 31 '20 at 06:52
  • @PrachiAgrawal that is part of a different problem. For starred chapters \addcontentsline should come after the chapter title. For the list of figures etc. it should come before, but you should clear the page first so \addcontentsline knows a new page is about to start. With that I get the following result: https://imgur.com/a/I25NT8r with the following code: – Marijn Mar 31 '20 at 07:53
  • \pgfpagesuselayout{boxed}\nofiles [...] \chapter*{CERTIFICATE} \pagenumbering{roman} \addcontentsline{toc}{chapter}{CERTIFICATE} certificate \chapter*{ACKNOWLEDGMENT} \addcontentsline{toc}{chapter}{ACKNOWLEDGMENT} Ack. \chapter*{ABSTRACT} \addcontentsline{toc}{chapter}{ABSTRACT} Abstract \cleardoublepage \addcontentsline{toc}{chapter}{CONTENTS} \tableofcontents \cleardoublepage \addcontentsline{toc}{chapter}{LIST OF FIGURES} \listoffigures \cleardoublepage \addcontentsline{toc}{chapter}{LIST OF TABLES} \listoftables \chapter{INTRODUCTION} \pagenumbering{arabic} Intro – Marijn Mar 31 '20 at 07:56
  • Thank You @Marijn. I'll try this and let you know. – Prachi Agrawal Apr 01 '20 at 10:28
  • @PeterWilson I got the same issue earlier of the extended numbering into the border but now it's working fine. – Prachi Agrawal Apr 01 '20 at 10:33
  • 1
    @Marijn Thank you so much. My code is working fine now. – Prachi Agrawal Apr 06 '20 at 06:59

0 Answers0