llewmills - 8 months ago 60
LaTeX Question

Decrease vertical space between align environment and text content in RMarkdown

I am writing rmarkdown pdf documents with equations (using mac, knitr, pdf-latex). The problem I have is that rmarkdown is automatically creating a large blank gap of 2-3 lines between the preceding text and the equation. How do I get rid of this gap?

Sample rmarkdown doc below.

---
title: "No More Gaps"
author: "Llew Mills"
date: "16th of September 2016"
output: pdf_document
- \setlength{\mathindent}{0pt}
linestretch: 1.3
toc: yes
classoption: fleqn
---

Some text to illustrate the gap. I still want there to be a decent line spacing between lines of text, but I would like a much smaller gap between the equations and the preceding text.
\begingroup\Large
\begin{align*}
Y_{ij} &= \pi_{0i} + \pi_{1i}TIME_{ij} + \pi_{2i}(0) + \varepsilon_{ij}\\
&= \pi_{0i} + \pi_{1i}TIME_{ij} + \varepsilon_{ij}
\end{align*}
\endgroup

Can anyone help with this problem?


There are two options here. The first is just to use \vspace as I pointed out in my comment. The second one is to use \abovedisplayskip. For details on how this (and the sibling commands) works, I can refer you to Remove vertical space around align.

---
title: "Spacing"
output: pdf_document
- \usepackage{amsmath}
- \usepackage{lipsum}
---
\setlength{\abovedisplayskip}{-15pt}
\setlength{\belowdisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}
\lipsum*[3]
\begin{align*}
A\cap B & = \{b,d,e\} \cap \{a,b,f,g\} \\
& = \{b\}
\end{align*}
\lipsum[3]