Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm a LyX beginner so please don't worry about stating the obvious.

I'm numbering equations by section in my document. That's working fine. However, when I refer to the same equation later on in the text I can't see how I can give it its original reference number.

So if y=x+2 is numbered as 4.2.2, I want to be able to give y=x+2 the same number next time I use it. Is there a straightforward way of doing this? I'm assuming I have to sandwich the equations in code of some sort.

I'm using the scrbook (Koma-script) document class. I'm using the modules: Theorems (AMS), Theorems Numbered by Chapter, Number Equations by Section.

The LaTeX preamble is:

\usepackage{microtype}
\usepackage {hyperref}
\usepackage{amsmath} 
\numberwithin{equation}{section}
\setkomafont{captionlabel}{\bfseries}

To date I've been changing the code in my LyX documents using Windows Notepad. Is that the best way of editing code?

share|improve this question
1  
I know this isn't really helpful, but it is not usual to repeat an equation, and if you do, you shouldn't label it a second time, even with the original label. It's better in general simply to refer to the original. If you're concerned with readers flipping back and forth in a pdf, consider the hyperref package. –  qubyte Nov 5 '11 at 15:19

2 Answers 2

up vote 7 down vote accepted

Werner provided the real method, here's translated to LyX GUI (I tested this only with the simplest example):

  1. For the first instance of the equation, add a label by right clicking the equation and selecting "Equation label".

  2. The second time, write the equation, and while still in math mode add a TeX code box, by pressing Ctrl + L.

  3. In this code box, write tag{ (the backslash should already be there, at least it was when I tested). This should give you a set of braces with a small box in it.

  4. Choose Insert --> Cross-reference, and select the reference to the first instance of the equation.

A video showing the process, the TeX code menu option was outside the frame: http://www.youtube.com/watch?v=NTqLMO8WS6w

share|improve this answer
    
Torbjørn T. Brilliant - it works fine, though I found I had to choose the <reference> and not the (<reference>). Thanks –  Peter4075 Nov 7 '11 at 19:23

If you are using some packages of the AMS-LaTeX bundle, you could use amsmath reprint an equation number using the \tag{<stuff>} feature. It typesets <stuff> (which can be anything you specify) as the equation number. Then you can place the reference of your original equation in the tag so that it gets the same number.

Here is a short example:

enter image description here

\documentclass{scrbook}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\section{Some equations}
Here is a linear equation
\begin{equation}
  y=x+2 \label{eq:first}
\end{equation}
that is very interesting. However, the quadratic equation
\begin{equation}
  f(x)=ax^2+bx+c \label{eq:second}
\end{equation}
is far more complex. Come to think of it, I actually \emph{do\/} enjoy
\begin{equation*}
  y=x+2 \tag{\ref{eq:first}}
\end{equation*}
above~\eqref{eq:second}.
\end{document}

I only included the necessary package (amsmath) in the above example, but it should work with the other components of your document (like hyperref) without problem.

share|improve this answer
    
Werner - thank you, but what do I do with that? If I insert a simple display formula, eg y=x^2 the code is: \begin_body \begin_layout Standard \begin_inset Formula [ y=x^{2} ] \end_inset \end_layout \end_body How do I use the code you sent me? Thank you –  Peter4075 Nov 5 '11 at 16:09
    
It is obvious that I am not in sync with Lyx. Is there no way for you to insert some of the above code within Lyx? You mention you're using Windows Notepad instead. Perhaps some with Lyx experience can comment on this, since my answer show how it can be done... but perhaps not how it can be done in Lyx! –  Werner Nov 5 '11 at 16:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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