[Tex/LaTex] How to remove spaces between paragraph and lines
spacing
In given below text, I want to remove space between "diverse areas" to "2.1.1 Brief…".
Best Answer
Based on my answer at Spacing before and after section titles, but with space removed rather than added. Here, I use \sectionprelude and if needed, \sectionpostlude to modify the default space before and after section headings. However, they can also be used to add ruled lines and other such stylistic modifications to the section head appearance.
Obviously, similar things can be done for subsections, etc.
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\let\origsection\section
\renewcommand\section{\@ifstar{\starsection}{\nostarsection}}
\newcommand\nostarsection[1]
{\sectionprelude\origsection{#1}\sectionpostlude}
\newcommand\starsection[1]
{\sectionprelude\origsection*{#1}\sectionpostlude}
\newcommand\sectionprelude{%
\vspace{-4ex}% STUFF TO DO PRIOR TO THE SECTION HEADING
}
\newcommand\sectionpostlude{%
% \vspace{-2.5ex}% STUFF TO DO FOLLOWING THE SECTION HEADING
}
\makeatother
\begin{document}
\lipsum[4]
\section{Section Title}
\lipsum[1]
\end{document}
\documentclass{scrbook}
\KOMAoptions{fontsize=10pt, paper=14cm:21cm, DIV=calc, pagesize=auto, BCOR=5mm, twoside=true, titlepage=true}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
% shows frames of type area (good for debugging)
\usepackage{showframe}
\makeatletter
% change definition of \section; remove space before
\renewcommand{\section}{\@startsection{section}{1}{\z@}%
{-0.01ex}%
{2.3ex \@plus.2ex}%
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}
\makeatother
\begin{document}
\vspace*{-\topskip}
\section{Test}
Test
\end{document}
The code redefines the \section command in the way that the space before is set to -0.01ex (must be a negative number to avoid paragraph indention). There is only a little bit space left. Remove or comment out \vspace*{-\topskip} to see test this.
Best Answer
Based on my answer at Spacing before and after section titles, but with space removed rather than added. Here, I use
\sectionprelude
and if needed,\sectionpostlude
to modify the default space before and after section headings. However, they can also be used to add ruled lines and other such stylistic modifications to the section head appearance.Obviously, similar things can be done for subsections, etc.