1

In an overleaf document using \documentclass[a4paper,15pt]{scrartcl}, I wrote some text and thereafter, I wrote something like $$ c^2=a^2+(-b)^2=a^2+b^2 $$ (Not this equation, please see the attached code below) followed by a new paragraph. But, the problem is that the equation seems to be sandwiched between the two texts. Here's the code :

...where $\mathbf{R_2}\vec{x}=\vec{0}$ as $\mathbf{R_2}$ is a zero matrix. So, now we have

$$\bnorm{\mathbf{R}\vec{x}-\mathbf{Q}'\vec{b}}^2~=~\bnorm{\mathbf{R_1}\vec{x}-\mathbf{c_1}}^2~+~\bnorm{-\mathbf{c_2}}^2~=~\bnorm{\mathbf{R_1}\vec{x}-\mathbf{c_1}}^2~+~\bnorm{\mathbf{c_2}}^2$$

Now, if $\mathbf{A}$ is of full column rank, then its QR decomposition is unique, hence $\mathbf{Q}$ and $\mathbf{R}$ (And thus, $\mathbf{R_1}$ are fixed.

But, in some previous portions of the document, I've written things like below and in this case, the spacing seem perfectly fine to me. See below :

...The proof is following : $$\norm{\mathbf{G}\vec{x}}~=\sqrt{\left(\mathbf{G}\vec{x}\right)'\cdot\mathbf{G}\vec{x}}~=\sqrt{\vec{x}'\big(\mathbf{G}'\mathbf{G}\big)\vec{x}}=\sqrt{\vec{x}'\vec{x}}~=\norm{\vec{x}}$$

$\bullet~~\textbf{\colorbox{magicmint}{Fact \#3} :}~$ If the matrix $A$ is of full column rank, then it has a unique QR Decomposition.

Here, previously I've written

\newcommand\norm[1]{\left\lVert#1\right\rVert}
\newcommand\bnorm[1]{\big\lVert#1\big\rVert}

I tried using \begin{equation*}, but it's producing the same output. :(

Can anyone please help ? Thanks in advance. :)

6
  • 3
    Don't use $$ for display math, see tex.stackexchange.com/questions/503/why-is-preferable-to. Beside this: if you want help you will have to show a small complete example. Screenshots are not enough. May 28, 2020 at 14:48
  • 2
    it is impossible to tell without an example but note that the space around displays can stretch or shrink. If you are using a document class that uses \flushbottom this vertical space can change to ensure equal page lengths just as inter-word space changes on a line to maintain equal line lengths May 28, 2020 at 14:52
  • Ohk fine. Let me write some code snippets.
    – JRC
    May 28, 2020 at 14:57
  • 2
    code snippets are not "a small complete example". But don't use empty lines around display math. This math belongs to the paragraph. May 28, 2020 at 15:09
  • 2
    Your code contains an empty line, which generates a paragraph break, before the first instance of $$...$$ but not before the second. The iron rule of TeX and LaTeX says: never, ever, permit a paragraph break before starting a display-math group.
    – Mico
    May 28, 2020 at 15:23

1 Answer 1

3

You claim,

in both the cases, I've written the codes in the exact similar manner. But why are the vertical spacings different for the two cases?

In fact, there is a crucial difference between the ways you wrote the two instances of $$...$$: In the former there's a blank line right before $$...$$, whereas in the latter there's not.

Blank lines in TeX and LaTeX documents trigger a paragraph break. There is an Iron Rule in TeX and LaTeX: Never, ever place a paragraph break immediately before a displaymath entity -- be this $$...$$, \[...\], \begin{equation} ... \end{equation}, or what have you. Taking out the blank line immediately improves the spacing situation.

An MWE (minimum working example) that's based on your code fragment:

enter image description here

For the second case, I also removed all the ~ spacers.

\documentclass[a4paper,15pt]{scrartcl}
\usepackage{mathtools} % for '\DeclarePairedDelimiter' macro
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}
\subsubsection*{With the spurious blank line}

\dots where $\mathbf{R}_2\vec{x}=\vec{0}$ as 
$\mathbf{R}_2$ is a zero matrix. So, now we have

\[
\norm{\mathbf{R}\vec{x}-\mathbf{Q}'\vec{b}}^2~
=~\norm{\mathbf{R}_1\vec{x}-\mathbf{c}_1}^2~+~\norm{-\mathbf{c}_2}^2~
=~\norm{\mathbf{R}_1\vec{x}-\mathbf{c}_1}^2~+~\norm{\mathbf{c}_2}^2
\]

\subsubsection*{Without the spurious blank line}

\dots where $\mathbf{R}_2\vec{x}=\vec{0}$ as 
$\mathbf{R}_2$ is a zero matrix. So, now we have
\[
\norm{\mathbf{R}\vec{x}-\mathbf{Q}'\vec{b}}^2
=\norm{\mathbf{R}_1\vec{x}-\mathbf{c}_1}^2+\norm{-\mathbf{c}_2}^2
=\norm{\mathbf{R}_1\vec{x}-\mathbf{c}_1}^2+\norm{\mathbf{c}_2}^2
\]
\end{document}
1
  • Thank you. It really helped. :)
    – JRC
    May 28, 2020 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .