2

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 05 '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 05 '18 at 23:19
  • I would use both of these spacing options quite frequently. I don't want to change those parameters back and forth when I switch between them. –  Jan 05 '18 at 23:20
  • @Zarko I was under the impression that amsmath redefined the equation environment. I want to keep the same compatibility. But if this detail is immaterial, ignore I mentioned amsmath. –  Jan 05 '18 at 23:22
  • 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 05 '18 at 23:24
  • The "equations" for which I want reduced spacing really wouldn't qualify as proper equations. They are more like lists of numbers that don't belong in-line. Although they should be centered and they do symbolize math quantities, they shouldn't call attention to themselves as much as the more important results. –  Jan 05 '18 at 23:32
  • But in any event, would you deny me my agency to go to typographic hell? –  Jan 05 '18 at 23:33
  • but do you want both types to be numbered in the same sequence? – David Carlisle Jan 05 '18 at 23:34
  • @DavidCarlisle They may count independently of each other. –  Jan 05 '18 at 23:35
  • that makes quite a difference to the required definitions:-) – David Carlisle Jan 05 '18 at 23:36
  • @DavidCarlisle oh well... I didn't think would. In that case, I really didn't have any intention on numbering these "smaller" equations. I was planning on just mimicking the code and use it to craft a equation* environment. –  Jan 05 '18 at 23:38
  • 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 05 '18 at 23:41
  • @DavidCarlisle \abovedisplayshortskip is, by default, 0pt plus 3pt – egreg Jan 05 '18 at 23:42
  • @egreg details (to be filled in later:-) main point is that it's a fair bit simpler if you don't need tp mess with counters, probably would reset the displayskips rather than adding negative vspace in practice – David Carlisle Jan 05 '18 at 23:47
  • I don't think you need to shoot flies with cannons, that is, I think what you want to do can be done without redefining the equation environment either in plain LaTeX or within amsmath. I think the problem of spacing may be due to your way of composing your equations on the one hand, and on the other hand to lack of use of amsmath that besides equation, includes a lot of more environments to compose mathematics that surely you can adapt more easily to your needs. – Aradnix Jan 05 '18 at 23:52
  • 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 05 '18 at 23:53

1 Answers1

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

egreg
  • 1,121,712
  • 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. –  Jan 06 '18 at 00:14
  • Thanks. However your solution does not seem to work inside other amsmath environments, such as gather. Should I post a new question ? – dominique Oct 05 '22 at 20:04
  • @dominique Better do a new question. – egreg Oct 05 '22 at 21:49
  • https://tex.stackexchange.com/questions/660649/separate-numberings-in-two-equation-environments :-) – dominique Oct 05 '22 at 22:20