-1

How the distance between first line and equation and last line and equation is different. How to remove the extra space.

enter image description here

I am using this code

 According to given assumption that n is a power of 2 or $n=2^k$
    \begin{center}
    \begin{equation} \label{eq:solve}
     2T(n/2) + 1     
    \end{equation}
    \end{center} 

MWE

\documentclass{article}

\usepackage{fancyhdr} % Required for custom headers
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage{graphicx} % Required to insert images
\usepackage{listings} % Required for insertion of code
\usepackage{courier} % Required for the courier font
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{mathtools}          %loads amsmath as well
\DeclarePairedDelimiter\Floor\lfloor\rfloor
\DeclarePairedDelimiter\Ceil\lceil\rceil

% Margins
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in

\linespread{1.1} % Line spacing
\begin{document}
\begin{section}
According to given assumption that n is a power of 2 or $n=2^k$

\section{equation} 
 2T(n/2) + 1     
\end{equation}

Using Master Theorem where a=2, b=2, d=0;


\end{document}
  • 2
    Please post a compilable MWE, not just a code snippet. – Mico Apr 12 '15 at 07:04
  • what is compatible MWE ? – Arjun Chaudhary Apr 12 '15 at 07:05
  • Please follow the link to learn what an MWE is. – Mico Apr 12 '15 at 07:06
  • 4
    Incidentally, where did you "learn" to encase an equation environment inside a center environment? (Remove the center environment code and the excess vertical space will disappear.) – Mico Apr 12 '15 at 07:11
  • Still some extra space is there i have added MWE – Arjun Chaudhary Apr 12 '15 at 07:16
  • And why using center element gives extra space. – Arjun Chaudhary Apr 12 '15 at 07:17
  • You still have some extra space, because you now have a blank line (which starts a new paragraph) before \begin{equation}. Please study any introductory LaTeX tutorial to learn some of the basics of TeX and LaTeX -- including what not to do, such as (a) encasing an equation environment in a center environment, (b) leaving a blank line above a \begin{equation} statement, or (c) using nonexistent instructions such as \begin{section} and \end{section. – Mico Apr 12 '15 at 07:21
  • Thanks man just started with that all however section thing actually i was using my own definition so included in braces but forget to add definition in beginning for MWE. – Arjun Chaudhary Apr 12 '15 at 07:32
  • One reason for requesting a compilable MWE rather than some code snippets is that it becomes immediately evident that things such as \section{equation} ...\end{equation}` cannot possibly work. Before posting code revisions, please do check if the revised code even compiles. – Mico Apr 12 '15 at 07:43
  • 2
    The supplied MWE clearly does not produce the image shown. – David Carlisle Apr 12 '15 at 09:13
  • unrelated to the vertical space issues but where a=2, b=2, d=0; should be where $a=2$, $b=2$, $d=0$; – David Carlisle Apr 12 '15 at 10:09

1 Answers1

5

First of all, your MWE doesn't work because you wrote \section{equation} ... \end{equation}. Latex does not recognise these tags to be paired, so change the first one to \begin{equation}.

Delete the \begin{section} and \end{section} tags, they serve no purpose. If you want to start a chapter in your document (for the article class), then write \section{Title here}.

As it has also been suggested to you in the comments, leaving a blank line produces a wider vertical space. So for the following code:

According to given assumption that $n$ is a power of $2$ or $n=2^k$

\begin{equation} 
 2T(n/2) + 1     
\end{equation}

According to given assumption that $n$ is a power of $2$ or $n=2^k$
\begin{equation} 
 2T(n/2) + 1     
\end{equation}

You get this result. The first example shows more distance than the second one (although not that evident, it's still present).

enter image description here

Your equation is already centered, so you don't need a center environment, which is what caused the huge space in your case. Also, it's for text anyway, not math, so you have no reason to be using it in this instance. For centering multiple equations, see this question: How do you center equations?

Alenanno
  • 37,338