Problem in Latex: "There's no line here to end"
Asked Answered
F

8

9

I'm using Lyx to produce a Latex document, and when i try to convert to pdf, it complains of the error: "there's no line to end", and description is "//".

My Latex document is like 200 lines without many line breaks. How am I supposed to debug this and get this darned pdf converted. I literally am stuck on this for hours, can't submit this pdf. And for 90% of the time while writing this document, the convert to pdf works fine, I don't know know since what point did it start to fail.

Someone give me a quick way to get rid of this error? Otherwise this Latex document is useless.

Thanks.

Fremantle answered 31/10, 2009 at 7:44 Comment(0)
C
0

Dear Saobi, please post the offending line. Probably you have a "\" in a single-line math environment. If you post the code for the complete environment, I can try to indicate how to prevent this error.

Clarify answered 31/10, 2009 at 7:47 Comment(0)
C
27

That may sound stupid, but sometimes Latex needs a sign before the \, therefore:

~\\

That very much depends on the distribution you chose. LyX btw. is kind of crazy, when it comes to LaTeX export. Try auctex if you've got a month or two to spare ;)

Coalfish answered 31/10, 2009 at 11:29 Comment(2)
In cases like this you shouldn't be using `\` to add extra vertical space; use \vspace or \bigskip or similar.Pentobarbital
If you do this, you will get an Underfull Badness 10000 warning.Neoplasm
P
5

IMO this is the problem with LyX; when things go wrong it's hard to know where to look to fix the problem. This is a minimal document that shows an example of the error:

\documentclass{article}
\begin{document}
\\ there
\end{document}

I suggest exporting your LyX document to LaTeX, then compiling it "by hand" (with pdflatex mydoc or whatever) and see where in the document the error is appearing. You should then be able to correlate it with some misbehaving piece of the LyX document.

Pentobarbital answered 31/10, 2009 at 8:36 Comment(0)
C
0

Dear Saobi, please post the offending line. Probably you have a "\" in a single-line math environment. If you post the code for the complete environment, I can try to indicate how to prevent this error.

Clarify answered 31/10, 2009 at 7:47 Comment(0)
A
0

Do a binary search. Delete half the document, if it compiles then the problem was in the part you deleted. If not, then it's in the half you kept. Repeat the procedure on the offending portion and you should soon find which line is causing it.

Adrianadriana answered 31/10, 2009 at 10:15 Comment(0)
B
0

You can go to View -> View Source and click around until you find the offending line. In latex, line break is \\.

After doing that I realized the problem is you can't put a line break (Ctrl+Enter) at the start of a line (or cell). You can cheat by forcing a space (Ctrl+Space) before the line break. :)

Boeotia answered 11/10, 2011 at 6:14 Comment(0)
R
-1

My approach for locating compilation errors in LaTeX documents is based on a binary search approach. I suppose that a similar approach can be used in LyX.

The key idea is to divide your document in two parts of approximately the same size. At the boundary between these two parts a line containing \end{document} is inserted. If the document now can compile with no problems, the problem were located in the second half part of the document (otherwise it were in the first half part).

\documentclass{article}
\begin{document}
% First half part of the document
\section{Hello}

% Location for inserting \end{document}

% Second half part of the document
% in which the error is located
\section{World
\end{document}
Rizal answered 31/10, 2009 at 11:27 Comment(1)
You could also just read the line number off the error messageClarify
B
-1

In addition, check out that your LaTex lines already have content. I wrote an empty line, and It also causes error, from my experience.

\vspace{1cm}{ }\\
Backflow answered 7/1, 2022 at 15:43 Comment(0)
N
-1

~// solves my problem. Perhaps my problem was due to either "\begin{cases} \end{cases}" or "\begin{proof} \end{proof}". I am fresh to those two syntaxes.

I just simply changed "//" to "~//" above the occurrence of error message. Before the change it highlighted the entire "Claim 2" in red, and "Claim 2" did not start on a new line, just as below. enter image description here

After the change, it only shows one warning on "~//", and "Claim 2" starts on a new line. enter image description here

Background: I have written homework assignments in latex for 2 years, but I often used templates, and I do not have enough knowledge and skill of style.

Nihil answered 4/2 at 22:24 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Lastminute

© 2022 - 2024 — McMap. All rights reserved.