0

I'm confused about why for two seemingly identical lines of code, one file will give me an error while the other will not. Error-free code:

\hyperlink{page.2}{\normal{Insert text here:}}
\vspace{-6.5mm}\\
% \normal{Insert text here}
\begin{compactitem}
 \item[$\bullet$ \Text { } {\color{OliveGreen}\bf{+}}:] \AddTicker
 \item[$\bullet$ \Text { }{\color{red}\bf{-}}:] \DeleteTicker
\end{compactitem}

\vspace{1mm}\\

\hspace{0mm}\textbf{\normal {Insert text here:}}

Code that gives me errors (the error is in the line between vspace and hspace):

\normal{\hyperlink{page.3}{Insert text here:}}
\vspace{-6.5mm}\\
% \normal{None}
\begin{compactitem}
  \item[$\bullet$ \Text{ } {\color{OliveGreen}\bf{+}}:] \AddTicker
  \item[$\bullet$ \Text{ } {\color{red}\bf{-}}:] \DeleteTicker
\end{compactitem}

\vspace{0mm}\\

\hspace{0mm}\textbf{\normal {Insert text here:}}

I don't think it's the switch in order of \normal and \hyperlink as it doesn't give me an error in other places. I've read that many times this error has to do with ending a paragraph, so am I in trouble because I have a vspace of 0 mm instead of 1 mm?

Furthermore, although I get the following message, I still have a pdf output. Does that mean this is a warning message only, and my file compiled correctly after all?

output file: announcement.tex

Error: running 'texi2dvi' on 'announcement.tex' failed

LaTeX errors:
ex.tex:330: LaTeX Error: There's no line here to end.
5
  • Your uses of ` \\ ` are wrong. They should all be deleted. Beside this, as you didn't provide a complete example your code can not be tested, as it is unclear how \normal is defined. Commented Jun 26, 2017 at 14:20
  • I removed the r tags as (this time) the question is unrelated to R although it would have been better if the example had been a complete (non-r) document that generated the error. Commented Jun 26, 2017 at 14:22
  • tex recovers from errors only enough to syntax check the remaining document, it makes no attempt to make sensible pdf output so in general no, the fact that a pdf is made if you scroll past an error does not imply that it is just a warning. Commented Jun 26, 2017 at 14:30
  • why are you using texi2dvi which is designed for texinfo documents with latex? (presumably it has been extended to detect latex input as you get some output at all but it seems a strange choice of command) Commented Jun 26, 2017 at 14:31
  • \bf{-} is wrong, \bf should not be used in latex, but if it is used, it does not take an argument, so the syntax would be {\bf +} (like the latex version {\bfseries +}) not like \textbf{+} Commented Jun 26, 2017 at 14:33

1 Answer 1

1
...ctitem}

\vspace{1mm}\\

will give the error as you are ending a line when you are in vertical mode so there is no line to end.

\hyperlink{page.2}{\normal{Insert text here:}}
\vspace{-6.5mm}\\

Is wrong, you should never end a paragraph with \\ but it will not error, it will just give an underfull hbox warning.

The difference between the two is the blank line before the \vspace in one case but not the other. It's almost always best to have a blank line before \vspace.

4
  • Thanks @David, I actually didn't receive any errors with the \vspace{1mm}\\, only \vspace{0mm}\\ However, is ending any line with `\` bad practice? Should I use \leavevmode \\ instead?
    – Anna
    Commented Jun 26, 2017 at 14:32
  • yes you must have got an error but as you have provided no example it is impossible to say. You should almost never have \\ in a document other than its use to end table rows. Certainly none of the ones you show in your fragments should be there at all. Commented Jun 26, 2017 at 14:35
  • @Anna You normally shouldn't use \\ at all. Outside of tabulars it is almost always wrong. Commented Jun 26, 2017 at 14:35
  • @UlrikeFischer and I are subject to Group-think, as you see. Commented Jun 26, 2017 at 14:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .