astrofunkswag
astrofunkswag

Reputation: 2698

Rmarkdown failed to compile pdf - missing package for LaTex "\limits"

My rmarkdown is failing to compile, and the source of the error is the LaTex command \limits. I used the tinytex package to install LaTex packages. I've tried to track down the right LaTex package with no success.

The following output was generated via html.

## Compiles

$$\hat{\beta_1} = \frac{\sum_{i = 1}^{n}(X_1 - \bar{X})(Y_i - \bar{Y})}{\sum_{i = 1}^{n}(X_1 - \bar{X})^2}$$

## Fails to Compile

$$\hat{\beta_1} = \frac{\sum_\limits{i = 1}^{n}(X_1 - \bar{X})(Y_i - \bar{Y})}{\sum_\limits{i = 1}^{n}(X_1 - \bar{X})^2}$$

enter image description here

When I try to knit to pdf I get the following error:

enter image description here

Upvotes: 0

Views: 164

Answers (2)

neuroandstats
neuroandstats

Reputation: 124

$$\hat{\beta_1} = \frac{\sum\limits_{i = 1}^n (X_1 - \bar{X})(Y_i - \bar{Y})}{\sum\limits_{i = 1}^n (X_1 - \bar{X})^2}$$

Upvotes: 1

Your syntax is wrong. It is not \sum_\limits{}^{} but \sum\limits_{}^{}

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
\hat{\beta_1} = \frac{\sum\limits_{i = 1}^{n}(X_1 - \bar{X})(Y_i - \bar{Y})}{\sum\limits_{i = 1}^{n}(X_1 - \bar{X})^2}
\]

\end{document}

Upvotes: 1

Related Questions