Problem in Latex: "There's no line here to end" - latex

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.

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 ;)

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.

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.

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.

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. :)

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}

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}{ }\\

Related

latex: footnote in glossaries entry

I need help with the latex glossaries package. I just need a footnote within a glossary entry.
Example:
\newglossaryentry{glos:vo}{
name=ValueObject,
description={a very good explanation for valueObject\footnote{S.89ff \cite{aBookInBibliography}}.}}
Texmaker refuses to build PDF. The log file is confusing as always, saying something like this:
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
! Too many }'s.
So any ideas here? Thank you.
i've got it. it has not been the fault of the footnote or cite. it turned out, my description text has been to long.
whysoever latex accepts description texts just with 1024 characters maximum.

How do I ref a figure in LaTeX before it occurs?

I always like my figures to be placed in between text as opposed to the top or bottom of the page. I also like to talk about the figure before it is shown. So I am trying to have something like this:
By looking at Figure~\ref{fig:VCO} you can see that blah blah blah.
\begin{figure}[h]
\caption{VCO test circuit}\label{fig:VCO}
\begin{center}
\includegraphics[width=0.9\columnwidth]{figures/VCO_circuit.eps}
\end{center}
\end{figure}
This doesn't seem to work because it I guess it is referencing something that hasn't occurred yet? Does anyone have some simple solution? I am still very new to LaTeX.
Generally LaTeX needs at least two passes to resolve all its references, the first time to write them to an auxiliary file and the second time to put them into the final ps/pdf/dvi file. So it does not matter where the reference is.
A third pass will be needed, for example, if your document has a long table-of-contents which will screw up page numbers.
It failed the first time because labeling and referencing are a two-pass process. The first time you processed your latex, all the labels were being indexed so the ref failed. The second time around, since the labels had been indexed the ref knew what it was actually referencing.
I would add that latexmk (link) has proven invaluable to me over the years. This is a LaTeX "build" script written in Perl that is designed to compile .tex source files the right number of times. It parses the output from the latex command and performs dependency checking to ensure that the output document is kept up-to-date with the minimum number of passes. It can also deal with BibTeX bibliography files. Generally speaking, I invoke latexmk from either an Ant or GNU Make makefile and treat it just like I'm compiling C++ code, for example.
I had same problem and I found this solution:
\graphicspath{{images/}}
\DeclareGraphicsExtensions{.jpg}
\makeatletter
\newenvironment{tablehere}
{\def\#captype{table}}
{}
\newenvironment{figurehere}
{\def\#captype{figure}}
{}
\makeatother
\begin{figurehere}
\includegraphics[height=5cm]{2-14aGa-Sur.jpg}
\caption{Hliněná destička s mapou severu Mezopotámie}
\label{fig:Ga-Sur}
\end{figurehere}
\graphicspath{{images/}} is there to declare your path to your pictures
\DeclareGraphicsExtensions{.jpg} is there for declare picture extension (multiple can be with comma (I think ;-))
\makeatletter
\newenvironment{tablehere}
{\def\#captype{table}}
{}
\newenvironment{figurehere}
{\def\#captype{figure}}
{}
\makeatother
is there for precise determination of position here
\begin{figurehere}
\includegraphics[height=5cm]{2-14aGa-Sur.jpg}
\caption{Hliněná destička s mapou severu Mezopotámie}
\label{fig:Ga-Sur}
\end{figurehere}
there is your picture with height specified and caption and label with it...
I hope it will help you ;-).

latex undefined control sequence with tableofcontents

I was using \documentclass{amsmath} for awhile with no issues, but I recently wanted to switch to the normal \documentclass{article} because I thought it looked nicer. However, now my \tableofcontents command produces this error:
! Undefined control sequence.
<argument> \tocsection
{}{1}{Purpose}
l.1 ...ne {section}{\tocsection {}{1}{Purpose}}{4}
?
I'm writing a research paper with latex, and Purpose is the first section (the command I'm using is \section{Purpose}). It's saying line 1 has the error, which is \documentclass{article}. Can anyone help me with this error?
1) Most probably "l.1" refers to the first line of the TOC file, not of the TEX file. It's impossible to tell for sure from the little snippet you've shown.
2) First thing to try in this situation will be to delete (or better to move to some temp. place) all the TeX-generated files in your working folder. Usually this means that only TEX and BIB files should remain (and any figures if you have them). Then run the usual latex; bibtex; latex; latex sequence.
3) If you still get the same error, there is probably some package conflict. To diagnose that, we'll need all of your preamble.

Why does LaTeX start a new line when making a reference

I just created a LaTeX document and compile it to a PDF using pdftex. Every time I make a reference using the \ref command, the reference is put on a new line. Why does this happen and how do I prevent this?
Are you by any chance using \\ in URLs instead of //? \\ is used as a linebreak in TeX.
Try to localize the problem: create a new file which initializes hyperref the same way, uses no other packages, and has some text and a reference. Check if references still start on new lines. If they do, you can show it here (and on LaTeX forums); if not, add more of your report's preamble until you get a file which exhibits the problem.
Can you prepare a minimum example demonstrating your problem?
I've tried with:
\documentclass{report}
\usepackage[pdftex,breaklinks=true,bookmarks=true,bookmarksopen= true,pdfpagemode=UseNone,plainpages=false,pdfpagelabels,pdfstartview=FitH,olorlinks=true,citecolor=blue]{hyperref}
\begin{document}
Test \url{http://test.com} \ref{http://someother.com}.
\end{document}
And the whole output is a single line in PDF.
BTW \ref is used to produce internal document links (like in "As described in chapter \ref{chapter:second}...").
It was my own fault, I used \par for the paragraph sign instead of \P. This is one of my first LaTeX documents, so I overlooked it. Thanks for the quick responses/answers though.

Special characters in LaTeX table caption

When I include \overline{x} or other special characters in the caption text of a table, the whole caption text won't appear at all. When I put simple text without special characters, the caption works fine. How can I include special characters in the caption?
Are you putting $ around the maths? I.e.:
\caption{This is a caption with maths $\overline{x}$ in it.}
Apparently your real problem was that TeX's fancy error correction mechanism prevented you from knowing that there was a syntax error in the document. Back in 1982 or so, running TeX on a long document would take so much time that Knuth didn't want TeX to just quit when it ran into an error. Instead, TeX tries to guess what you meant and go on typesetting the document, so that you can fix a bunch of errors before you run it again; for example, when it spots a math-mode command outside math mode, it assumes that you forgot a dollar sign and inserts it. No automatic error-correction mechanism is perfect, so syntax errors often cause some part of text to be lost, or typeset in a wrong way.
TeX does try to tell you that it has found errors, but I suppose current IDEs make it easy to ignore the output. Try running latex on the document from the command line and pay attention to what it says. For example, the short document
\documentclass{article}
\begin{document}
It seems \sqrt{2} I forgot some dollar signs.
\end{document}
causes TeX to prompt you with
! Missing $ inserted.
<inserted text>
$
l.3 It seems \sqrt{
2} I forgot some dollar signs.
?
The 2009 way of dealing with this is to type X to quit, fix the source document, and run latex again - but you can actually enter other commands at the prompt to edit the input that TeX sees. If you just type Q (to run quietly - same as specifying \batchmode, which Emacs or whatever IDE you are using probably does for you) you get a typeset document as a result, and it might not be obvious that there are in fact syntax errors in it.
If you looking for how to insert any special character in Latex in a table then this may help you. Check this out...
\documentclass{article}
\begin{document}
\begin{tabular}{|l|r|r|}
Item & Quality & Price(\$)\\
Nails & 500 & 34\\
Wooden boards & 100 & 4\\
Bricks & 240 & 11\\
\end{tabular}
\end{document}

Resources