6

I have the over 30 errors in my LaTeX file, all over the \ref{...} command, and all following this similar pattern (I put it as a quote instead of code as it is long and code does not wrap)

I returned and saw under the sun, that the race is not to the swift, nor the battle to the strong, neither yet bread to the wise, nor yet riches to men of understanding, nor yet favour to men of skill; but time and chance happeneth to them all. \ref{bible:ecclesiastes}

Every time I get the following complaint over \ref{...}

perhaps you should insert a `~' before "\ref"

Why am I getting this error? How can I avoid it?

qubyte
  • 17,299
puk
  • 3,061
  • 5
  • 30
  • 41
  • 2
    Is this actually an error? Or is it just a suggestion that is output by vim? Is that the exact reference given? – Werner Dec 08 '11 at 18:57
  • @Werner it's actually an error. The exact error is |6 error| perhaps you should insert a~' before "\ref"` where 6 is the line number – puk Dec 08 '11 at 19:04
  • @derobert feel free to recommend moving this page. The reason I put it here, as opposed to TeX.SE is because I felt it was more a problem with vim's syntax check than LaTex's syntax. – puk Dec 08 '11 at 19:05
  • @puk: That's not default vim behavior. Maybe you've enabled a plugin (such as checksyntax) which is calling chktex? (and yes, I voted to move it; "latex editors" is explicitly given in the FAQ, so vim used for editing TeX would be OK there, I think ) – derobert Dec 08 '11 at 19:12
  • @derobert I have syntastic on, but that is just for javascript. Also, I am using beautifiers for javascript and PHP. Besides that, I have not turned on any syntax checkers. – puk Dec 08 '11 at 19:21
  • Duplicate in terms of reference: Tilde and Slash in LaTeX, but not in terms of a vim solution. – Werner Dec 08 '11 at 20:12
  • 3
    @puk: syntastic also does error checking for a variety of filetypes, including LaTeX. For LaTeX, it uses the lacheck script, which gives the error message. – Aditya Dec 09 '11 at 08:26

1 Answers1

20

If you write "... this was written by \ref{foo}" the following output is possible:

... this was written by
[1]

which looks ugly in fact of the linebreak. This is the reason why vim is very nice to you and told you that you should write: "... this was written by~\ref{foo}". Then your output is at least:

...  this  was  written 
by [1]

So it is not a LaTeX error, but an "error message" from vim.