1

I believe that using packages for solving of all problems in my document makes it compiling time too long and loading many packages cause some unexpected errors. So, I don't want to use unnecessary packages.

Q1: I want to add vertical space before Section titles that started on new page. what is the solution? enter image description here Q2: Also How to reduce space between TOC items in preamble without any package again?

Here is my MWE:

\documentclass[14pt,a4paper]{extbook}
\usepackage[left=1in, right=1.2in, top=1.35in, bottom=1.2in, headsep=.25in, footskip=.3in,
showframe]{geometry}
\usepackage{lipsum}
\renewcommand\baselinestretch{1.2}
\makeatletter
\setlength\parskip{7.2\p@ \@plus \p@}
\makeatother

\begin{document}
    \tableofcontents
    \chapter{First chapter}
\section{First section}
\subsection{First subsection}
\lipsum[1]
\section{Second section}
\subsection{Second subsection}
\lipsum[1-2]
    \chapter{second chapter}
\section{First section} 
\subsection{First subsection} 
\lipsum[1]
\section{Second section}
\subsection{Second subsection}
\lipsum[1-2]
\end{document}

Do you recommend the following trick? (\vspace*{-15pt})

\makeatletter
    \renewcommand\section{\vspace*{-15pt}\@startsection {section}{1}{\z@}%
                                       {-3.5ex \@plus-1ex \@minus-.2ex}%
                                       {1ex \@plus.2ex}%
                                       {\normalfont\fontsize{16}{19.2}\selectfont\bfseries}}
\makeatother
  • 2
    Loading e.g. titlesec to hack into section title and ToC formatting will definitely make you waste precious milliseconds of life ;-) – campa Dec 11 '19 at 13:13
  • "A journey of a thousand miles begins with a single step!!!" –  Dec 11 '19 at 15:00
  • https://tex.stackexchange.com/questions/303836/vertical-space-before-new-section-on-new-page-begins?rq=1 – js bibra Dec 11 '19 at 15:20
  • https://latex.org/forum/viewtopic.php?t=4628 – js bibra Dec 11 '19 at 15:22
  • https://tex.stackexchange.com/questions/56546/how-to-change-spaces-between-items-in-table-of-contents – js bibra Dec 11 '19 at 15:23
  • @cfr--please have a look at Q2 by OP--How to reduce space between TOC items---third link is How to change spaces between items in Table of Contents--and the second link is --Modify Table of Contents: Reduce Spacing Between Lines?--would you agree or should I delete --kindly reconcile and advise – js bibra Dec 11 '19 at 16:05
  • You should use setspace rather than changing \baselinestretch like that. If a package does what you need, it is generally better to load the package than reinvent it in your preamble. There's nothing magic about package code. Adding stuff to your preamble also increases compilation time. The only differences are that (1) LaTeX has to find the package, but this is typically database-based and fast and (2) the package may do more than just what you need, but this will only make a significant difference to compilation time if the package is huge and, even then, it will be minimal. – cfr Dec 11 '19 at 16:07
  • @jsbibra I already deleted my comment. I missed the fact the OP asked two questions on first reading. – cfr Dec 11 '19 at 16:08

1 Answers1

0

A simple solution is as follows:

\newcommand{\mysection}[1]{\vspace*{20pt}\section{#1}}

and use \mysection instead of \section inside the document.