I'm writing a scientific article and I would like to reference a formula before it appears in the text. In principle it should work, the problem is that I want to use the hyperref package, so that I can create a hyperlink to that formula. This is the code I'm using:

F is defined in Formula \ref{eq:Fdef} \\

\begin{equation} \label{eq:Fdef}
F = RU

If I use \usepackage{hyperref} at the beginning of the document I obtain the following error:

! Paragraph ended before \Hy@setref@link was complete.

I thought that maybe there was some way of defining the equation before, but including it in the text later, but I didn't find how to do it, any suggestion?

  • 1
    Please complete your code with the document class and a minimal set of packages used. That way it's easier for people here to spot the problem. – Herr K. Apr 30 '15 at 18:26
  • 2
    Getting rid of the \\ will fix it (even with hyperref). You shouldn't be using \\ in normal text, in any event, or it will tend to produce the wrong vertical spacing, Just leave a blank line for a new paragraph (or not). – Steven B. Segletes Apr 30 '15 at 18:26
  • also better not to leave a blank line before a math display. that takes the spacing out of latex's control by making it look like the beginning of a paragraph. the spacing above and below displays is cooked into latex, but only if it's not avoided by extra blank lines in the input. – barbara beeton Apr 30 '15 at 18:31

The fix is obtained by removing the \\ from the line, following the \ref.

As I commented, the use of \\ is specialized for things like tabular and should generally be avoided in normal text. See David's answer at When to use \par and when \\, or blank lines for a better discussion.

I don't know what hyperref did to actually make the code break by placing a \\ immediately following a \ref, but since it is bad LaTeX to use it, good grammar takes care of the problem.

As barbara adds, an equation environment is generally not preceded by a paragraph break.

And, as egreg adds, the "F" in the text should be $F$ to place it in math mode.

$F$ is defined in Formula \ref{eq:Fdef}
\begin{equation} \label{eq:Fdef}
F = RU

enter image description here

| improve this answer | |
  • 1
    You should also use $F$ before “is defined”. – egreg Apr 30 '15 at 18:41
  • Yet another hint from hyperref's README: Consider using the environments that package amsmath provide, e.g. gather for equation. The environment equation can even redefined to use gather: \usepackage{amsmath} \let\equation\gather \let\endequation\endgather – Arash Esbati May 1 '15 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.