3

The following MCE points out an extra vertical space before display equations in case of fleqn option given at \documentclass level.

Do you know what's going on?

% Workflow if this file is named `test.tex`:
% pdflatex test
% pdflatex without-fleqn
% pdflatex with-fleqn
% 
\begin{filecontents*}{without-fleqn.tex}
\documentclass{article}
\input{maths}
\end{filecontents*}

\begin{filecontents*}{with-fleqn.tex}
\documentclass[fleqn]{article}
\input{maths}
\end{filecontents*}

\documentclass{article}
\usepackage{filecontents}
%
\begin{filecontents*}{maths.tex}
\usepackage[papersize={15cm,3cm}]{geometry}
\usepackage[step=1cm]{pagegrid}
\usepackage{amsmath}
\begin{document}
Foo :
\[
y=Ce^{-\int a(x)dx}\int b(x)e^{\int a(x)dx}dx
\]
\end{document}
\end{filecontents*}
%
\begin{document}
\end{document}

enter image description here

Denis Bitouzé
  • 9,652
  • 4
  • 27
  • 85
  • 2
    i think this question/answer is relevant: https://tex.stackexchange.com/a/235111/579 . unfortunately, the actual reason is not obvious. – barbara beeton Mar 28 '18 at 18:28
  • @barbarabeeton isn't a design choice (even without amsmath)? – touhami Mar 28 '18 at 19:09
  • 1
    @barbarabeeton Indeed, in the sense that using gather environment instead of \[...\] (or equationenvironment) does the trick, but still strange. I guess this is a bug (maybe the same as in this question/answer). Should it be reported? – Denis Bitouzé Mar 28 '18 at 19:17
  • 1
    @DenisBitouzé -- when i first read your question, i thought the extra space might be there to accommodate a (nonexistent in this case) equation number, but looking further, i found the existing report with a link to the question i already cited. i've added this report to that record. but, as before, i can't say when it might get addressed. sigh. – barbara beeton Mar 28 '18 at 19:42
  • @DenisBitouzé did you try without amsmath? – touhami Mar 28 '18 at 20:17
  • @touhami Yes: same result. Not on your system? – Denis Bitouzé Mar 28 '18 at 20:22
  • @DenisBitouzé what i mean is that this may not be related to amsmath. \[ and \] are redefined in flqn.clo and so do amsmath.sty. – touhami Mar 28 '18 at 20:26
  • @touhami Indeed. That's the reason I didn't explicitly incriminate amsmath ;) But at least it could fix the problem :) – Denis Bitouzé Mar 28 '18 at 20:29
  • @touhami it's mostly necessitated by the flush left alignment so would be the same in any implementation. – David Carlisle Mar 28 '18 at 20:37
  • @DenisBitouzé it may be an old choice – touhami Mar 28 '18 at 20:40
  • @DavidCarlisle that's what i mean by a design choice. – touhami Mar 28 '18 at 20:52

1 Answers1

3

enter image description here

enter image description here

fleqn doesn't (and can't really) use the \abovedisplayshortskip length, if you set this to \abovedisplayskip you get the same space in both cases.

\documentclass
%[fleqn]
{article}
\usepackage[papersize={15cm,3cm}]{geometry}
\usepackage[step=1cm]{pagegrid}
\usepackage{amsmath}

\begin{document}
\abovedisplayshortskip=\abovedisplayskip
Foo :
\[
y=Ce^{-\int a(x)dx}\int b(x)e^{\int a(x)dx}dx
\]
\end{document}
David Carlisle
  • 757,742
  • Nice! But why fleqn can't really use the \abovedisplayshortskip length? – Denis Bitouzé Mar 28 '18 at 20:10
  • 2
    @DenisBitouzé as your image shows, the short version is used when the equation is small and the last line of the paragraph is short so you can use a smaller vertical space as the last line above "fits" in the space to the left of the equation. fleqn equations never have that space. – David Carlisle Mar 28 '18 at 20:14