0

I want to remove the page break forcefully inserted by \tableofcontents and so far I have not had much success browsing through forums/StackExchange. [I have added page border only to show separation of pages]

Sample Page Output

In the sample image I have posted, I want the contents of page 2 to appear in the centre right after State of Uttar Pradesh and Others (given on pg 1).

I am using XeTeX and here is the relevant section from my code.

I have written a custom Class file called vakalatnama.cls, in which I have:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{vakalatnama}[2020/09/15 Vakalatnama template for Indian courts]

\LoadClass{article}

\RequirePackage{xparse}
\RequirePackage[driver=xetex,a4paper,noheadfoot,includeheadfoot,nomarginpar,top=1.5in,bottom=1.5in,left=1.75in,right=1.0in]{geometry}
\RequirePackage{xunicode}
% \RequirePackage{xltxtra}

% Make entries in the index table as links
\RequirePackage[linktocpage=true]{hyperref}

% Set font to Times New Roman
\RequirePackage{fontspec}
\setmainfont{Times New Roman}

% line spacing = 1.5
\RequirePackage[onehalfspacing]{setspace}

\RequirePackage[parfill]{parskip}

% Format section title to have numbers in Table of Contents, but not in document
\RequirePackage{titlesec}
\titleformat{\section}{\center \normalfont \bfseries}{}{0pt}{\newpage}
\setcounter{section}{1}

\RequirePackage{fontenc}
\hyphenation{con-sti-tu-tion-al}

% Set title of Table of Contents from Contents -> Particulars. '*' implies that
% the argument must not be in multiple paragraphs i.e. /long
\renewcommand*{\contentsname}{
    \centering{\underline{\textsc{\large{Index}}}} \\
    \parbox{25pt}{\textbf{Si. No.}} \hfill \underline{\textbf{Particulars}} \hfill \underline{\textbf{Page}}
}

\newcommand{\dhc}{Delhi High Court}
\newcommand{\sci}{Supreme Court of India}
\newcommand{\petitioner}[1]{\newcommand{\@petitioner}{#1}}
\newcommand{\respondent}[1]{\newcommand{\respndt}{#1}}
\newcommand{\court}[1]{\newcommand{\crt}{#1}}
\newcommand{\jurisdiction}[1]{\newcommand{\jurisdctn}{#1}}
\newcommand{\petitiontype}[1]{\newcommand{\ptntype}{#1}}

\NewDocumentCommand {\setname} {O{Shri} m m} { % Title (default=Shri), first, last
    \newcommand {\tfname} {#1 #2 #3} % Full name with title
    \newcommand {\fname} {#2 #3} % first + last name
    \newcommand {\tlname} {#1 #3} % title + last name
}

\newcommand{\advocate}[2][Shri]{
    \newcommand{\adv}{#2}
    \newcommand{\fulladv}{#1 #2}
}


\newcommand{\clientdetails}[1]{\newcommand{\clntdtls}{#1}}

\newcommand{\caseNumbers}[2]{
    \newcommand{\fullcasenumber}{#1 of #2}
    \newcommand{\shortcasenumber}{#1/#2}
}


\newcommand{\caseTitle}{
    \begin{center}
        \textsc{In the \crt{}} \newline
        \textsc{\jurisdctn{}} \newline
        \textsc{\ptntype{} \fullcasenumber{}} \newline
    \end{center}
}

\newcommand{\inmatterof}{%
    % \begin {flushleft}
        \begin{tabular}{l c r}
             \multicolumn{3}{l}{\underline{\textsc{In the matter of:}}}  \tabularnewline
             \tabularnewline
             \@petitioner & \ldots & Petitioner \tabularnewline
             & -- \textsc{versus} -- & \tabularnewline
             \respndt & \ldots & Respondent \tabularnewline
        \end{tabular}
   % \end{flushleft}
}

\newcommand{\parties}{%
    \begin {center}
        \begin{tabular}{l c r}
             \@petitioner & \ldots & Appellant/Petitioner \\ %\tabularnewline
             {} & -- \textsc{Between/And} -- & {}  \\ %\tabularnewline
             \respndt & \ldots & Defendant/Respondent/Opposite Party \\ % \tabularnewline
        \end{tabular}
    \end{center}
}

\newcommand{\tophead}{%Roll the Court Name, petition etc into a single command
    \caseTitle{}
    \inmatterof{}
}

\ProcessOptions\relax
\endinput

And there is a separate tex file called cover.tex which contains:

\tophead{}
\tableofcontents
\vfill*
\textbf{Advocate for the Respondent: \respndt{}} 

There is a third file called main.tex which only provides the parameters for these functions and that is the file I use for compilation. The contents of main.tex are:

\documentclass{vakalatnama}
\setcounter{tocdepth}{1}
\begin{document}

\petitioner{Test Petitioner}
\court{Supreme Court Of India}
\respondent{State of Uttar Pradesh and Others}
\jurisdiction{Criminal Appellate Jurisdiction}
\petitiontype{SLP (Civil)}
\caseNumbers{1152}{2000}

\input{cover.tex}
\section{yyy} 
\section{zzz}
\end{document} 

I will be very very grateful for any help on this.

10
  • 1
    you make it very hard for anyone to help if you only post fragments not a test document that can be debugged, but your inmatterof isn't a heading just a flushleft environment so will have vertical space (and a legal page break point) after it, you don't show any code at all for \tableofcontents but if that is making an unbreakable box such as a tabular then it will have to break at the point you show, you could force the page break earlier by adding \clearpage at the point you want the page break. Sep 29, 2020 at 7:12
  • Hello David - Thank you for your comment. I have added more details, earlier I had not posted them in order to keep the post short and to-the-point. Sep 29, 2020 at 7:47
  • 1
    but we still can not run the example to see the problem. or test answers, you could remove the \input lines and replace by just enough \section{zzz} to show the page break you are asking about. Also you have said you do not want the page break where it is, but do you want it earlier so the preceding text comes at the top of the page, you presumably do not want it to break after the Particulars heading row, and there does not look to be space to get any of the table of contents rows on that page as it is? Sep 29, 2020 at 7:57
  • Thank you for your comment and being so patient with me David. I added the suggested edits. In short, I want the Index (which is the title I chose for Table of Contents) to appear on the first page (after the line starting with State of Uttar Pradesh). I removed the other two lines with \input and I have given the contents of cover.tex file in my question Sep 29, 2020 at 8:06
  • 1
    in article class sections do not start on a new page but you are forcing that with \titleformat{\section}{\center \normalfont \bfseries}{}{0pt}{\newpage} Sep 30, 2020 at 9:03

1 Answer 1

2

Note it is bad style to put formatting in \zzzname macros, they were introduced specifically to separate the text name from formatting, so they can be easily translated without having to copy formatting, however I am not suggesting changing that here.

White space at the beginning of a line is dropped this includes \hfill which is why your Index is flush right. \hspace* is a variant of \hspace that prevents this so:

\par\noindent\hspace*{\fill}Index\hspace*{\fill}\\*

would centre the text.

\tableofcontents in article class is a \section* so is affected by your declaration

\titleformat{\section}{\center \normalfont \bfseries}{}{0pt}{\newpage}

which forces a new page. If you want later sections to have this but not in the frontmatter use

\newcommand\secpagebreak{}
\titleformat{\section}{\centering \normalfont \bfseries}{}{0pt}{\secpagebreak}

so it starts off doing nothing,then at some point do

\renewcommand\secpagebreak{\clearpage}

so following sections start on a new page (and prevent floating figures flowing past that point with \clearpage rather than just \newpage).

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.