Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the lecture note, on I am working, we use lots of equations. To set them I use often the gather environment of the amsmath package. But how it standard looks, I don't really like. First of all, I have no influence to make the vertical space (before or after the equation) greater or less. That's why I made a little change on the gather environment and named it Gather
I show how it works:

\makeatletter
\newlength{\mathe}
\mathe3pt
\newlength{\mathvariable}
\mathvariable3pt
\newlength{\foren}
\newcommand{\en}{\\[\foren]}        
\newcommand{\stretchtheequations}{0}

\newenvironment{Gather}[1][\stretchtheequations]{%
\setlength{\mathe}{#1\mathvariable}%
\setlength{\foren}{10.75pt+1.5\mathe}
\vskip-\parskip%
\vskip-\baselineskip%
\vskip\mathe% -24pt
  \start@gather\st@rredfalse%
}{%
  \math@cr \black@\totwidth@ \egroup%
  $$\ignorespacesafterend%
  \vskip-\parskip%
  \vskip\mathe% -24pt
}
\makeatother

It based on standard gather environment from the amsmath package.
It would be added the setlength and vskip commands, the rest is from the original.

The following minimal example helps me explaining what I want to do:

\documentclass[11pt]{memoir}
\parskip10pt

\usepackage[fleqn]{amsmath}
\usepackage{blindtext}
\usepackage{calc}
\usepackage{multicol}  
% include here the code above

\begin{document}

\blindtext\ -- equation is compressed
    \begin{Gather}[-2.5]
        a+b+c+d   \en
        a+b+c+d   \en
        a+b+c+d   
    \end{Gather}
\blindtext\ -- equation is stretched
    \begin{Gather}[3]
        a+b+c+d   \en
        a+b+c+d   \en
        a+b+c+d   
    \end{Gather}
\blindtext

\clearpage
Look, how it looks, with columnbreak inside the multicols environment:

\begin{multicols}{2}
    \blindtext
    \columnbreak
    \begin{gather}
        a+b+c+d
    \end{gather}
    \blindtext
    \\\bfseries The gather environment begins at the same height as the text at left side. That's exactly what I want with my new Gather environment.
\end{multicols}

\clearpage
Look, how it looks, with columnbreak inside the multicols environment:

\begin{multicols}{2}
    \blindtext
    \columnbreak
    \begin{Gather}
        a+b+c+d
    \end{Gather}
    \blindtext
    \\\bfseries The Gather environment begins NOT at the same height as the text at left side.
\end{multicols}

\cleartoverso
\blindtext

\clearpage
    \begin{Gather}
        a+b+c+d
    \end{Gather}
\blindtext
\end{document}

On the first page, you can see, how stretching works.
Page 3 shows that if I take the gather environment inside multicols, the first line of the equation begins exactly at the same height as the text at left side.
On page 4 you can see, that with Gather it is not the case.
It is the same, if I use the Gather environment after \clearpage(see pages 6 and 7).

And now the question

I would like to create an environment which works exactly like Gather now, with the exception, that there won't be added any vertical space before the equation if it is used immediately after commands \clearpage, \pagebreak, \newpage.
So the behaviour is the same like gather on page 3 inside the multicols environment and after \columnbreak.

share|improve this question
add comment

1 Answer

I don't quite understand the setting of the length, but here's something that can help you:

\makeatletter
\newenvironment{Gather}[1][0]
  {\abovedisplayskip=2pt \belowdisplayskip=\abovedisplayskip
   \setlength{\mathe}{#1\mathvariable}%
   \setlength{\foren}{10.75pt+1.5\mathe}%
   \start@gather\st@rredfalse}
  {\math@cr \black@\totwidth@ \egroup
   $$\ignorespacesafterend}
\makeatother

You can act on \abovedisplayskip and \belowdisplayskip to set the distance from the text to the Gather environment's contents. This way no \parskip glue will be inserted.

share|improve this answer
    
I find this answer usefull, because I've learnt, how abovedisplayskip and belowdisplayskip works. I hope, I can use this learning in the future. But this solution doesn't handle the problem with the \clearpage command. What I wanted, is a solution, that causes no vertcial skip (no abovedisplayskip) above the math environment, if it begins a new page. Even, if I set abovedisplayskip to zero, there will be a vertical space with the length of \baselineskip. –  Daniel Jun 5 '12 at 21:09
    
@Daniel Yes, of course: \clearpage ends the current paragraph and Gather starts another one. Indeed \columnbreak uses a different strategy that you can find useful: in order to break a page before a Gather environment say \vadjust{\eject}. –  egreg Jun 5 '12 at 21:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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