2

I am working on the following code with some latex (making a reproducible report document in R notebook, but for some reason my table is put above my text and equation. How do I fix this? enter image description here

title: "Empirical Research in Finance"
subtitle: "**Hypothesis tests and simulation**" 
author: Faes E.
fontsize: 12pt
date: '*January 25, 2021*'
output: 
    pdf_document: default
    html_document:
    df_print: paged
header-includes:
  - \usepackage{amsmath} \usepackage{color}
  - \usepackage{titling}
  - \pretitle{\begin{center}
    \includegraphics[width=4in,height=4in]{AMSLOGO.jpg}\LARGE\\}
  - \posttitle{\end{center}}
\thispagestyle{empty}
# copy the R logo to the current directory
file.copy(file.path(R.home("doc"), "html", "AMSLOGO.jpg"), '.')
\newpage

\newpage

An examination of the first and second moments of the sample skewness is been done in table 1. There can be seen that the mean goes to zero for larger samples. For the variance, the asymptotic variance is being reached. We know that it should render the following values (equation 2) as we know that skewness is asympotitcally distributed with mean 0 and variance 6/n (where n is in this case the sample size).

\begin{equation} 
\tag{2} 
skewness \stackrel{a}{\sim}N(0,\dfrac{6}{n})
\end{equation}

```{r echo=FALSE}
kable(des(mom=S), digits= 3, caption = "Statistics for skewness") %>%
    kable_classic(full_width = F) %>%
     footnote(number = c("n is the sample size","std is the standard deviation"))
```
Enjo Faes
  • 35
  • 8
  • That's where LaTeX is putting it. Where do you want it? See https://www.texfaq.org/FAQ-floats for a discussion of what's possible. One `kable`-specific thing: if you don't add a caption, your table won't be a float at all. – user2554330 Jan 16 '21 at 17:49
  • @user2554330 it should be under my equation from LaTeX. But for some reason (if you click the image) it is above my text. – Enjo Faes Jan 16 '21 at 19:17
  • Skip the caption. – user2554330 Jan 16 '21 at 19:20
  • @user2554330 exactly, works then. But now my table title is gone.. What do you recommend – Enjo Faes Jan 16 '21 at 20:00
  • 3
    You can use `kable(..., format = "latex", position = "h!")` to give a very strong suggestion to leave it in place. If LaTeX thinks that's a bad idea, it still won't do it. – user2554330 Jan 16 '21 at 20:21
  • This did it for, me thank you! – Enjo Faes Jan 16 '21 at 21:41

1 Answers1

1

Like user2554330 answered correctly and worked for me:

You can use kable(..., format = "latex", position = "h!") to give a very strong suggestion to leave it in place. If LaTeX thinks that's a bad idea, it still won't do it.

Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51
Enjo Faes
  • 35
  • 8