4

I need every amsmath equation to place at the top of the page. So I use \noindent to do that. Everything is fine except equation+split environment. Than formula is placed a bit higher (by \vskip-\lineskiplimit (it's -3pt) from asmmath.sty \@display@init macro). align+split is ok. The glue is discardable item but it's in a box so it's not discarded.

....\glue(\topskip) 0.0
....\hbox(21.00012+16.0001)x430.00462, direction TLT
.....\vbox(21.00012+16.0001)x430.00462, direction TLT
......\glue -3.0
......\glue 0.0

MWE:

\documentclass{article}
\usepackage[showframe,paperwidth=10cm,paperheight=5cm]{geometry}
\usepackage{amsmath}

\begin{document}

\noindent
\[
\begin{split}
\left(a^{B^{B^{B}}}\right)
\\
bb
\end{split}
\]

\clearpage
\noindent
\begin{align}
\begin{split}
\left(a^{B^{B^{B}}}\right)
\\
bb
\end{split}
\end{align}

\end{document}

Result: enter image description here

Questions:

  1. Is there a way to test am I on the top of page? Then I could fix that \vskip. I tried leaders but its very tricky.
  2. Is there an other way to place formulas forcing \topskip?
  • I'm not sure what \noindent has to do with this... Do I miss something? – yo' Sep 17 '15 at 6:43
  • @yo' it stops the white paragraph line being formed before the display (but not if it is followed by \par as in the second example. – David Carlisle Sep 17 '15 at 6:47
  • it's generally considered bad form to start a page with a display. amsmath was built around the assumption that (at least one) line of text would precede a display. but, as the answer by david shows, the problem here is actually in the input. – barbara beeton Sep 17 '15 at 13:43
5

The problem is

\noindent

\begin{align}

you have a paragraph break there. Remove the blank line. The space at the top of the page is not dropped as it is not vertical space it is a one line blank paragraph.

With blank line before equation:

enter image description here

Without blank line:

enter image description here

With the corrected version and the addition of

\showoutput
\showboxdepth5

The log (using lualatex as you did) shows

....\glue(\topskip) 0.0
....\hbox(22.50012+17.5001)x199.16841, direction TLT
.....\glue(\tabskip) 80.22015
.....\hbox(22.50012+17.5001)x0.0, direction TLT []

Showing there is nothing on the page before the alignment.

  • David, with align I have no problem. Yes, that's my mistake that blank line in example. Actually I use \appto\mathdisplay@push{\parshape=\z@\par\noindent} I fixed example. – Linuxss Sep 17 '15 at 6:57
  • @Linuxss I can only answer as here. The \showoutput log you show does not seem to be from your example (before or after the rogue par is corrected) I get nothing between \topskip and the alignment box itself I will add the log to my question in a second. – David Carlisle Sep 17 '15 at 8:48
0

Is it safe to use leaders to test am I on the top of page? What do experts think? Previously I tried check \pagegoal, \maxdimen and \pagetotal, but it worked not 100%.

\documentclass{article}
\usepackage[showframe,paperwidth=10cm,paperheight=5cm]{geometry}
\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
%% leaders should be discarded at top of new page
\newif\if@top@of@page\@top@of@pagefalse
  \def\check@top@of{%
    \ifmmode
    \else
      \@top@of@pagetrue
      \ifvmode
        \cleaders\vbox to \z@{\@top@of@pagefalse}\vskip\z@
      \else
        \cleaders\vbox to \z@{\@top@of@pagefalse}\hskip\z@
      \fi
    \fi
    }
%% Passing check to equations
\preto\equation{\check@top@of}
\expandafter\preto\csname equation*\endcsname{\check@top@of}

\def\@display@init#1{%
    \global\dt@ptrue \spread@equation
    \everycr{%
        \noalign{%
            #1%
            \ifdt@p
                \global\dt@pfalse
                %% No negative skip if equation is on a top of the page
                \if@top@of@page
                \else
                  \vskip-\lineskiplimit
                  \vskip\normallineskiplimit
                \fi
            \else
                \penalty\@eqpen \global\dspbrk@lvl\m@ne
            \fi
        }%
    }%
  }
%% don't add \topskip for equation 
\appto\mathdisplay@push{\noindent}
\makeatother


\begin{document}
\[
\begin{split}
\left(a^{B^{B^{B}}}\right)
\\
bb
\end{split}
\]

\clearpage
\noindent
\begin{align}
\begin{split}
\left(a^{B^{B^{B}}}\right)
\\
bb
\end{split}
\end{align}

\end{document}

I've fixed my problem with this code so I wrote it as an answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.