1

I would like to create a new environment which acts exactly the same as the equation environment from amsmath; however, I want this new environment to have less spacing above and below the environment. I do not want to overwrite or alter the extant equation environment. I want both environments.

How would I go about doing this? I've always been an end-user of packages, so creating something like this is outside my experience.

  • 1
    equation is standard latex environment. – Zarko Jan 5 '18 at 23:18
  • 1
    I’m curious: Why do you think it’s necessary to “clone” the math environments of the amsmath package — of which there are quite a few — in order to achieve your stated objective? (The amsmath package modifies the behavior of the equation environment.) Why not just change the values of the length parameters \abovedisplayskip and \belowdisplayskip? – Mico Jan 5 '18 at 23:19
  • 2
    Using two different sets of spacing settings for displayed equations is pretty much an invitation to typographic hell (or, at the very least, purgatory). Why inflict it on your poor readers? – Mico Jan 5 '18 at 23:24
  • 1
    that's what I suspected, but if that is the intention you can skip all the effort to set up a new counter and make the clone not be a clone but use the new counter, basically you just need a definition that resolves to \vspace{-2pt}\[...\]\vspace{-2pt} if you want 2pt less than a normal display math – David Carlisle Jan 5 '18 at 23:41
  • 1
    You don't need to create a typographical hell or add inconsistencies to your document, why don't you add an MWE to your question to better understand your problem and what solution can be given? – Aradnix Jan 5 '18 at 23:53
5

Without going into the details for the independent numbering, you can set differently the parameters for the spacing.

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}

\newenvironment{equation-}
 {%
  \abovedisplayshortskip=0pt plus 1pt
  \abovedisplayskip=2pt plus 1pt minus 1pt
  \belowdisplayshortskip=\abovedisplayskip
  \belowdisplayskip=\abovedisplayskip
  \begin{equation}%
 }
 {\end{equation}\ignorespacesafterend}

\begin{document}

\lipsum*[2]
\begin{equation-}
1\quad 2\quad 3
\end{equation-}
Short short short short short short short short short short short short
short short
\begin{equation-}
1\quad 2\quad 3
\end{equation-}
\lipsum*[2]
\begin{equation}
1\quad 2\quad 3
\end{equation}
\lipsum[2]

\end{document}

enter image description here

I'm not sure you really want it.

For the independent numbering:

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}

\newcounter{savedequation}
\newcounter{shortequation}

\newenvironment{equation-}
 {%
  \setcounter{savedequation}{\value{equation}}%
  \setcounter{equation}{\value{shortequation}}%
  \renewcommand\theequation{S\arabic{equation}}%
  \abovedisplayshortskip=0pt plus 1pt
  \abovedisplayskip=2pt plus 1pt minus 1pt
  \belowdisplayshortskip=\abovedisplayskip
  \belowdisplayskip=\abovedisplayskip
  \begin{equation}%
 }
 {%
  \end{equation}%
  \setcounter{shortequation}{\value{equation}}%
  \setcounter{equation}{\value{savedequation}}%
  \ignorespacesafterend
 }

\begin{document}

\lipsum*[2]
\begin{equation}
a=b
\end{equation}
\lipsum*[2]
\begin{equation-}
1\quad 2\quad 3
\end{equation-}
Short short short short short short short short short short short short
short short
\begin{equation-}
1\quad 2\quad 3
\end{equation-}
\lipsum*[2]
\begin{equation}
c=d
\end{equation}
\lipsum[2]

\end{document}

enter image description here

  • I'm fiddling with it, and it has mixed results. You're right. I'm not sure if I do want it. But thank you anyway, Virgil. – Robert Wolfe Jan 6 '18 at 0:14

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.