2

The result of the following code is strange: vertical space before align environment is smaller than displayed math. What is the problem with align environment?

Edit: I want the same vertical space before and after align environments, just like other displayed formulas.

\documentclass{article}

\usepackage[14pt]{extsizes}
\usepackage{amsmath}

\setlength{\lineskiplimit}{4pt}
\setlength{\lineskip}{4pt plus 1pt minus 1pt}

\AtBeginDocument{%
  \setlength{\baselineskip}{19pt plus 1pt minus 1pt}%
}

\begin{document}

\setlength{\fboxsep}{0pt}

\noindent
\fbox{\makebox[\textwidth]{lazy dog}}
\begin{align*}
  \boxed{f(x) = \sin x + 1}
\end{align*}
\fbox{\makebox[\textwidth]{lazy dog}}
$$\boxed{f(x) = \sin x + 1}$$
\fbox{\makebox[\textwidth]{lazy dog}}
\[\boxed{f(x) = \sin x + 1}\]
\fbox{\makebox[\textwidth]{lazy dog}}

\end{document}

enter image description here

Z.H.
  • 3,346
  • 21
  • 39
  • 1
    There isn't is a problem here, per se. \begin{align}...\end{align} do some things different than does \[...\] (see Why is \[ ... \] preferable to $$ ... $$?). What are you after? Should they be the same? If so, which one do you prefer? – Werner Nov 29 '18 at 01:52
  • 1
    align is intended to be used for multi-line, not single line, displays. – barbara beeton Nov 29 '18 at 02:31
  • @Werner I want the same vertical space before and after align environments, just like other displayed formulas. – Z.H. Nov 29 '18 at 05:31
  • @Z.H.: Then you should not adjust \lineskiplimit. – Werner Nov 29 '18 at 05:36
  • @Werner I have updated my MWE, and there is no difference between \[...\] and $$...$$ in my case. The problem is the inconsistent spaces before and after the align formula. – Z.H. Nov 29 '18 at 05:37
  • @Werner I need \lineskiplimit in my real usage. Why does it only affect align environments? I don't think I am using \lineskiplimint in a wrong way. – Z.H. Nov 29 '18 at 05:41
  • @barbarabeeton It is a MWE. The problem also exists in multi-line align formulas. – Z.H. Nov 29 '18 at 05:44
  • @Z.H.: It's because align uses \lineskiplimit and \[...\] doesn't. Check \@display@init in amsmath.dtx. – Werner Nov 29 '18 at 05:45
  • @Werner Could it be interpreted as align uses \lineskiplimit in a buggy way? – Z.H. Nov 29 '18 at 05:49
  • @Z.H. not really. whenever \lineskip is used you get inconsistent spacing, as that is what it is for, a fallback for when consistent \baselineskip can not be ensured. By increasing \lineskiplimit you make that more likely. – David Carlisle Nov 29 '18 at 07:54
  • @DavidCarlisle I still could not understand why align environment needs to use \lineskiplimit. Are there any special reasons for it? – Z.H. Nov 29 '18 at 09:28
  • there are some comments in the code, ... % \begin{macro}{\strut@} % \begin{macro}{\strutbox@} % Next follows a special internal strut which is supposed to match % the height and the depth of a normal |\strut| minus % |\normallineskiplimit| according to M. Spivak. – David Carlisle Nov 29 '18 at 09:47
  • 1
    you may want to adjust \normallineskiplimit but having such a large value for \lineskiplimit seems very odd – David Carlisle Nov 29 '18 at 09:48

1 Answers1

3

According to @DavidCarlisle's comment, the problem could be fixed with

\normallineskiplimit=\lineskiplimit

enter image description here

Z.H.
  • 3,346
  • 21
  • 39
  • it have been nice if ask David first, if he would extend his comment to the answer ... – Zarko Dec 07 '18 at 12:08
  • @Zarko I have waited for the answer for one week. Apparently he is not interested in answering this question. – Z.H. Dec 07 '18 at 12:15