2

When I have a displayed math equation (\[...\] or equivalently the displaymath environment) at the start of a paragraph right after a heading, there is too much space before it.

This short code reproduces the problem.

\documentclass[a4paper,11pt]{article}
\usepackage[margin=0.5in,footskip=0.25in]{geometry}
\begin{document}
\section{Quadratic formula}
%Line line line line line line line line line.
\[x = \frac{-b\pm\sqrt{b^2-4ac}}{2a}\]
Line line line line line line line line line.
\end{document}

If the commented line is uncommented, the space around the equation becomes acceptable:

Illustration of problem

The problem does not seem to be caused by geometry. Repeating the above without geometry loaded produces this:

Illustration of problem without geometry

Using $$...$$ instead (which seems to be discouraged in LaTeX) does not produce this problem:

Illustration

The problem seems to be caused by the definition of \[ — specifically the italicised line:

\def\[{%
   \relax\ifmmode
      \@badmath
   \else
      \ifvmode
         \nointerlineskip
         \makebox[.6\linewidth]{}%
      \fi
      $$%%$$ BRACE MATCH HACK
   \fi
}

What should I do? Do I just use $$...$$? Or is there a better solution?

8
  • 1
    Please give a use case for a displayed equation immediately follow a sectioning header.
    – Mico
    Commented May 2, 2015 at 14:09
  • @Mico The MWE I gave is more or less the same as my actual document (except that it deals with a different equation). But does it matter? If you intend to suggest that I arrange my document differently, that isn't a solution to the problem.
    – angelsl
    Commented May 2, 2015 at 14:15
  • I bet this is for some kind of equation collection/cheat-sheet right? You wouldn't write an equation after a heading in a thesis or paper, right?
    – Johannes_B
    Commented May 2, 2015 at 14:16
  • @Johannes_B Yeah, it's for my own notes on a subject. Not a formal paper.
    – angelsl
    Commented May 2, 2015 at 14:16
  • 1
    That doesn't answer the question why there is additional space, but ... The section command does some stuff you might not be aware of, generating a toc-entry, stepping counters, placing the title, adding space ... If this is for some personal notes, you can redefine section for your own needs.Of course, you are loosing some funcionality. btw, very good example and welcome to TeX.SX. :-)
    – Johannes_B
    Commented May 2, 2015 at 14:23

1 Answer 1

3

amsmath redefines \[...\] to its own equation* environment which doesn't use \makebox to workaround vmode spacing issues.

So loading amsmath solves this problem.

1
  • The ` amsmath` definitions ans $$ all produce bad spacing if used at the start of the paragraph, although in this case after a heading the amsmath version makes a reasonable result. Commented May 2, 2015 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .