5

When trying to knit an rmarkdown file to a PDF, I am encountering the following error. It is referencing a line number with no text reference and the line number is out of range of the number of lines of the file.

Rmarkdown Error:

! Paragraph ended before \text@ was complete.

<to be read again>

                   \par
l.375 

If anyone has encountered a similar error or has an idea about how to identify the location of the error in the file it'd be appreciated.

J19
  • 51
  • 1
  • 3

1 Answers1

4

I have encountered this a couple times. It can be frustrating because you are likely finishing a lot of work and just creating the report so it can take some time to knit to find what is causing it.

The first thing you likely want to do is to heed that next line that has:

... See <your_output_file>.log for more info. ...

However because of the confluence of using all of TeX, Markdown and R's text generator, the line numbers are off a bit in this log file, so you may need to just start hunting.

I tend to use $\color{blue}{\text{, however likely searching for \text{ throughout your .Rmd file should be enough.

Likely you will need to escape some character as described in this answer. For me it is often parentheses.

For example I just got this error on a line that had:

$\color{blue}{\text{..., (if provided)...}}$

I was able to resolve with:

$\color{blue}{\text{..., \(if provided\)...}}$
aaron blythe
  • 324
  • 1
  • 7
  • 3
    In case it helps anyone else, this is also the error I saw when I used \text{95% CI} instead of \text{95\% CI} – jdcode Apr 13 '22 at 12:58