! LaTeX Error: There's no line here to end.

This error message is produced by knit when I try to convert an Rmd file to pdf. I had updated all my packages before my attempt.
YAML looks like:

---
title: "Proven i religionskunskap"
author: "Frank Bach"
date: "`r Sys.Date()`"
bibliography: reference.bib
biblio-style: apa-like
csl: university-of-gothenburg-apa-swedish-legislations.csl
toc: FALSE
tables: yes
output:  
  bookdown::pdf_document2
lang: sv
header-includes:
 \usepackage{booktabs}
 \usepackage{longtable}
 \usepackage{array}
 \usepackage{multirow}
 \usepackage{wrapfig}
 \usepackage{float}
 \floatplacement{figure}{H}
---
and the r setup

```{r setup, include = FALSE}
library(papaja)
library(tidyverse)
library(readr)
library(lavaan)
library(scales)
library(psych)
library(semPlot)
library(equaltestMI)
library(semTools)
library(kableExtra)
library(gridExtra)
library(broom)
library(gt)
knitr::opts_chunk$set(
  echo = FALSE,
	warning = FALSE,
	cache.extra = knitr::rand_seed,
	out.extra = ""
)
set.seed(42)
options(OutDec= ",")
theme_set(theme_apa())
```

Best regards
Frank Bach

I was able knit the document as pasted above:

image

I had to comment out the lines:

bibliography: reference.bib
csl: university-of-gothenburg-apa-swedish-legislations.csl

As I do not have those files. I also had to add library(jtools) to your list for the theme_apa() function.

This suggests that there is something else in your .Rmd file that is triggering this latex error. I have gotten this error before, but I forget what it was caused by or how I fixed it.

One thing that caught my eye is:

biblio-style: apa-like

I generally just type this as apalike -- something to try for sure, but I don't anticipate this fixing the problem.

Another thing that could cause this problem, is the header-includes part. I generally use:

header-includes:
  - \usepackage{booktabs}
  - \usepackage{longtable}

Rather than omitting the hypens as you have done. I would try this too.

If neither of these solutions fix your problem, I suggest trying to dive into the log file to find which line specifically is causing your problem. You could then paste a more complete .Rmd file that users can reproduce the error from.

Thank you for your help, it got me to dive in to the log file and I finally found the error without really understand it. I just erased the part and built it up from the beginning. Then it worked.

Best regards

Frank Bach

1 Like

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.