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
header-includes:
- \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?
The \vspace command adds vertical space. The length of the space can be expressed in any terms that LaTeX understands, i.e., points, inches, etc. You can add negative as well as positive space with an \vspace command. LaTeX removes vertical space that comes at the end of a page.
Just put \begin{center} when you want to start centering, and \end{center} when you want to stop centering. (If you want to center everything until the end of the document, you still need an \end{center} before the \end{document} at the end of the source file.
Any text in between \begin{flushleft}... \end{flushleft} will be aligned with the left-hand margin, but have a ragged right-hand edge. This is another case of a LaTeX environment. If you are already in an environment you can switch this style of alignment on in a different way using \raggedright .
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
header-includes:
- \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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With