2

I'm trying to do the following: I'd like to say "as shown in $(18)$ below", where $(18)$ is a certain equation that (which I shall label norm-split), as per the 'below', I have not yet written. Is there a way (or, rather, what is the way) that I can do this with \eqref? At the moment, if I just replace "$(18)$" with "\eqref{norm-split}", then it just puts $(5.2)$, which is the (sub)section number.

Any advice would be most appreciated.

I'm using TeXstudio under MiKTeX. Also, this is the first day that I've been using TeX - I have always previously used MathJax - so I'm a bit of a noob at it in some ways, but in others I know a reasonable amount!


Here's my code (with the intermediary bits taken out):

as shown in \eqref{norm-split} below. We keep the $u \ge 0$ constraint
in the primal objective, however. This is because we can still do
backwards primal step explicitly and ... we may write
\label{norm-split}
\begin{align}
\begin{split}
\| (v,w) - (v',w') \| &= \|v-v'\|_q^q + \|w-w'\|_2^2 \\
& = \sum_{i=1}^n \|v^i - v'^i\|_q^q + \|w - w'\|_2^2,
\end{split}
\end{align}
the backwards dual step ...
Sam OT
  • 1,329
  • 1
    You need an equation with a label to reference it. If the equation isn't written yet (hence not labeled) I would suggest to use a package like todonotes, which will let you write reminders in the margin, at the places where you want to insert cross-references. – Bernard Jul 14 '15 at 11:44
  • 2
    \eqref{norm-split} should never produce the section number but it is hard to debug code you have not shown. Either it should give the equation number (if \label{norm-split} is in the equation) or it should give an undefined label warning and print ?? (if the equation is not yet in the document). – David Carlisle Jul 14 '15 at 11:47
  • Ah, let me clarify: by "not yet written", I mean that the equation is below. I have typed it in, just "yet" is referring to ordering in the document. – Sam OT Jul 14 '15 at 11:48
  • 1
    Then you have something wrong, most likely \label is not in the equation, but as I say it is hard if you do not give any clues as to what the input looks like. – David Carlisle Jul 14 '15 at 11:50
  • Ok, yeah, "\label" is outside the "\begin{align} ... \end{align}" because I wanted the label centralised between the two lines - is this not necessary? – Sam OT Jul 14 '15 at 11:53
  • 1
    No. \label doesn't print anything. It is just used to store the value of the currently active counter. This is not the equation counter if \label was placed outside an equation environment. – AlexG Jul 14 '15 at 12:19
  • 2
    You have \label out of the math environment, there's nothing to refer but the section command. You need to put it inside. In any case, what's the point of using {align} and {split}? Either use {align} or {equation} with {split}. – Manuel Jul 14 '15 at 12:33
  • @AlexG - yeah, I realise label doesn't print anything... and thinking about it now that means that there's no way it could change what I wanted! Oops! – Sam OT Jul 14 '15 at 12:44
  • @Manuel As I said, this is the first day I've used LaTeX, and I looked online to see how to only put the one equation number on, and I just copied the way an answer on here had done it... although they were actually aligning something... – Sam OT Jul 14 '15 at 12:48
  • 1
    Look into the amsmath documentation for examples (texdoc amsldoc). Equations (single ones, aligned ones, multiline ones etc.) are automatically numbered. The cited doc is full of examples that make sense. – AlexG Jul 14 '15 at 12:51
  • @AlexG You could make an answer. – Manuel Jul 14 '15 at 12:52
  • Ok, it is working now. I changed "align" to "equation" and moved the "label" to be after "equation" and before "split". – Sam OT Jul 14 '15 at 13:00
  • \label grabs the last counter to call \refstepcounter (possibly the page number). Putting it right after \begin{align} is safest. – John Kormylo Jul 14 '15 at 17:28
  • Ah, thank you for the clarification. I have it working now. :) – Sam OT Jul 14 '15 at 21:20
  • 4
    I'm voting to close this question as off-topic because the problem has been resolved within the comments as a basic misunderstanding regarding the use of the \label-\ref system. As generic reference, consider reading up on Understanding how references and labels work. – Werner Dec 18 '15 at 06:57
  • That's fine by me :) -- close away! – Sam OT Dec 18 '15 at 13:08

0 Answers0