6
\documentclass[12pt,oneside]{article}
\usepackage{libertine}
\usepackage{amsthm}
\usepackage[libertine]{newtxmath}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{commath}
\usepackage{bm}
\usepackage{xpatch}

\xapptocmd\normalsize{%
 \abovedisplayskip=12pt plus 3pt minus 9pt
 \abovedisplayshortskip=0pt plus 3pt
 \belowdisplayskip=3ex plus 3pt minus 9pt
 \belowdisplayshortskip=5ex plus 3pt minus 4pt
}{}{}

\newtheoremstyle{definitionstyle}  % <name>
        {3ex}                   % <space above>
        {2ex}                   % <space below>
        {\normalfont}           % <body font>
        {}                      % <indent amount}
        {\bfseries}             % <theorem head font>
        {\normalfont\bfseries:} % <punctuation after theorem head>
        {.5em}                  % <space after theorem head>
        {}                      % <theorem head spec (can be left empty, meaning "normal")>
\theoremstyle{definitionstyle}

\newtheorem{definition}{Definition}[section] % Comment out [section] to remove section number dependence

\begin{document}

\begin{definition}
\textit{Displacement} is a vector measure (it has both magnitude and direction) of the interval between two locations measured along the shortest path connecting them.
\textit{Distance,} or distance traveled, is a scalar measure (an absolute value) of the interval between two locations measured along the actual path connecting them.
\end{definition}

\begin{definition}
\textit{Instant velocity,} or velocity, of an object is the rate of change of its displacement \textit{with respect to} time:
\end{definition}
\begin{equation}
\bm{v} = \lim_{\Delta t \to 0} \frac{\bm{r}(t+\Delta t) - \bm{r}(t)}{\Delta t}=\lim_{\Delta t \to 0}\frac{\Delta \bm{r}}{\Delta t}=\frac{\dif\bm{r}}{\dif t}=\dot{\bm{r}}
\end{equation}

\textit{Instant speed,} or speed, is the rate of change of distance with respect to time:
\[\envert{\bm{v}} = v = \lim_{\Delta t \to 0} \frac{\Delta s}{\Delta t} = \frac{\dif s}{\dif t} = \dot{s}\]

\begin{definition}
\textit{Instant acceleration,} or acceleration, is the rate of change of velocity with respect to time:
\end{definition}

\end{document}

Despite similar questions, I still do not fully understand how these spacing work as a whole (when combined). The above code produces: enter image description here

With respect to the spacing values in definitionstyle and math related spacing (abovedisplayskip, etc.), exactly how does LaTeX engine make the calculations? Thus, say, if I want all the vertical spacing (colored boxes) in the image be equal, how do I make the calculations to achieve the desired effect?

  • 1
    The error is having equation outside of definition: it should be inside it. – egreg Apr 27 '17 at 17:03
  • @egreg Thank you for pointing that out. With due respect, how does that help with the main point of my question? (For example, in the above output there are (almost) five different vertical spacing issue.) – blackened Apr 27 '17 at 17:07
  • See my answer: the space around the equations is the same; the space between the two definitions is how you set it. It's not clear why using different units for the purpose (ex and pt). – egreg Apr 27 '17 at 17:09
7

Rubber lengths have nothing to do with this, as the page is neither stretched nor shrinked.

Let's try placing the equation environment inside definition, where it belongs.

\documentclass[12pt,oneside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{commath} % don't use it, it's full of bugs
\usepackage{bm}
\usepackage{xpatch}

\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\xapptocmd\normalsize{%
 \abovedisplayskip=12pt plus 3pt minus 9pt
 \abovedisplayshortskip=0pt plus 3pt
 \belowdisplayskip=3ex plus 3pt minus 9pt
 \belowdisplayshortskip=5ex plus 3pt minus 4pt
}{}{}

\newtheoremstyle{definitionstyle}  % <name>
        {3ex}                   % <space above>
        {2ex}                   % <space below>
        {\normalfont}           % <body font>
        {}                      % <indent amount}
        {\bfseries}             % <theorem head font>
        {\normalfont\bfseries:} % <punctuation after theorem head>
        {.5em}                  % <space after theorem head>
        {}                      % <theorem head spec (can be left empty, meaning "normal")>
\theoremstyle{definitionstyle}

\newtheorem{definition}{Definition}[section] % Comment out [section] to remove section number dependence

\begin{document}

\begin{definition}
\textit{Displacement} is a vector measure (it has both magnitude and direction) of the interval between two locations measured along the shortest path connecting them.
\textit{Distance,} or distance traveled, is a scalar measure (an absolute value) of the interval between two locations measured along the actual path connecting them.
\end{definition}

\begin{definition}
\textit{Instant velocity,} or velocity, of an object is the rate of change of its displacement \textit{with respect to} time:
\begin{equation}
\bm{v} = \lim_{\Delta t \to 0} \frac{\bm{r}(t+\Delta t) - \bm{r}(t)}{\Delta t}=\lim_{\Delta t \to 0}\frac{\Delta \bm{r}}{\Delta t}=\frac{\dif\bm{r}}{\dif t}=\dot{\bm{r}}
\end{equation}
\end{definition}

\textit{Instant speed,} or speed, is the rate of change of distance with respect to time:
\[\envert{\bm{v}} = v = \lim_{\Delta t \to 0} \frac{\Delta s}{\Delta t} = \frac{\dif s}{\dif t} = \dot{s}\]

\begin{definition}
\textit{Instant acceleration,} or acceleration, is the rate of change of velocity with respect to time:
\end{definition}

\end{document}

enter image description here

If I also change the various spacings you set, like below

\documentclass[12pt,oneside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{bm}
\usepackage{xpatch}

\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\xapptocmd\normalsize{%
 \abovedisplayskip=12pt plus 3pt minus 9pt
 \abovedisplayshortskip=0pt plus 3pt
 \belowdisplayskip=12pt plus 3pt minus 9pt
 \belowdisplayshortskip=12pt plus 3pt minus 4pt
}{}{}

\newcommand{\dif}{\mathop{}\!\mathrm{d}}

\newtheoremstyle{definitionstyle}  % <name>
        {12pt}                  % <space above>
        {12pt}                  % <space below>
        {\normalfont}           % <body font>
        {}                      % <indent amount}
        {\bfseries}             % <theorem head font>
        {\normalfont\bfseries:} % <punctuation after theorem head>
        {.5em}                  % <space after theorem head>
        {}                      % <theorem head spec (can be left empty, meaning "normal")>
\theoremstyle{definitionstyle}

\newtheorem{definition}{Definition}[section] % Comment out [section] to remove section number dependence

\begin{document}

\begin{definition}
\textit{Displacement} is a vector measure (it has both magnitude and direction) 
of the interval between two locations measured along the shortest path connecting them.
\textit{Distance,} or distance traveled, is a scalar measure (an absolute value) 
of the interval between two locations measured along the actual path connecting them.
\end{definition}

\begin{definition}
\textit{Instant velocity,} or velocity, of an object is the rate of change of its 
displacement \textit{with respect to} time:
\begin{equation}
\bm{v} = \lim_{\Delta t \to 0} \frac{\bm{r}(t+\Delta t) - 
\bm{r}(t)}{\Delta t}=\lim_{\Delta t \to 0}\frac{\Delta \bm{r}}{\Delta t}=
\frac{\dif\bm{r}}{\dif t}=\dot{\bm{r}}
\end{equation}
\end{definition}

\textit{Instant speed,} or speed, is the rate of change of distance with respect to time:
\[
\lvert\bm{v}\rvert = v = \lim_{\Delta t \to 0} \frac{\Delta s}{\Delta t} = 
\frac{\dif s}{\dif t} = \dot{s}
\]

\begin{definition}
\textit{Instant acceleration,} or acceleration, is the rate of change of velocity 
with respect to time:
\end{definition}

\end{document}

I get

enter image description here

  • Thank you. Just to play the devil, and perhaps improve my understanding: Is it a silly exercise to try to achieve equal spacing in the MWE without your adjustment? (My point is, could there be a time where the above MWE semantically correct, thus my original question becomes valid?) – blackened Apr 27 '17 at 17:13
  • 2
    @blackened No. A math display must never start a paragraph. – egreg Apr 27 '17 at 17:28

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.