0

If I use amsmath and have an eqation as its own paragraph (surrounded by empty lines), the space around it is too large and the space above is much greater than the space below. Why is that? If I don't use amsmath, the space is small.

I want that the spaces around equations would be the same as spaces between paragraphs. How can that be done?

Here is a demonstration of the spacing:

\documentclass{minimal}
\usepackage[paperwidth=5cm, paperheight=5cm]{geometry}
\usepackage{amsmath}

\begin{document}

paragraph

\begin{equation} a = b \end{equation}

paragraph

\end{document}

enter image description here

matj1
  • 109
  • As a general rule, a math display should never be preceded by a blank line. – egreg Jan 04 '23 at 17:47
  • and as a general rule, don't use the minimal class as it is often too minimal. Use article for such examples. – Ulrike Fischer Jan 04 '23 at 18:00
  • 1
    @egreg Why? The equation is its own unit possibly not related to the preceding paraghraph, so I expect that it would be represented as a paragraph. Also, If I have several paragraphs or equations after each other not separated by lines, the source is too dense and searching in it is difficult. – matj1 Jan 04 '23 at 18:10
  • 1
    @egreg Also, I have a custom environment which sometimes contains just an equation, and the equation can't be joined with the previous paragraph, so there is always the weird space above the equation. – matj1 Jan 04 '23 at 18:34
  • 1
    this is not a feature of amsmath, you see the same in plain tex with $$ Tex does not support starting a paragraph with a math display – David Carlisle Jan 04 '23 at 19:32
  • @DavidCarlisle Then, can I put an object with zero size before the equation, so the equation is not at the beginning of a paragraph, but nothing takes space before it? – matj1 Jan 04 '23 at 19:36
  • @matj1 just don't have a paragraph break, you could use % if you want a more or less empty line without ending a paragraph – David Carlisle Jan 04 '23 at 19:45
  • @DavidCarlisle Like I said, I have an environment where, if its content begins with an equation, the equation can't be joined with a previous paragraph. If I showed you the implementation, would you help me rework it so it would be as intended? – matj1 Jan 04 '23 at 19:53
  • @DavidCarlisle Why can't TEX paragraphs begin with equations? What caused Donald Knuth to implement it that way? – matj1 Jan 04 '23 at 19:56
  • You'd have to ask him. You can (if you must) use \noindent\begin{equation*} – David Carlisle Jan 04 '23 at 19:57
  • \noindent works, but only in vacuum. It doesn't work in my case. The environment uses addmargin from KOMA-Script, and, if the equation is at the beginning of addmargin, \noindent doesn't work – matj1 Jan 04 '23 at 20:43
  • "the equation can't be joined with the previous paragraph" I don't understand what you mean by this. If you use %, that gets rid of the vertical space you don't want. Why are you objecting to that? – Teepeemm Jan 04 '23 at 20:52
  • @Teepeemm If the equation is at the beginning of the inside of addmargin, a directly previous paragraph doesn't exist. – matj1 Jan 04 '23 at 20:59
  • @matj1 Because no well written paragraph starts with a formula, displayed or not. – egreg Jan 04 '23 at 21:22
  • It sounds like that means your question is really "how can I begin an KOMA script addmargin with a displayed equation?" Is that correct? It might be better to ask that question. – Teepeemm Jan 04 '23 at 21:28
  • 1
    @egreg I don't understand how a paragraph starting with a formula can't be well written. It seem like a too big generalisation. – matj1 Jan 04 '23 at 21:46
  • @matj1 Please, make some authoritative example from books printed by important publishers. Maybe you find some occasional inline formula starting a paragraph. – egreg Jan 04 '23 at 21:50
  • @Teepeemm Yes, but I would rather have a proper way to have an equation at the beginning of a paragraph. What if I was to ask “How can I begin addmargin with a displayed equation?”? Should I modify this question, or rather ask a new question and abandon this one? – matj1 Jan 04 '23 at 21:51
  • Linguistically, most equations need some sort of introduction to say what the equation is about. Typographically, if you start a paragraph with an equation, there's nothing to indent, and no way for the reader to know that a new paragraph started. I think you should ask a new question, since that would be sufficiently different from this one. You can link back to this one if you wish. – Teepeemm Jan 04 '23 at 22:02
  • @Teepeemm I know what you mean, but I think that the justification limits the introduction to being in the same paragraph and paragraph separation to first-line indentation. Apart from addmargin, my case is that I have a paragraphs introducing the following equations; then I have several sets of equations where the equations are closely related in the sets, but not so much across the sets. Each set is in its own align* to be structurally separated from others. I separate paragraphs by spaces, so indentation is not my problem. – matj1 Jan 04 '23 at 22:24
  • TeX is for writing various texts, not just books printed by important publishers. That someone makes a cheat sheet with just headings and formulas is a valid use case, but I think that no important publisher would print that. That someone shows an example of usually bad typography is a valid use case. That someone starts a story by showing a mysterious formula is something that may actually be published, but I don't know any specific case of this. – matj1 May 03 '23 at 15:53

1 Answers1

2

What you see is not vertical space, it is a 1-line paragraph with no visible text, note the placement is identical if you do have text there.

enter image description here

\documentclass{minimal}
\usepackage[paperwidth=5cm, paperheight=5cm]{geometry}
\usepackage{amsmath}

\begin{document}

paragraph

\begin{equation} a = b \end{equation}

paragraph

\clearpage

paragraph

some text \begin{equation} a = b \end{equation}

paragraph

\end{document}

As a paragraph line it does not stretch or shrink like the real display vertical skips and if a page break happens at that point it is not discarded so you can get a blank line at the top of a page.

This is a primitive feature of display math inherited from $$ not something programmed in amsmath.

Basically never have a blank line before a math display and never follow math display by another one. Use a multiline display such as gather not adjacent equation environments.

David Carlisle
  • 757,742